예제 #1
0
        /// <summary>
        /// 获取默认的PQ指令
        /// </summary>
        /// <param name="machine"></param>
        /// <param name="mode"></param>
        /// <returns></returns>
        public static string GetSnCode(AllMachine.Machines machine, AllMachine.Modes mode)
        {
            byte[] buff = new byte[10];

            switch (machine)
            {
            case AllMachine.Machines.商用V4:
                buff    = new byte[10];
                buff[0] = 0xAA;
                buff[1] = 0x01;    //内机序号
                buff[2] = 0x00;    //模式
                buff[3] = 0x3C;    //能级需求
                buff[4] = 0x25;
                buff[5] = 0x01;
                buff[6] = 0x00;
                buff[7] = 0x00;
                buff[8] = 0x00;    //校验
                buff[9] = 0x55;
                switch (mode)
                {
                case AllMachine.Modes.待机:
                    buff[2] = 0x00;
                    buff[4] = 0x19;
                    break;

                case AllMachine.Modes.制冷:
                    buff[2] = 0x02;
                    buff[4] = 0x11;
                    break;

                case AllMachine.Modes.制热:
                    buff[2] = 0x03;
                    buff[4] = 0x1E;
                    break;
                }
                AllMachine.GetCheck(AllMachine.Machines.商用V4, buff, out buff[8]);
                break;

            case AllMachine.Machines.商用V6:
            case AllMachine.Machines.商用定变组合:
                buff    = new byte[10];
                buff[0] = 0xAA;
                buff[1] = 0x01;    //内机序号
                buff[2] = 0x00;    //模式
                buff[3] = 0x00;    //能级需求
                buff[4] = 0x00;
                buff[5] = 0x00;
                buff[6] = 0x00;
                buff[7] = 0x00;
                buff[8] = 0xFF;    //校验
                buff[9] = 0x55;
                break;

            case AllMachine.Machines.商用两管制:
            case AllMachine.Machines.商用三管制:
                buff     = new byte[32];
                buff[0]  = 0xAA;
                buff[1]  = 0xC0;
                buff[2]  = 0x80;
                buff[3]  = 0x00;
                buff[4]  = 0x00;
                buff[5]  = 0x00;
                buff[6]  = 0xE0;
                buff[7]  = 0x14;
                buff[8]  = 0x88;
                buff[9]  = 0x01;
                buff[10] = 0x15;
                buff[11] = 0x5A;
                buff[12] = 0x5A;
                buff[13] = 0x48;
                buff[14] = 0xFF;
                buff[15] = 0xFF;
                buff[16] = 0xFF;
                buff[17] = 0x00;
                buff[18] = 0x00;
                buff[19] = 0x01;
                buff[20] = 0x04;
                buff[21] = 0x04;
                buff[22] = 0x00;
                buff[23] = 0x00;
                buff[24] = 0x00;
                buff[25] = 0x00;
                buff[26] = 0x00;
                buff[27] = 0x0A;
                buff[28] = 0x1E;
                buff[29] = 0xF2;
                AllMachine.GetCheck(machine, buff, out buff[30]);
                buff[31] = 0x55;
                break;
            }
            return(All.Class.Num.Hex2Str(buff));
        }
예제 #2
0
        /// <summary>
        /// 实际使用中,自动修正发送指令
        /// </summary>
        /// <param name="FE"></param>
        /// <param name="InDoorIndex"></param>
        /// <param name="OutDoorIndex"></param>
        /// <returns></returns>
        private byte[] ChangeSnCode(bool FE, byte InDoorIndex, byte OutDoorIndex)
        {
            byte[] buff   = All.Class.Num.Str2Hex(this.SnCode);
            byte[] result = new byte[0];
            int    index  = 0;

            switch (Machine)
            {
            case AllMachine.Machines.商用V4:
                if (OutDoorIndex == 3)
                {
                    buff[6] = 0xFA;
                }
                else
                {
                    buff[6] = 0x00;
                }
                buff[1] = InDoorIndex;

                AllMachine.GetCheck(Machine, buff, out buff[8]);
                result = new byte[10];
                if (FE)
                {
                    result          = new byte[12];
                    result[index++] = 0xFE;
                }
                for (int i = 0; i < buff.Length && i < result.Length; i++)
                {
                    result[index++] = buff[i];
                }
                if (FE)
                {
                    result[index++] = 0xFE;
                }
                break;

            case AllMachine.Machines.商用V6:
            case AllMachine.Machines.商用定变组合:
                result = new byte[10];
                if (FE)
                {
                    result          = new byte[12];
                    result[index++] = 0xFE;
                }
                for (int i = 0; i < buff.Length && i < result.Length; i++)
                {
                    result[index++] = buff[i];
                }
                if (FE)
                {
                    result[index++] = 0xFE;
                }
                break;

            case AllMachine.Machines.商用两管制:
            case AllMachine.Machines.商用三管制:
                buff[4] = InDoorIndex;
                AllMachine.GetCheck(Machine, buff, out buff[30]);
                result = new byte[32];
                if (FE)
                {
                    result          = new byte[34];
                    result[index++] = 0xFE;
                }
                for (int i = 0; i < buff.Length && i < result.Length; i++)
                {
                    result[index++] = buff[i];
                }
                if (FE)
                {
                    result[index++] = 0xFE;
                }
                break;
            }
            return(result);
        }