using allInOneMachine;
using BroadcastModule;
using centralController.advert;
using centralController.WebServer;
using db;
using Monitor;
using MySql.Data.MySqlClient;
using NumMachine;
using parkMonitor.language;
using parkMonitor.LOG;
using parkMonitor.model;
using PLCS7;
using System;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using System.Management;
using System.Net;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Monitor
{
public class Monitor : IMonitor
{
///
/// 监控模块单例
///
public static Monitor ins { get; set; }
///
/// 中控系统总状态
///
public static bool globalStatus = false;
///
/// 初始化步骤
///
public static int initializeState = 0;
///
/// PLC对象句柄
///
public static AbstractPLCLinker PLC = null;
public static string plcIPAddr { get; set; }
public static int plcRack { get; set; }
public static int plcSlot { get; set; }
public static string[] plcDatablockConfig { get; set; }
public static int plcTerminalCount { get; set; }
public static int plcParkingSpaceCount { get; set; }
public static int plcRefreshInterval { get; set; }
public static MainBlockStru mainBlockInfo { get; set; }
public static List parkingSpaceInfo { get; set; }
public static ErrorInfoStru PLCErrorInfo { get; set; }
///
/// 远程数据库操作句柄
///
public static DBOperation remoteDBOper;
///
/// 本地数据库操作句柄
///
public static DBOperation localDBOper;
///
/// 显示板操作对象句柄
///
public static BroadcastLinker allInOneMachine;
public static string allInOneMachineIP { get; set; }
public static int allInOneMachinePort { get; set; }
///
/// 号牌机操作句柄
///
public static NumMachineLinker numMachineLinker;
public static IntPtr flpHandle;
///
/// 本地web操作句柄
///
public static IWebServer webServer;
public static int webPort { get; set; }
///
/// 广告路径
///
public static string advertPath { get; set; }
public static AdvertManager advertMgr;
public static centralController.centralController mainWin { get; set; }
public static string defaultLic{get;set;}
///
/// 车库层数
///
public static int floors { get; set; }
///
/// 每层分块数
///
public static int rows { get; set; }
///
/// 每块车位数
///
public static int spacesInRow { get; set; }
///
/// 系统初始化器句柄
///
internal static SystemInitializer sysInitializer;
///
/// 系统关闭状态
///
public static bool isClosing;
///
/// 车库ID
///
public static int garageID;
///
/// PLC读取锁
///
public static object PLCReadLock = new object();
///
/// 是否初始化PLC数据更新次数的计数,重连PLC后初始化该值以刷新车位
///
public static bool updateCount = false;
///
/// 将显示在界面的提示字符串
///
private static Queue notificationQueue = new Queue();
private const int MAXLINES = 80;
private void PLCUpdate()
{
int linkCount = 0;
int count = 0;
bool disconnected = false;
while (!isClosing)
{
if (updateCount)
{
count = 0;
updateCount = false;
}
if (count > 50)
count = 3;
count++;
if (PLC != null)
{
if (PLC.isConnected)
{
if (disconnected) {disconnected = false; SetNotification("PLC已重新连接",TextColor.Info); }
linkCount = 0;
lock (PLCReadLock)
{
List