Exemplo n.º 1
0
        public bool SetBlink(string Parameter, string Value)
        {
            bool result = false;

            try
            {
                ParamConfig ctrlCfg;
                if (Controls.TryGetValue(Parameter, out ctrlCfg))
                {
                    if (Value.ToUpper().Equals("TRUE"))
                    {
                        if (!ctrlCfg.Status.ToUpper().Equals("BLINK"))
                        {
                            ChangeHisRecord.New(ctrlCfg.DeviceName, ctrlCfg.Type, ctrlCfg.Address, ctrlCfg.Parameter, "Blink", ctrlCfg.Status);
                        }
                        ctrlCfg.Status = "Blink";
                        new Thread(() =>
                        {
                            Thread.CurrentThread.IsBackground = true;
                            _Report.On_Data_Chnaged(Parameter, "BLINK", ctrlCfg.Type);
                        }).Start();
                    }
                    else
                    {
                        if (!ctrlCfg.Status.ToUpper().Equals("FALSE"))
                        {
                            ChangeHisRecord.New(ctrlCfg.DeviceName, ctrlCfg.Type, ctrlCfg.Address, ctrlCfg.Parameter, "False", ctrlCfg.Status);
                        }
                        ctrlCfg.Status = "False";
                        new Thread(() =>
                        {
                            Thread.CurrentThread.IsBackground = true;
                            _Report.On_Data_Chnaged(Parameter, "FALSE", ctrlCfg.Type);
                        }).Start();
                    }
                }
                else
                {
                    logger.Debug("SetIO:Parameter is not exist.");
                }
            }
            catch (Exception e)
            {
                logger.Debug("SetBlink:" + e.Message);
            }
            return(result);
        }
Exemplo n.º 2
0
        public void SetIO(Dictionary <string, string> Params)
        {
            Dictionary <string, IDIOController> DIOList = new Dictionary <string, IDIOController>();

            foreach (string key in Params.Keys)
            {
                string Value = "";
                Params.TryGetValue(key, out Value);
                ParamConfig ctrlCfg;
                if (Controls.TryGetValue(key.ToUpper(), out ctrlCfg))
                {
                    IDIOController ctrl;
                    if (Ctrls.TryGetValue(ctrlCfg.DeviceName, out ctrl))
                    {
                        if (!Value.Equals(ctrlCfg.Status))
                        {
                            ChangeHisRecord.New(ctrlCfg.DeviceName, ctrlCfg.Type, ctrlCfg.Address, ctrlCfg.Parameter, Value, ctrlCfg.Status);
                        }
                        ctrlCfg.Status = Value;
                        ctrl.SetOutWithoutUpdate(ctrlCfg.Address, Value);
                        new Thread(() =>
                        {
                            Thread.CurrentThread.IsBackground = true;
                            _Report.On_Data_Chnaged(key, Value, ctrlCfg.Type);
                        }).Start();

                        if (!DIOList.ContainsKey(ctrlCfg.DeviceName))
                        {
                            DIOList.Add(ctrlCfg.DeviceName, ctrl);
                        }
                    }
                    else
                    {
                        logger.Debug("SetIO:DeviceName is not exist.");
                    }
                }
                else
                {
                    logger.Debug("SetIO:Parameter is not exist.");
                }
            }
            foreach (IDIOController eachDIO in DIOList.Values)
            {
                eachDIO.UpdateOut();
            }
        }