コード例 #1
0
            public void AddPage(string[] lines, BlinkCode blinkCode, int onTime)
            {
                if (frames.Count > MaxFrames)
                {
                    throw new Exception("Max Pages Reached, remove a page first");
                }
                List <Line> linez = new List <Line>();

                foreach (string line in lines)
                {
                    linez.Add(new Line(line));
                }
                frames.Add(new Sequence(linez, blinkCode, onTime));
            }
コード例 #2
0
 public void AddSequence(int messageNumber, BlinkCode blinkCode, int onTime)
 {
     if (commandParts.Count >= Message.MaxFrames)
     {
         throw new Exception("Maximum Page Count reached, remove a page before adding another");
     }
     if (onTime != 0)
     {
         if (onTime < Sequence.MinimumOnTime)
         {
             throw new Exception("onTime must be greater than '" + Sequence.MinimumOnTime + "'");
         }
         if (onTime > Sequence.MaximumOnTime)
         {
             throw new Exception("onTime must be less than '" + Sequence.MaximumOnTime + "'");
         }
     }
     if (blinkCode == BlinkCode.Illegal)
     {
         throw new Exception("You cannot use BlinkCode Illegal");
     }
     int[] prts = new int[] { messageNumber, (int)blinkCode, onTime };
     commandParts.Add(prts);
 }
コード例 #3
0
 public Sequence(List <Line> lines, BlinkCode blinkCode, int onTime)
 {
     Lines       = lines;
     BlinkCode   = blinkCode;
     this.onTime = onTime;
 }
コード例 #4
0
 public Sequence(int messageNumber, BlinkCode blinkCode, int onTime)
 {
     this.sequenceNumber = (short)messageNumber;
     this.blinkCode      = blinkCode;
     this.onTime         = onTime;
 }
