Beispiel #1
0
        public Message QueryMessage()
        {
            Message      response = new Message();
            QueryCommand cmd      = new QueryCommand();


            byte[] outBytes = cmd.ToBytes().ToArray();

            List <byte> result = new List <byte>(SendRecieve(outBytes, 0));

            while (result[result.Count - 1] != CommandBase.CommandEnd)
            {
                result.AddRange(Recieve());
            }

            result.RemoveAt(result.Count - 1);

            if (Encoding.ASCII.GetString(result.ToArray()) == "QFF")
            {
                response.MessageNumber = 0xff;
                return(response);
            }
            else
            {
                result.RemoveRange(0, cmd.CommandCharacters.Length);

                response.MessageNumber = Int16.Parse(Encoding.ASCII.GetString(result.GetRange(0, 2).ToArray()), System.Globalization.NumberStyles.HexNumber);//Convert.ToInt16(System.Text.Encoding.ASCII.GetString(result.GetRange(0, 2).ToArray()));

                result.RemoveRange(0, 2);

                while (result.Count > 0)
                {
                    byte[]    workingFrame = result.GetRange(0, 27).ToArray();
                    BlinkCode code;
                    int       onTime;
                    string[]  lines = new string[Sequence.MaxLines];
                    lines[0] = Encoding.ASCII.GetString(workingFrame, 0, 8);
                    lines[1] = Encoding.ASCII.GetString(workingFrame, 8, 8);
                    lines[2] = Encoding.ASCII.GetString(workingFrame, 16, 8);
                    code     = (BlinkCode)Convert.ToInt16(System.Text.Encoding.ASCII.GetString(workingFrame, 24, 1));
                    onTime   = int.Parse(System.Text.Encoding.ASCII.GetString(workingFrame, 25, 2), System.Globalization.NumberStyles.HexNumber);//workingFrame[25] | workingFrame[26];
                    response.AddPage(lines, code, onTime);
                    result.RemoveRange(0, 27);
                }


                return(response);
            }
        }
Beispiel #2
0
        public static void SendQueryCommand(QueryCommand queryCommand)
        {
            var commandHeader = new CommandHeader
            {
                Count = 1,
                Type  = (int)CommandTypeEnum.QueryCommand
            };


            byte[] commandBytes = CommandUtils.ConcatByteArrays(commandHeader.ToBytes(), queryCommand.ToBytes());
            SendAnswer(IP, Port, commandBytes);
        }