Пример #1
0
 protected override void AfterMyWorkStateChanged(object sender, EventArgs e)
 {
     if (myWorkState)
     {
         AiProtocol aiProtocol = new AiProtocol()
         {
             CaseNo = GateWaySetting.CaseNo, APISetting = APISetting
         };
         AbsProtocols.Add(aiProtocol);
         StateProtocol stateProtocol = new StateProtocol()
         {
             CaseNo = GateWaySetting.CaseNo, APISetting = APISetting
         };
         AbsProtocols.Add(stateProtocol);
         ReadThread = new Thread(Analysis);
         ReadThread.Start();
     }
     else
     {
         if (ReadThread != null)
         {
             ReadThread.Abort();
         }
     }
 }
Пример #2
0
        protected override void AfterMyWorkStateChanged(object sender, EventArgs e)
        {
            if (myWorkState)
            {
                foreach (var item in ElectricConfigs)
                {
                    ElectricEnumType = (ElectricEnumType)item.ElectricEnumType;
                    switch (ElectricEnumType)
                    {
                    case ElectricEnumType.PA310:
                    {
                        PA310Protocol protocol = new PA310Protocol()
                        {
                            GatewayIndex = item.GatewayIndex, DeviceIndex = item.DeviceIndex, ID = (byte)item.DeviceID, LoopEnumType = item.LoopEnumType, PhaseAngleEnumType = item.PhaseAngleEnumType, PhaseEnumType = item.PhaseEnumType, ElectricEnumType = item.ElectricEnumType
                        };
                        AbsProtocols.Add(protocol);
                    }
                    break;

                    case ElectricEnumType.HC660:
                    {
                        HC6600Protocol protocol = new HC6600Protocol()
                        {
                            GatewayIndex = item.GatewayIndex, DeviceIndex = item.DeviceIndex, ID = (byte)item.DeviceID, LoopEnumType = item.LoopEnumType, PhaseAngleEnumType = item.PhaseAngleEnumType, PhaseEnumType = item.PhaseEnumType, ElectricEnumType = item.ElectricEnumType
                        };
                        AbsProtocols.Add(protocol);
                    }
                    break;

                    case ElectricEnumType.CPM6:
                    {
                        CPM6Protocol protocol = new CPM6Protocol()
                        {
                            GatewayIndex = item.GatewayIndex, DeviceIndex = item.DeviceIndex, ID = (byte)item.DeviceID, LoopEnumType = item.LoopEnumType, PhaseAngleEnumType = item.PhaseAngleEnumType, PhaseEnumType = item.PhaseEnumType, ElectricEnumType = item.ElectricEnumType
                        };
                        AbsProtocols.Add(protocol);
                    }
                    break;

                    case ElectricEnumType.PA60:
                    {
                        PA60Protocol protocol = new PA60Protocol()
                        {
                            GatewayIndex = item.GatewayIndex, DeviceIndex = item.DeviceIndex, ID = (byte)item.DeviceID, LoopEnumType = item.LoopEnumType, PhaseAngleEnumType = item.PhaseAngleEnumType, PhaseEnumType = item.PhaseEnumType, ElectricEnumType = item.ElectricEnumType
                        };
                        AbsProtocols.Add(protocol);
                    }
                    break;

                    case ElectricEnumType.ABBM2M:
                    {
                        ABBM2MProtocol protocol = new ABBM2MProtocol()
                        {
                            GatewayIndex = item.GatewayIndex, DeviceIndex = item.DeviceIndex, ID = (byte)item.DeviceID, LoopEnumType = item.LoopEnumType, PhaseAngleEnumType = item.PhaseAngleEnumType, PhaseEnumType = item.PhaseEnumType, ElectricEnumType = item.ElectricEnumType
                        };
                        AbsProtocols.Add(protocol);
                    }
                    break;

                    case ElectricEnumType.PM200:
                    {
                        PM200Protocol protocol = new PM200Protocol()
                        {
                            GatewayIndex = item.GatewayIndex, DeviceIndex = item.DeviceIndex, ID = (byte)item.DeviceID, LoopEnumType = item.LoopEnumType, PhaseAngleEnumType = item.PhaseAngleEnumType, PhaseEnumType = item.PhaseEnumType, ElectricEnumType = item.ElectricEnumType
                        };
                        AbsProtocols.Add(protocol);
                    }
                    break;

                    case ElectricEnumType.TWCPM4:
                    {
                        TWCPM4Protocol protocol = new TWCPM4Protocol()
                        {
                            GatewayIndex = item.GatewayIndex, DeviceIndex = item.DeviceIndex, ID = (byte)item.DeviceID, LoopEnumType = item.LoopEnumType, PhaseAngleEnumType = item.PhaseAngleEnumType, PhaseEnumType = item.PhaseEnumType, ElectricEnumType = item.ElectricEnumType
                        };
                        AbsProtocols.Add(protocol);
                    }
                    break;
                    }
                }
                ReadThread = new Thread(Analysis);
                ReadThread.Start();
            }
            else
            {
                if (ReadThread != null)
                {
                    ReadThread.Abort();
                }
            }
        }