Exemplo n.º 1
0
 /// <summary>
 /// 获取NPDU
 /// </summary>
 /// <param name="data"></param>
 /// <returns></returns>
 public string GetNPDU(byte[] data)
 {
     length = Convert.ToInt32(data[0]);
     apci   = GlobalClass.BitToInt(GlobalClass.IntToBit(Convert.ToInt32(data[1]), 8).Substring(6, 2)
                                   + GlobalClass.IntToBit(Convert.ToInt32(data[2]), 8).Substring(0, 2));
     apciData  = GlobalClass.BitToInt(GlobalClass.IntToBit(Convert.ToInt32(data[2]), 8).Substring(2, 6));
     this.data = GlobalClass.ByteToHex(data, 3, length - 1);
     return(GlobalClass.ByteToHex(data));
 }
Exemplo n.º 2
0
        private void read()
        {
            if (cbHeat.SelectedIndex == -1)
            {
                cbHeat.SelectedIndex = 0;
            }
            Cursor.Current = Cursors.WaitCursor;
            try
            {
                byte[] arayTmp = new byte[1];
                arayTmp[0] = Convert.ToByte(cbHeat.SelectedIndex);
                if (CsConst.mySends.AddBufToSndList(arayTmp, 0x1972, SubNetID, DeviceID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(DeviceType)) == true)
                {
                    int    intTmp = CsConst.myRevBuf[57];
                    string strTmp = GlobalClass.IntToBit(intTmp, 8);
                    for (int i = 1; i <= 8; i++)
                    {
                        ComboBox cb = this.Controls.Find("cb" + i.ToString(), true)[0] as ComboBox;
                        if (CsConst.myRevBuf[25 + (i - 1) * 4] <= 1)
                        {
                            cb.SelectedIndex = CsConst.myRevBuf[25 + (i - 1) * 4];
                        }
                        NumericUpDown tmp1 = this.Controls.Find("NumSub" + i.ToString(), true)[0] as NumericUpDown;
                        tmp1.Value = Convert.ToDecimal(CsConst.myRevBuf[26 + (i - 1) * 4]);
                        NumericUpDown tmp2 = this.Controls.Find("NumDev" + i.ToString(), true)[0] as NumericUpDown;
                        tmp2.Value = Convert.ToDecimal(CsConst.myRevBuf[27 + (i - 1) * 4]);
                        NumericUpDown tmp3 = this.Controls.Find("NumChn" + i.ToString(), true)[0] as NumericUpDown;
                        tmp3.Value = Convert.ToDecimal(CsConst.myRevBuf[28 + (i - 1) * 4]);
                        CheckBox chb = this.Controls.Find("chb" + i.ToString(), true)[0] as CheckBox;
                        if (strTmp.Substring((8 - i), 1) == "0")
                        {
                            chb.Checked = true;
                        }
                        else
                        {
                            chb.Checked = false;
                        }
                    }

                    CsConst.myRevBuf = new byte[1200];
                }
            }
            catch
            { }
            Cursor.Current = Cursors.Default;
        }
Exemplo n.º 3
0
        /// <summary>
        /// 设置NPDU
        /// </summary>
        /// <returns></returns>
        public string SetNPDU()
        {
            string temp = "";

            temp += GlobalClass.AddLeftZero(length.ToString("X"), 2);
            string _tpci = GlobalClass.IntToBit(apci, 4);

            if (!isOneToOne)
            {
                temp += GlobalClass.AddLeftZero(GlobalClass.BitToInt(_tpci.Substring(0, 2)).ToString("X"), 2);
            }
            else
            {
                temp += GlobalClass.AddLeftZero(GlobalClass.BitToInt("01" + GlobalClass.IntToBit(sendTime, 4) + _tpci.Substring(0, 2)).ToString("X"), 2);
            }
            temp += GlobalClass.AddLeftZero(GlobalClass.BitToInt(_tpci.Substring(2, 2) + GlobalClass.IntToBit(apciData, 6)).ToString("X"), 2);
            temp += data;
            return(temp);
        }
