Example #1
0
        public static byte[] CmdAskStartCounting(uint commandNumber, double Ts_double, double tz_double, double tq_double, decimal cth_double, double Vq_double, int cmd_length = 13)
        {
            //===================================
            //
            /*Prašymas pradėti skaičiavimą*/
            /*Esc s nr Ts Tz Tq(2 baitai) Cth Vq CRC32*/
            byte esc = 0x1b; //Esc
            byte s   = 0x73; //s(tart)
            byte nr  = (byte)commandNumber;
            byte Ts  = ExternalFunctions.getTs(Ts_double);
            byte Tz  = ExternalFunctions.getTz(tz_double);

            byte[] Tq  = ExternalFunctions.getTq(tq_double);
            byte   Cth = ExternalFunctions.returnCthVoltage(cth_double);
            byte   Vq  = ExternalFunctions.getVq(Vq_double);

            byte[] cmd = new byte[9];
            cmd[0] = esc;
            cmd[1] = s;
            cmd[2] = nr;
            cmd[3] = Ts;
            cmd[4] = Tz;
            cmd[5] = Tq[0];
            cmd[6] = Tq[1];
            cmd[7] = Cth;
            cmd[8] = Vq;
            Crc32 crc = new Crc32();

            byte[] crc_code = crc.ComputeHash(cmd);
            byte[] cmd_ret  = new byte[cmd.Length + crc_code.Length];
            cmd.CopyTo(cmd_ret, 0);
            crc_code.CopyTo(cmd_ret, cmd.Length);
            return(cmd_ret);
        }