public int Interval = 3; //默认是3秒 /// <summary> /// 启动模拟器 /// </summary> /// <param name="form"></param> public void InitSimulator(int mInterval) { Task.Run(() => { Scada.Business.SCADA_DRIVER DriverBll = new Scada.Business.SCADA_DRIVER(); Scada.Business.SCADA_DEVICE_DRIVER DeviceDriverBll = new Scada.Business.SCADA_DEVICE_DRIVER(); Scada.Business.IO_DEVICE deviceBll = new Scada.Business.IO_DEVICE(); Scada.Business.IO_COMMUNICATION commBll = new Scada.Business.IO_COMMUNICATION(); Scada.Business.IO_SERVER serverBll = new Scada.Business.IO_SERVER(); List <Scada.Model.SCADA_DRIVER> CommDrivers = null; List <Scada.Model.SCADA_DEVICE_DRIVER> DeviceDrivers = null; Interval = mInterval;//获取时间间隔 Servers = serverBll.GetModelList(""); Communications = commBll.GetModelList(""); Devices = deviceBll.GetModelList(""); CommDrivers = DriverBll.GetModelList(""); DeviceDrivers = DeviceDriverBll.GetModelList(""); for (int i = 0; i < Communications.Count; i++) { Communications[i].DriverInfo = CommDrivers.Find(x => x.Id == Communications[i].IO_COMM_DRIVER_ID); if (Communications[i].DriverInfo != null) { Communications[i].CommunicateDriver = DriverAssembly.CreateCommunicateDriver(Communications[i].DriverInfo); } Communications[i].Devices = Devices.FindAll(x => x.IO_COMM_ID == Communications[i].IO_COMM_ID && x.IO_SERVER_ID == Communications[i].IO_SERVER_ID); for (int j = 0; j < Communications[i].Devices.Count; j++) { Communications[i].Devices[j].DriverInfo = DeviceDrivers.Find(x => x.Id == Communications[i].Devices[j].DEVICE_DRIVER_ID); if (Communications[i].Devices[j].DriverInfo != null) { Communications[i].Devices[j].DeviceDrive = DriverAssembly.CreateDeviceDrive(Communications[i].Devices[j].DriverInfo); } } } }); }
public bool ClearServers(string serverid) { try { SCADA_DRIVER DriverBll = new SCADA_DRIVER(); IO_ALARM_CONFIG alarmBll = new IO_ALARM_CONFIG(); IO_COMMUNICATION commBll = new IO_COMMUNICATION(); IO_DEVICE deviceBll = new IO_DEVICE(); IO_PARA paraBll = new IO_PARA(); IO_SERVER serverBll = new IO_SERVER(); alarmBll.Clear(serverid.Trim()); commBll.Clear(serverid.Trim()); deviceBll.Clear(serverid.Trim()); paraBll.Clear(serverid.Trim()); serverBll.Clear(serverid.Trim()); DbHelperSQLite.Compress(); return(true); } catch { return(false); } }