Exemplo n.º 4
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            Cursor.Current            = Cursors.WaitCursor;
            CsConst.ChannelIDForNewIR = cbChannel.SelectedIndex;
            CsConst.KeyIDForNewIR     = cbKey.SelectedIndex;
            if (panel9.Visible)
            {
                CsConst.arayACParamForNewIR    = new byte[6];
                CsConst.arayACParamForNewIR[0] = Convert.ToByte(IRDevice);
                CsConst.arayACParamForNewIR[1] = Convert.ToByte(cbPower.SelectedIndex);
                CsConst.arayACParamForNewIR[2] = Convert.ToByte(cbMode.SelectedIndex);
                CsConst.arayACParamForNewIR[3] = Convert.ToByte(cbFan.SelectedIndex);
                CsConst.arayACParamForNewIR[4] = Convert.ToByte(sbTemp.Value);
                CsConst.arayACParamForNewIR[5] = Convert.ToByte(cbWind.SelectedIndex);
            }
            //DialogResult = DialogResult.OK;

            byte[] arayTmp = new byte[4];
            if (DeviceType == 729)
            {
                arayTmp = new byte[4];
                int    int1 = 0;
                int    int2 = CsConst.ChannelIDForNewIR + 1;
                string str1 = GlobalClass.IntToBit(int1, 2);
                string str2 = GlobalClass.IntToBit(int2, 6);
                string str  = str1 + str2;
                arayTmp[0] = 1;
                arayTmp[1] = Convert.ToByte(GlobalClass.BitToInt(str));
                arayTmp[2] = Convert.ToByte(IRDevice);
                arayTmp[3] = Convert.ToByte(CsConst.KeyIDForNewIR + 1);
                if (CsConst.mySends.AddBufToSndList(arayTmp, 0xdb90, SubNetID, DevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(DeviceType)) == true)
                {
                }
            }
            else if (DeviceType == 1301 || DeviceType == 1300 || DeviceType == 6100 || DeviceType == 908)
            {
                if (IRID == 5)
                {
                    arayTmp    = new byte[13];
                    arayTmp[0] = Convert.ToByte(IRDevice);
                    arayTmp[3] = Convert.ToByte(sbTemp.Value);
                    arayTmp[4] = Convert.ToByte(sbTemp.Value);
                    arayTmp[5] = Convert.ToByte(sbTemp.Value);
                    arayTmp[6] = Convert.ToByte(sbTemp.Value);
                    arayTmp[7] = Convert.ToByte(sbTemp.Value);
                    Array.Copy(CsConst.arayACParamForNewIR, 1, arayTmp, 8, 5);
                    if (CsConst.mySends.AddBufToSndList(arayTmp, 0x193A, SubNetID, DevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(DeviceType)) == true)
                    {
                    }
                }
                else
                {
                    arayTmp = new byte[4];
                    int    int1 = 0;
                    int    int2 = CsConst.ChannelIDForNewIR + 1;
                    string str1 = GlobalClass.IntToBit(int1, 2);
                    string str2 = GlobalClass.IntToBit(int2, 6);
                    string str  = str1 + str2;
                    arayTmp[0] = Convert.ToByte(GlobalClass.BitToInt(str));
                    arayTmp[1] = Convert.ToByte(IRDevice);
                    if (arayTmp[1] > 4)
                    {
                        arayTmp[1] = Convert.ToByte(arayTmp[1] - 4);
                    }
                    arayTmp[2] = Convert.ToByte(CsConst.KeyIDForNewIR + 1);
                    if (CsConst.mySends.AddBufToSndList(arayTmp, 0xdb90, SubNetID, DevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(DeviceType)) == true)
                    {
                    }
                }
            }
            else
            {
                arayTmp = new byte[4];
                int    int1 = 0;
                int    int2 = CsConst.ChannelIDForNewIR + 1;
                string str1 = GlobalClass.IntToBit(int1, 2);
                string str2 = GlobalClass.IntToBit(int2, 6);
                string str  = str1 + str2;
                arayTmp[0] = Convert.ToByte(GlobalClass.BitToInt(str));
                arayTmp[1] = Convert.ToByte(IRDevice);
                arayTmp[2] = Convert.ToByte(CsConst.KeyIDForNewIR + 1);
                if (CsConst.mySends.AddBufToSndList(arayTmp, 0xdb90, SubNetID, DevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(DeviceType)) == true)
                {
                }
            }
            Cursor.Current = Cursors.Default;
        }
