コード例 #1
0
ファイル: SimulatorManager.cs プロジェクト: nxzzkj/lazyiot
        public int Interval = 3; //默认是3秒

        /// <summary>
        /// 启动模拟器
        /// </summary>
        /// <param name="form"></param>
        public void IniSimulator()
        {
            try
            {
                if (SimulatorForm != null)
                {
                    ColseSimulator();
                    SimulatorForm.Close();
                    SimulatorForm = null;
                }

                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();
                Interval       = 120;//获取时间间隔
                Servers        = serverBll.GetModelList("");
                Communications = commBll.GetModelList("");
                Devices        = deviceBll.GetModelList("");
                for (int i = 0; i < Communications.Count; i++)
                {
                    Communications[i].Devices = Devices.FindAll(x => x.IO_COMM_ID == Communications[i].IO_COMM_ID && x.IO_SERVER_ID == Communications[i].IO_SERVER_ID);
                }
            }
            catch
            {
            }
        }
コード例 #2
0
ファイル: SimulatorManager.cs プロジェクト: nxzzkj/lazyiot
        public void ReloadSimulator(string IO_SERVER_ID)
        {
            Task.Run(() => {
                if (IOCenterManager.SimulatorManager.SimulatorForm != null)
                {
                    IOCenterManager.SimulatorManager.ColseSimulator();
                }
                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();
                lock (Servers)
                {
                    Scada.Model.IO_SERVER deleteServer = Servers.Find(x => x.SERVER_ID == IO_SERVER_ID);
                    if (deleteServer != null)
                    {
                        Servers.Remove(deleteServer);//删除这个采集站信息
                    }

                    Scada.Model.IO_SERVER newsServer = serverBll.GetModel(IO_SERVER_ID);
                    if (newsServer != null)
                    {
                        Servers.Add(newsServer);
                    }
                    else
                    {
                        return;
                    }
                }
                lock (Communications)
                {
                    for (int i = Communications.Count - 1; i >= 0; i--)
                    {
                        if (Communications[i].IO_SERVER_ID == IO_SERVER_ID)
                        {
                            //首先删除设备
                            for (int d = Communications[i].Devices.Count - 1; d >= 0; d--)
                            {
                                Devices.Remove(Communications[i].Devices[d]);
                            }
                            Communications.RemoveAt(i);
                        }
                    }

                    List <Scada.Model.IO_COMMUNICATION> newsCommunications = commBll.GetModelList(" IO_SERVER_ID='" + IO_SERVER_ID + "' ");
                    Communications.AddRange(newsCommunications);
                    List <Scada.Model.IO_DEVICE> newsDevices = deviceBll.GetModelList("  IO_SERVER_ID='" + IO_SERVER_ID + "'");
                    Devices.AddRange(newsDevices);

                    for (int i = 0; i < newsCommunications.Count; i++)
                    {
                        newsCommunications[i].Devices = newsDevices.FindAll(x => x.IO_COMM_ID == newsCommunications[i].IO_COMM_ID && x.IO_SERVER_ID == newsCommunications[i].IO_SERVER_ID);
                    }
                }
            });
        }
コード例 #3
0
        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);
                        }
                    }
                }
            });
        }
コード例 #4
0
        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);
            }
        }