Beispiel #1
0
        /// <summary>
        /// 处理接收到的获取时间数据
        /// </summary>
        /// <param name="dataPack"></param>
        void processorData_GetTime(PowerDataPack_Receive_GetTime dataPack)
        {
            string vMAC = NetHelper.BytesToString_MAC(new byte[] { dataPack.MAC1, dataPack.MAC2, dataPack.MAC3, dataPack.MAC4,
                                                                   dataPack.MAC5, dataPack.MAC6 });
            PowerTimeConfigEFModel vPowerTimeConfigEFModel = new PowerTimeConfigEFModel()
            {
                Time = BitConverter.ToInt32(new byte[] { dataPack.Time4, dataPack.Time3, dataPack.Time2, dataPack.Time1 }, 0)
            };
            bool vResult = m_BasicDBClass_Receive.UpdateRecord(vPowerTimeConfigEFModel, string.Format("DianYuanID='{0}'", vMAC));

            if (!vResult)
            {
                vPowerTimeConfigEFModel.DianYuanID = vMAC;
                vResult = m_BasicDBClass_Receive.InsertRecord(vPowerTimeConfigEFModel) > 0 ? true : false;
            }

            PowerSendCMDEFModel vPowerSendCMDEFModel = new PowerSendCMDEFModel()
            {
                IsReply = true
            };

            if (vResult)
            {
                vPowerSendCMDEFModel.State = true;
            }
            string vSql = string.Format("DianYuanID='{0}' and CMD={1:D} and SN={2}", vMAC, (byte)PowerDataPack_Send_CommandEnum.GetTime, dataPack.SN);

            m_BasicDBClass_Receive.UpdateRecord(vPowerSendCMDEFModel, vSql);
        }
Beispiel #2
0
        /// <summary>
        /// 处理收到的数据包(IP地址设置)
        /// </summary>
        /// <param name="dataPack"></param>
        void processorData_GetIPAddress(PowerDataPack_Receive_GetIPAddress dataPack)
        {
            string vMAC = NetHelper.BytesToString_MAC(new byte[] { dataPack.MAC_1, dataPack.MAC_2, dataPack.MAC_3, dataPack.MAC_4,
                                                                   dataPack.MAC_5, dataPack.MAC_6 });
            PowerNetConfigEFModel vPowerNetConfigEFModel = new PowerNetConfigEFModel()
            {
                MAC             = vMAC,
                DHCP            = dataPack.DHCP == 0x01 ? true : false,
                Gateway         = NetHelper.BytesToString_IP(new byte[] { dataPack.gateway1, dataPack.gateway2, dataPack.gateway3, dataPack.gateway4 }),
                IPAddress       = NetHelper.BytesToString_IP(new byte[] { dataPack.IPAddress1, dataPack.IPAddress2, dataPack.IPAddress3, dataPack.IPAddress4 }),
                ServerIPAddress = NetHelper.BytesToString_IP(new byte[] { dataPack.ServerIPAddress1, dataPack.ServerIPAddress2, dataPack.ServerIPAddress3, dataPack.ServerIPAddress4 }),
                SubMask         = NetHelper.BytesToString_IP(new byte[] { dataPack.SubnetMask1, dataPack.SubnetMask2, dataPack.SubnetMask3, dataPack.SubnetMask4 }),
                Port            = BitConverter.ToInt16(new byte[] { dataPack.Port2, dataPack.Port1 }, 0),
                ServerPort      = BitConverter.ToInt16(new byte[] { dataPack.ServerPort2, dataPack.ServerPort1 }, 0)
            };

            try
            {
                m_BasicDBClass_Receive.TransactionBegin();
                m_BasicDBClass_Receive.DeleteRecordCustom <PowerNetConfigEFModel>(string.Format("MAC='{0}'", vMAC));
                m_BasicDBClass_Receive.InsertRecord(vPowerNetConfigEFModel);
                PowerSendCMDEFModel vPowerSendCMDEFModel = new PowerSendCMDEFModel()
                {
                    IsReply = true,
                    State   = true
                };
                string vSql = string.Format("DianYuanID='{0}' and CMD={1:D} and SN={2}", vMAC, (byte)PowerDataPack_Send_CommandEnum.Send_GetIPAddress, dataPack.SN);
                m_BasicDBClass_Receive.UpdateRecord(vPowerSendCMDEFModel, vSql);
                m_BasicDBClass_Receive.TransactionCommit();
            }
            catch (Exception ex)
            {
                string vOutInfo = string.Format("电源获取电源IP地址错误:{0}", ex.Message);
                Console.WriteLine(vOutInfo);
                LogHelper.WriteLog_Debug(typeof(PowerControl), vOutInfo);
                m_BasicDBClass_Receive.TransactionRollback();
            }
        }