Exemplo n.º 5
0
        public void DownloadFloorheatingsettingFromDevice(Byte SubNetID, Byte DeviceID, int DeviceType, ref Byte[] AcTemperatureRange)
        {
            Byte[] ArayTmp = new byte[0];

            // floor heating
            #region
            if (CsConst.mySends.AddBufToSndList(ArayTmp, 0x1940, SubNetID, DeviceID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(DeviceType)) == true)
            {
                #region
                if (CsConst.mintNewDLPFHSetupDeviceType.Contains(DeviceType) || NormalPanelDeviceTypeList.WirelessSimpleFloorHeatingDeviceTypeList.Contains(DeviceType)) //新版读取设置的功能
                {
                    HeatEnable   = CsConst.myRevBuf[25];
                    SourceTemp   = CsConst.myRevBuf[26];
                    OutDoorParam = new byte[20];
                    Array.Copy(CsConst.myRevBuf, 27, OutDoorParam, 0, 8);
                    SourceParam = new byte[20];
                    Array.Copy(CsConst.myRevBuf, 35, SourceParam, 0, 8);
                    PIDEnable  = CsConst.myRevBuf[43];
                    OutputType = CsConst.myRevBuf[44];
                    minPWM     = CsConst.myRevBuf[45];
                    maxPWM     = CsConst.myRevBuf[46];
                    Speed      = CsConst.myRevBuf[47];
                    Cycle      = CsConst.myRevBuf[48];
                    ModeAry    = new byte[] { 0, 0, 0, 0, 0 };
                    string strTmp = GlobalClass.IntToBit(Convert.ToInt32(CsConst.myRevBuf[49]), 8);
                    if (strTmp.Substring(7, 1) == "1")
                    {
                        ModeAry[0] = 1;
                    }
                    if (strTmp.Substring(6, 1) == "1")
                    {
                        ModeAry[1] = 1;
                    }
                    if (strTmp.Substring(5, 1) == "1")
                    {
                        ModeAry[2] = 1;
                    }
                    if (strTmp.Substring(4, 1) == "1")
                    {
                        ModeAry[3] = 1;
                    }
                    if (strTmp.Substring(3, 1) == "1")
                    {
                        ModeAry[4] = 1;
                    }
                    Switch  = CsConst.myRevBuf[50];
                    TimeAry = new byte[4];
                    Array.Copy(CsConst.myRevBuf, 51, TimeAry, 0, 4);
                    ProtectTemperature = CsConst.myRevBuf[55];
                    ControlMode        = CsConst.myRevBuf[57];
                    HeatType           = CsConst.myRevBuf[58];
                    SysEnable          = new byte[4];
                    if (CsConst.myRevBuf[59] == 1)
                    {
                        SysEnable[0] = 1;
                    }
                    strTmp = GlobalClass.IntToBit(Convert.ToInt32(CsConst.myRevBuf[60]), 8);
                    if (strTmp.Substring(7, 1) == "1")
                    {
                        SysEnable[1] = 1;
                    }
                    if (strTmp.Substring(6, 1) == "1")
                    {
                        SysEnable[2] = 1;
                    }
                    if (strTmp.Substring(5, 1) == "1")
                    {
                        SysEnable[3] = 1;
                    }
                    CompenValue      = CsConst.myRevBuf[61];
                    CsConst.myRevBuf = new byte[1200];

                    CalculationModeTargets = new byte[40];
                    if (CsConst.mySends.AddBufToSndList(null, 0x1972, SubNetID, DeviceID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(DeviceType)) == true) //新版把目标独立出来
                    {
                        Array.Copy(CsConst.myRevBuf, 25, CalculationModeTargets, 0, 33);
                        CsConst.myRevBuf = new byte[1200];
                        //从机读取目标
                        RelayCommandGroup = new byte[33];
                        if (CsConst.mySends.AddBufToSndList(null, 0x1976, SubNetID, DeviceID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(DeviceType)) == true) //新版把目标独立出来
                        {
                            Array.Copy(CsConst.myRevBuf, 25, RelayCommandGroup, 0, 33);
                        }
                        else
                        {
                            return;
                        }
                        CsConst.myRevBuf = new byte[1200];
                        HDLUDP.TimeBetwnNext(10);
                    }
                    else
                    {
                        return;
                    }
                }
                else
                {
                    HeatEnable        = CsConst.myRevBuf[25];
                    RelayCommandGroup = new byte[33];
                    Array.Copy(CsConst.myRevBuf, 26, RelayCommandGroup, 0, 16);
                    SourceTemp   = CsConst.myRevBuf[42];
                    OutDoorParam = new byte[20];
                    Array.Copy(CsConst.myRevBuf, 43, OutDoorParam, 0, 8);
                    SourceParam = new byte[20];
                    Array.Copy(CsConst.myRevBuf, 51, SourceParam, 0, 8);
                    PIDEnable        = CsConst.myRevBuf[59];
                    CsConst.myRevBuf = new byte[1200];
                    HDLUDP.TimeBetwnNext(10);
                }

                if (CsConst.mySends.AddBufToSndList(ArayTmp, 0x1900, SubNetID, DeviceID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(DeviceType)) == true)  // read temperature range
                {
                    if (AcTemperatureRange == null)
                    {
                        AcTemperatureRange = new Byte[9];
                    }
                    Array.Copy(CsConst.myRevBuf, 25, AcTemperatureRange, 0, 9);

                    minTemp          = CsConst.myRevBuf[34];
                    maxTemp          = CsConst.myRevBuf[35];
                    CsConst.myRevBuf = new byte[1200];
                    HDLUDP.TimeBetwnNext(10);
                }
                else
                {
                    return;
                }

                ReadFloorheatingAdvancedCommandsGroup(SubNetID, DeviceID, DeviceType);
                #endregion
            }
            else
            {
                return;
            }
            #endregion
        }
