示例#1
0
            static public IpPacket GetCommand_SetExpositions(int common_time,
                                                             int[] exps, int ver)
            {
                IpPacket p = new IpPacket();

                int  len;
                byte comm;

                if (ver == 4)
                {
                    len  = 16;
                    comm = 2;
                }
                else
                {
                    if (ver == 2)
                    {
                        len  = 8;
                        comm = 1;
                    }
                    else
                    {
                        throw new Exception("Exposition error: unsuported version of the device: " + ver);
                    }
                }
                p.ExtraCommand    = new byte[2 + 4 + 4 * len];
                p.ExtraCommand[0] = comm;
                p.ExtraCommand[1] = 0;
                int[] tmp = new int[exps.Length + 1];
                tmp[0] = common_time;
                for (int i = 0; i < exps.Length; i++)
                {
                    tmp[1 + i] = exps[i];
                }
                for (int i = 0; i < tmp.Length; i++)
                {
                    p.ExtraCommand[2 + i * 4] = (byte)tmp[i];
                    p.ExtraCommand[3 + i * 4] = (byte)(tmp[i] >> 8);
                    p.ExtraCommand[4 + i * 4] = (byte)(tmp[i] >> 16);
                    p.ExtraCommand[5 + i * 4] = (byte)(tmp[i] >> 24);
                }

                p.InitSize();

                p.CycleNum        = CycleNumLast++;
                p.CycleCommandNum = CycleCommandLast++;
                p.DSN             = 15;
                p.PaketType       = 1;
                p.Command1        = 4;
                p.Command2        = 1;
                p.ReplyCommand1   = 254;
                p.ReplyCommand2   = 2;
                return(p);
            }
示例#2
0
            static public IpPacket GetCommand_ReSendLastData()
            {
                IpPacket p = new IpPacket();

                p.InitSize();

                p.CycleNum        = CycleNumLast++;
                p.CycleCommandNum = CycleCommandLast++;
                p.DSN             = 15;
                p.PaketType       = 1;
                p.Command1        = 6;
                p.Command2        = 1;
                p.ReplyCommand1   = 251;
                p.ReplyCommand2   = 1;
                return(p);
            }
示例#3
0
            static public IpPacket GetCommand_StartMeasuring()
            {
                IpPacket p = new IpPacket();

                p.InitSize();

                p.CycleNum        = CycleNumLast++;
                p.CycleCommandNum = CycleCommandLast++;
                p.DSN             = 15;
                p.PaketType       = 1;
                p.Command1        = 5;
                p.Command2        = 1;
                p.ReplyCommand1   = 254;
                p.ReplyCommand2   = 3;
                return(p);
            }
示例#4
0
            static public IpPacket GetCommand_CheckOnline()
            {
                IpPacket p = new IpPacket();

                p.InitSize();

                p.CycleNum        = CycleNumLast++;
                p.CycleCommandNum = CycleCommandLast++;
                p.DSN             = 15;
                p.PaketType       = 1;
                p.Command1        = 1;
                p.Command2        = 4;
                p.ReplyCommand1   = 254;
                p.ReplyCommand2   = 2;
                return(p);
            }
示例#5
0
            static public IpPacket GetCommand_GetDivider()
            {
                IpPacket p = new IpPacket();

                p.InitSize();

                p.CycleNum        = CycleNumLast++;
                p.CycleCommandNum = CycleCommandLast++;
                p.DSN             = 15;
                p.PaketType       = 1;
                p.Command1        = 3;
                p.Command2        = 2;

                p.ReplyCommand1 = 253;
                p.ReplyCommand2 = 2;
                return(p);
            }
示例#6
0
            static public IpPacket GetCommand_SetGenByte(byte data)
            {
                IpPacket p = new IpPacket();

                p.ExtraCommand    = new byte[1];
                p.ExtraCommand[0] = data;

                p.InitSize();

                p.CycleNum        = CycleNumLast++;
                p.CycleCommandNum = CycleCommandLast++;
                p.DSN             = 15;
                p.PaketType       = 1;
                p.Command1        = 108;
                p.Command2        = 10;

                p.ReplyCommand1 = 254;
                p.ReplyCommand2 = 2;
                return(p);
            }
示例#7
0
            static public IpPacket GetCommand_SetDivider(byte val)
            {
                IpPacket p = new IpPacket();

                p.ExtraCommand    = new byte[4];
                p.ExtraCommand[0] = 1;
                p.ExtraCommand[1] = 0;
                p.ExtraCommand[2] = val;
                p.ExtraCommand[3] = (byte)(val >> 8);

                p.InitSize();

                p.CycleNum        = CycleNumLast++;
                p.CycleCommandNum = CycleCommandLast++;
                p.DSN             = 15;
                p.PaketType       = 1;
                p.Command1        = 3;
                p.Command2        = 3;

                p.ReplyCommand1 = 254;
                p.ReplyCommand2 = 2;
                return(p);
            }
示例#8
0
            static public IpPacket GetCommand_SetGenStatus(bool status)
            {
                IpPacket p = new IpPacket();

                p.InitSize();

                p.CycleNum        = CycleNumLast++;
                p.CycleCommandNum = CycleCommandLast++;
                p.DSN             = 15;
                p.PaketType       = 1;
                p.Command1        = 108;
                if (status)
                {
                    p.Command2 = 2;
                }
                else
                {
                    p.Command2 = 3;
                }

                p.ReplyCommand1 = 254;
                p.ReplyCommand2 = 2;
                return(p);
            }