Beispiel #3
0
        /// <summary>
        /// 处理收到的开关参数设置(IP地址设置)
        /// </summary>
        /// <param name="dataPack"></param>
        void processorData_GetSwitchParam(PowerDataPack_Receive_GetSwitchParam dataPack)
        {
            string vMAC = NetHelper.BytesToString_MAC(new byte[] { dataPack.MAC1, dataPack.MAC2, dataPack.MAC3, dataPack.MAC4,
                                                                   dataPack.MAC5, dataPack.MAC6 });
            PowerSwithConfigEFModel vPowerSwithConfigEFModel = new PowerSwithConfigEFModel()
            {
                XianDingDN  = BitConverter.ToInt16(new byte[] { dataPack.XianDingDN2, dataPack.XianDingDN1 }, 0),
                XianDingGL  = BitConverter.ToInt16(new byte[] { dataPack.XianDingGL2, dataPack.XianDingGL1 }, 0),
                DianLiuLLZ  = BitConverter.ToInt16(new byte[] { dataPack.DianLiuRLZ2, dataPack.DianLiuRLZ1 }, 0),
                ChaoWenBHZ  = BitConverter.ToUInt16(new byte[] { dataPack.ChaoWenBHZ2, dataPack.ChaoWenBHZ1 }, 0),
                ChaoWenYJZ  = BitConverter.ToUInt16(new byte[] { dataPack.ChaoWenYJZ2, dataPack.ChaoWenYJZ1 }, 0),
                GuoYaSX     = BitConverter.ToInt16(new byte[] { dataPack.GuoYaSX2, dataPack.GuoYaSX1 }, 0),
                QianYaXX    = BitConverter.ToInt16(new byte[] { dataPack.QianYaXX2, dataPack.QianYaXX1 }, 0),
                EDingLDDZDL = BitConverter.ToInt16(new byte[] { dataPack.EDingLDDZDL2, dataPack.EDingLDDZDL1 }, 0),
                LouDianLYJZ = BitConverter.ToInt16(new byte[] { dataPack.LouDianLYJZ2, dataPack.LouDianLYJZ1 }, 0)
            };
            bool vResult = m_BasicDBClass_Receive.UpdateRecord(vPowerSwithConfigEFModel, string.Format("DianYuanID='{0}' and LuHao={1:D}", vMAC, dataPack.LuHao));

            if (!vResult)
            {
                vPowerSwithConfigEFModel.DianYuanID = vMAC;
                vResult = m_BasicDBClass_Receive.InsertRecord(vPowerSwithConfigEFModel) > 0 ? true : false;
            }

            PowerSendCMDEFModel vPowerSendCMDEFModel = new PowerSendCMDEFModel()
            {
                IsReply = true
            };

            if (vResult)
            {
                vPowerSendCMDEFModel.State = true;
            }
            string vSql = string.Format("DianYuanID='{0}' and CMD={1:D} and SN={2}", vMAC, (byte)PowerDataPack_Send_CommandEnum.GetSwitchParam, dataPack.SN);

            m_BasicDBClass_Receive.UpdateRecord(vPowerSendCMDEFModel, vSql);
        }