Exemplo n.º 6
0
        public Boolean DownloadFloorheatingsettingFromDevice(Byte SubNetID, Byte DeviceID, int DeviceType)
        {
            Byte[] ArayTmp = new byte[1] {
                (Byte)ID
            };
            try
            {
                // floor heating
                #region
                if (CsConst.mySends.AddBufToSndList(ArayTmp, 0x1940, SubNetID, DeviceID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(DeviceType)) == true)
                {
                    AdvancedCommands = new UVCMD.ControlTargets[8];
                    HeatEnable       = CsConst.myRevBuf[25];
                    SourceTemp       = CsConst.myRevBuf[26];
                    OutDoorParam     = new byte[20];
                    Array.Copy(CsConst.myRevBuf, 27, OutDoorParam, 0, 8);
                    SourceParam = new byte[20];
                    Array.Copy(CsConst.myRevBuf, 35, SourceParam, 0, 8);
                    PIDEnable  = CsConst.myRevBuf[43];
                    OutputType = CsConst.myRevBuf[44];
                    minPWM     = CsConst.myRevBuf[45];
                    maxPWM     = CsConst.myRevBuf[46];
                    Speed      = CsConst.myRevBuf[47];
                    Cycle      = CsConst.myRevBuf[48];
                    ModeAry    = new byte[] { 0, 0, 0, 0, 0 };
                    string strTmp = GlobalClass.IntToBit(Convert.ToInt32(CsConst.myRevBuf[49]), 8);
                    if (strTmp.Substring(7, 1) == "1")
                    {
                        ModeAry[0] = 1;
                    }
                    if (strTmp.Substring(6, 1) == "1")
                    {
                        ModeAry[1] = 1;
                    }
                    if (strTmp.Substring(5, 1) == "1")
                    {
                        ModeAry[2] = 1;
                    }
                    if (strTmp.Substring(4, 1) == "1")
                    {
                        ModeAry[3] = 1;
                    }
                    if (strTmp.Substring(3, 1) == "1")
                    {
                        ModeAry[4] = 1;
                    }
                    Switch  = CsConst.myRevBuf[50];
                    TimeAry = new byte[4];
                    Array.Copy(CsConst.myRevBuf, 51, TimeAry, 0, 4);
                    ProtectTemperature = CsConst.myRevBuf[55];
                    ControlMode        = CsConst.myRevBuf[57];
                    HeatType           = CsConst.myRevBuf[58];
                    SysEnable          = new byte[4];
                    if (CsConst.myRevBuf[59] == 1)
                    {
                        SysEnable[0] = 1;
                    }
                    strTmp = GlobalClass.IntToBit(Convert.ToInt32(CsConst.myRevBuf[60]), 8);
                    if (strTmp.Substring(7, 1) == "1")
                    {
                        SysEnable[1] = 1;
                    }
                    if (strTmp.Substring(6, 1) == "1")
                    {
                        SysEnable[2] = 1;
                    }
                    if (strTmp.Substring(5, 1) == "1")
                    {
                        SysEnable[3] = 1;
                    }
                    CompenValue      = CsConst.myRevBuf[61];
                    DesSubnetID      = CsConst.myRevBuf[62];
                    DesDeviceID      = CsConst.myRevBuf[63];
                    Channel          = CsConst.myRevBuf[64];
                    minTemp          = CsConst.myRevBuf[65];
                    maxTemp          = CsConst.myRevBuf[66];
                    CsConst.myRevBuf = new byte[1200];
                }
                else
                {
                    return(false);
                }


                CalculationModeTargets = new byte[40];
                if (CsConst.isRestore)
                {
                    ReadSalveChannelWhenSlaveMode(SubNetID, DeviceID, DeviceType);
                }
                #endregion
            }
            catch {
                return(false);
            }
            return(true);
        }