コード例 #5
0
        public bool PutSequence(SequencePutCommand cmd)
        {
            //for each msg in the sequence get the message by number
            //if the BlinkCode for the Line is Sequencing then check for '<', '-', '>'
            //if both '<' and '>' appear then use blinking
            //if any other character is present than '<', '-', '>' then use blinking

            cmd.commandParts.ForEach(cp =>
            {
                BlinkCode bc = (BlinkCode)cp[1];
                if (bc == BlinkCode.Line1Sequencing || bc == BlinkCode.Line2Sequencing || bc == BlinkCode.Line3Sequencing ||
                    bc == BlinkCode.Line1and2Sequencing || bc == BlinkCode.Line1and3Sequencing || bc == BlinkCode.Line2and3Sequencing ||
                    bc == BlinkCode.AllLinesSequencing)
                {
                    Message text = GetMessage(cp[0]);
                    string t;
                    if (bc == BlinkCode.Line1Sequencing)
                    {
                        t = text.Frames[0].Lines[0].Text;
                        if (t.Contains("<") && t.Contains(">"))
                        {
                            cp[1] = (int)BlinkCode.Line1Blink;
                        }
                        else
                        {
                            foreach (char c in t)
                            {
                                if (c != '<' && c != '>' && c != '-' && c != ' ')
                                {
                                    cp[1] = (int)BlinkCode.Line1Blink;
                                }
                            }
                        }
                    }
                    else if (bc == BlinkCode.Line2Sequencing)
                    {
                        t = text.Frames[0].Lines[1].Text;
                        if (t.Contains("<") && t.Contains(">"))
                        {
                            cp[1] = (int)BlinkCode.Line2Blink;
                        }
                        else
                        {
                            foreach (char c in t)
                            {
                                if (c != '<' && c != '>' && c != '-' && c != ' ')
                                {
                                    cp[1] = (int)BlinkCode.Line2Blink;
                                }
                            }
                        }
                    }
                    else if (bc == BlinkCode.Line3Sequencing)
                    {
                        t = text.Frames[0].Lines[2].Text;
                        if (t.Contains("<") && t.Contains(">"))
                        {
                            cp[1] = (int)BlinkCode.Line3Blink;
                        }
                        else
                        {
                            foreach (char c in t)
                            {
                                if (c != '<' && c != '>' && c != '-' && c != ' ')
                                {
                                    cp[1] = (int)BlinkCode.Line3Blink;
                                }
                            }
                        }
                    }
                    else if (bc == BlinkCode.Line1and3Sequencing)
                    {
                        t = text.Frames[0].Lines[0].Text; //+ text.Frames[0].Lines[2].Text;
                        if (t.Contains("<") && t.Contains(">"))
                        {
                            cp[1] = (int)BlinkCode.Line1and3Blink;
                        }
                        else
                        {
                            foreach (char c in t)
                            {
                                if (c != '<' && c != '>' && c != '-' && c != ' ')
                                {
                                    cp[1] = (int)BlinkCode.Line1and3Blink;
                                }
                            }
                        }

                        t = text.Frames[0].Lines[2].Text;
                        if (t.Contains("<") && t.Contains(">"))
                        {
                            cp[1] = (int)BlinkCode.Line1and3Blink;
                        }
                        else
                        {
                            foreach (char c in t)
                            {
                                if (c != '<' && c != '>' && c != '-' && c != ' ')
                                {
                                    cp[1] = (int)BlinkCode.Line1and3Blink;
                                }
                            }
                        }
                    }
                    else if (bc == BlinkCode.Line1and2Sequencing)
                    {
                        t = text.Frames[0].Lines[0].Text;//text.Frames[0].Lines[1].Text;
                        if (t.Contains("<") && t.Contains(">"))
                        {
                            cp[1] = (int)BlinkCode.Line1and2Blink;
                        }
                        else
                        {
                            foreach (char c in t)
                            {
                                if (c != '<' && c != '>' && c != '-' && c != ' ')
                                {
                                    cp[1] = (int)BlinkCode.Line1and2Blink;
                                }
                            }
                        }

                        t = text.Frames[0].Lines[1].Text;
                        if (t.Contains("<") && t.Contains(">"))
                        {
                            cp[1] = (int)BlinkCode.Line1and2Blink;
                        }
                        else
                        {
                            foreach (char c in t)
                            {
                                if (c != '<' && c != '>' && c != '-' && c != ' ')
                                {
                                    cp[1] = (int)BlinkCode.Line1and2Blink;
                                }
                            }
                        }
                    }
                    else if (bc == BlinkCode.Line2and3Sequencing)
                    {
                        t = text.Frames[0].Lines[1].Text;//text.Frames[0].Lines[1].Text;
                        if (t.Contains("<") && t.Contains(">"))
                        {
                            cp[1] = (int)BlinkCode.Line2and3Blink;
                        }
                        else
                        {
                            foreach (char c in t)
                            {
                                if (c != '<' && c != '>' && c != '-' && c != ' ')
                                {
                                    cp[1] = (int)BlinkCode.Line2and3Blink;
                                }
                            }
                        }

                        t = text.Frames[0].Lines[2].Text;
                        if (t.Contains("<") && t.Contains(">"))
                        {
                            cp[1] = (int)BlinkCode.Line2and3Blink;
                        }
                        else
                        {
                            foreach (char c in t)
                            {
                                if (c != '<' && c != '>' && c != '-' && c != ' ')
                                {
                                    cp[1] = (int)BlinkCode.Line2and3Blink;
                                }
                            }
                        }
                    }
                    else if (bc == BlinkCode.AllLinesSequencing)
                    {
                        t = text.Frames[0].Lines[0].Text;//text.Frames[0].Lines[1].Text;
                        if (t.Contains("<") && t.Contains(">"))
                        {
                            cp[1] = (int)BlinkCode.AllLinesBlink;
                        }
                        else
                        {
                            foreach (char c in t)
                            {
                                if (c != '<' && c != '>' && c != '-' && c != ' ')
                                {
                                    cp[1] = (int)BlinkCode.AllLinesBlink;
                                }
                            }
                        }

                        t = text.Frames[0].Lines[1].Text;
                        if (t.Contains("<") && t.Contains(">"))
                        {
                            cp[1] = (int)BlinkCode.AllLinesBlink;
                        }
                        else
                        {
                            foreach (char c in t)
                            {
                                if (c != '<' && c != '>' && c != '-' && c != ' ')
                                {
                                    cp[1] = (int)BlinkCode.AllLinesBlink;
                                }
                            }
                        }

                        t = text.Frames[0].Lines[2].Text;
                        if (t.Contains("<") && t.Contains(">"))
                        {
                            cp[1] = (int)BlinkCode.AllLinesBlink;
                        }
                        else
                        {
                            foreach (char c in t)
                            {
                                if (c != '<' && c != '>' && c != '-' && c != ' ')
                                {
                                    cp[1] = (int)BlinkCode.AllLinesBlink;
                                }
                            }
                        }
                    }
                }
            });


            while (true)
            {
                try
                {
                    cmd.AddSequence(0, 0, 0);
                }
                catch
                {
                    break;
                }
            }

            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 (BitConverter.ToString(result.ToArray()) == BitConverter.ToString(cmd.ErrorResponse))
            {
                return(false);
            }
            return(true);
        }