Beispiel #4
0
        void processorData_GetControlInfo(PowerDataPack_Receive_GetControlInfo dataPack)
        {
            string vMAC = NetHelper.BytesToString_MAC(new byte[] { dataPack.MAC1, dataPack.MAC2, dataPack.MAC3, dataPack.MAC4,
                                                                   dataPack.MAC5, dataPack.MAC6 });

            vMAC = vMAC.ToUpper();
            m_BasicDBClass_Receive.DeleteRecordCustom <PowerSwithConfigEFModel>(string.Format("DianYuanID='{0}'", vMAC));

            //漏保设备
            int vLouBaoSBLS = BitConverter.ToInt32(new byte[] { dataPack.LouBaoSBLS, 0x00, 0x00, 0x00 }, 0);

            for (int i = 1; i <= vLouBaoSBLS; i++)
            {
                PowerSwithConfigEFModel vPowerSwithConfigEFModel = new PowerSwithConfigEFModel()
                {
                    DianYuanID = vMAC,
                    LuHao      = i,
                    MinCheng   = string.Format("漏保{0}", i),
                    LeiXing    = "漏保"
                };
                m_BasicDBClass_Receive.InsertRecord(vPowerSwithConfigEFModel);
            }
            //分路路数
            int vFenLuLS = BitConverter.ToInt32(new byte[] { dataPack.FenLuLS, 0x00, 0x00, 0x00 }, 0);

            for (int i = 1; i <= vFenLuLS; i++)
            {
                PowerSwithConfigEFModel vPowerSwithConfigEFModel = new PowerSwithConfigEFModel()
                {
                    DianYuanID = vMAC,
                    LuHao      = i,
                    MinCheng   = string.Format("分路{0}", i),
                    LeiXing    = "分路"
                };
                m_BasicDBClass_Receive.InsertRecord(vPowerSwithConfigEFModel);
            }
            //漏保分路路数
            int vLouBaoFLLS = BitConverter.ToInt32(new byte[] { dataPack.LouBaoSBLS, 0x00, 0x00, 0x00 }, 0);

            for (int i = 1; i <= vLouBaoFLLS; i++)
            {
                PowerSwithConfigEFModel vPowerSwithConfigEFModel = new PowerSwithConfigEFModel()
                {
                    DianYuanID = vMAC,
                    LuHao      = i,
                    MinCheng   = string.Format("分路{0}(带漏保)", i),
                    LeiXing    = "分路(带漏保)"
                };
                m_BasicDBClass_Receive.InsertRecord(vPowerSwithConfigEFModel);
            }
            //漏保插座路数
            int vLouBaoCZLS = BitConverter.ToInt32(new byte[] { dataPack.LouBaoCZLS, 0x00, 0x00, 0x00 }, 0);

            for (int i = 1; i <= vLouBaoCZLS; i++)
            {
                PowerSwithConfigEFModel vPowerSwithConfigEFModel = new PowerSwithConfigEFModel()
                {
                    DianYuanID = vMAC,
                    LuHao      = i,
                    MinCheng   = string.Format("漏保插座{0}", i),
                    LeiXing    = "漏保插座"
                };
                m_BasicDBClass_Receive.InsertRecord(vPowerSwithConfigEFModel);
            }
            //插座路数
            int vChaZhuoLS = BitConverter.ToInt32(new byte[] { dataPack.ChaZhuoLS, 0x00, 0x00, 0x00 }, 0);

            for (int i = 1; i <= vChaZhuoLS; i++)
            {
                PowerSwithConfigEFModel vPowerSwithConfigEFModel = new PowerSwithConfigEFModel()
                {
                    DianYuanID = vMAC,
                    LuHao      = i,
                    MinCheng   = string.Format("普插座{0}", i),
                    LeiXing    = "普插座"
                };
                m_BasicDBClass_Receive.InsertRecord(vPowerSwithConfigEFModel);
            }

            PowerSendCMDEFModel vPowerSendCMDEFModel = new PowerSendCMDEFModel()
            {
                IsReply = true
            };

            vPowerSendCMDEFModel.State = true;
            string vSql = string.Format("DianYuanID='{0}' and CMD={1:D} and SN={2}", vMAC, (byte)PowerDataPack_Send_CommandEnum.GetControlInfo, dataPack.SN);

            m_BasicDBClass_Receive.UpdateRecord(vPowerSendCMDEFModel, vSql);
        }