Exemplo n.º 7
0
 private void btnRefAC_Click(object sender, EventArgs e)
 {
     try
     {
         Cursor.Current = Cursors.WaitCursor;
         if (cbACNO.SelectedIndex < 0)
         {
             cbACNO.SelectedIndex = 0;
         }
         byte[] arayTmp = new byte[1];
         arayTmp[0] = Convert.ToByte(cbACNO.SelectedIndex + 1);
         if (CsConst.mySends.AddBufToSndList(arayTmp, 0x1938, SubNetID, DevID, false, true, true, CsConst.minAllWirelessDeviceType.Contains(MyintDeviceType)) == true)
         {
             if (CsConst.myRevBuf[26] == 0)
             {
                 sbCoolTemp.Minimum = 0;
                 sbHeatTemp.Minimum = 0;
                 sbAutoTemp.Minimum = 0;
                 sbDryTemp.Minimum  = 0;
                 sbCoolTemp.Maximum = 30;
                 sbHeatTemp.Maximum = 30;
                 sbAutoTemp.Maximum = 30;
                 sbDryTemp.Maximum  = 30;
                 strTest            = "C";
             }
             else if (CsConst.myRevBuf[26] == 1)
             {
                 sbCoolTemp.Minimum = 32;
                 sbHeatTemp.Minimum = 32;
                 sbAutoTemp.Minimum = 32;
                 sbDryTemp.Minimum  = 32;
                 sbCoolTemp.Maximum = 86;
                 sbHeatTemp.Maximum = 86;
                 sbAutoTemp.Maximum = 86;
                 sbDryTemp.Maximum  = 86;
                 strTest            = "F";
             }
             lbCurTempValue.Text = CsConst.myRevBuf[27].ToString() + strTest;
             sbCoolTemp.Value    = CsConst.myRevBuf[28];
             sbHeatTemp.Value    = CsConst.myRevBuf[29];
             sbAutoTemp.Value    = CsConst.myRevBuf[30];
             sbDryTemp.Value     = CsConst.myRevBuf[31];
             string strRunnig = "";
             string strTmp    = GlobalClass.IntToBit(Convert.ToInt32(CsConst.myRevBuf[32]), 8);
             string str1      = strTmp.Substring(0, 4);
             string str2      = strTmp.Substring(4, 4);
             int    intTmp    = GlobalClass.BitToInt(str1);
             if (intTmp == 0)
             {
                 strRunnig = CsConst.mstrINIDefault.IniReadValue("Public", "00050", "");
             }
             else if (intTmp == 1)
             {
                 strRunnig = CsConst.mstrINIDefault.IniReadValue("Public", "00051", "");
             }
             else if (intTmp == 2)
             {
                 strRunnig = CsConst.mstrINIDefault.IniReadValue("Public", "00052", "");
             }
             else if (intTmp == 3)
             {
                 strRunnig = CsConst.mstrINIDefault.IniReadValue("Public", "00053", "");
             }
             else if (intTmp == 4)
             {
                 strRunnig = CsConst.mstrINIDefault.IniReadValue("Public", "00054", "");
             }
             intTmp = GlobalClass.BitToInt(str2);
             if (intTmp == 0)
             {
                 strRunnig = strRunnig + "," + CsConst.mstrINIDefault.IniReadValue("Public", "00060", "");
             }
             else if (intTmp == 1)
             {
                 strRunnig = strRunnig + "," + CsConst.mstrINIDefault.IniReadValue("Public", "00061", "");
             }
             else if (intTmp == 2)
             {
                 strRunnig = strRunnig + "," + CsConst.mstrINIDefault.IniReadValue("Public", "00062", "");
             }
             else if (intTmp == 3)
             {
                 strRunnig = strRunnig + "," + CsConst.mstrINIDefault.IniReadValue("Public", "00063", "");
             }
             lbRunningValue.Text      = strRunnig;
             cbACPower.SelectedIndex  = CsConst.myRevBuf[33];
             cbMode.SelectedIndex     = CsConst.myRevBuf[34];
             cbFanSpeed.SelectedIndex = CsConst.myRevBuf[35];
         }
     }
     catch
     {
     }
     Cursor.Current = Cursors.Default;
 }