public static byte[] SetBoxColor(byte[] data)
        {
            byte[] cmd_data = new byte[SMTPReply.UNRECOGNIZED_COMMAND];
            int    offset   = 0 + 1;

            cmd_data[0] = (byte)0;
            int offset2 = offset + 1;

            cmd_data[offset]  = (byte)10;
            offset            = offset2 + 1;
            cmd_data[offset2] = (byte)10;
            offset2           = offset + 1;
            cmd_data[offset]  = (byte)4;
            for (int j = 0; j < 363; j += 2)
            {
                if (j == 362)
                {
                    cmd_data[offset2] = (byte)(toUnsigned(data[j]) >> 4);
                }
                else
                {
                    cmd_data[offset2] = (byte)((toUnsigned(data[j]) >> 4) | ((toUnsigned(data[j + 1]) >> 4) << 4));
                }
                offset2++;
            }
            byte[] tmp_cmd_data = new byte[offset2];
            for (int i = 0; i < offset2; i++)
            {
                tmp_cmd_data[i] = cmd_data[i];
            }
            return(TimeBoxWrapper.EncodeCmd(_SetBoxColor, tmp_cmd_data));
        }
Exemple #2
0
        static void Main(string[] args)
        {
            TimeBoxWrapper w     = new TimeBoxWrapper();
            ColorBoard     board = new ColorBoard();

            Job  = new Thread(Action);
            Eyes = new Thread(Cligne);
            Mute = new Mutex();
            Job.Start();
            Eyes.Start();

            w.Connect(new AsyncCallback(Connected));
            Job.Join();
        }
        public static byte[] SetSystemTime()
        {
            DateTime dt = DateTime.Now;

            int year        = dt.Year;
            int center      = year / 100;
            int year_center = year % 100;
            int month       = dt.Month;
            int day_week    = (int)dt.DayOfWeek;
            int day_month   = dt.Day;
            int hour        = dt.Hour;
            int minute      = dt.Minute;
            int second      = dt.Second;

            byte[] cmd = TimeBoxWrapper.EncodeCmd(_SetSystemTime,
                                                  new byte[]
            {
                (byte)(year_center & TelnetOption.MAX_OPTION_VALUE), (byte)(center & TelnetOption.MAX_OPTION_VALUE),
                (byte)(month & TelnetOption.MAX_OPTION_VALUE), (byte)(day_month & TelnetOption.MAX_OPTION_VALUE),
                (byte)(hour & TelnetOption.MAX_OPTION_VALUE), (byte)(minute & TelnetOption.MAX_OPTION_VALUE),
                (byte)(second & TelnetOption.MAX_OPTION_VALUE), (byte)(day_week & TelnetOption.MAX_OPTION_VALUE)
            });
            return(cmd);
        }
 public static byte[] GetConnectedFlag()
 {
     return(TimeBoxWrapper.EncodeCmd(_GetConnectedFlag));
 }
Exemple #5
0
        public static void Action()
        {
            while (!OK)
            {
            }

            stream = TimeBoxWrapper.GetClient().GetStream();
            byte[] buff = CommandType.SetSystemTime();
            color = "1";

            stream.Write(buff, 0, buff.Length);

            bool happy = false;
            bool iter  = false;
            bool write = false;

            Skrom = new ColorBoard();
            Layer   Layer = new Layer(0, 2, 11, 7, new Black());
            Writing w1    = new Writing("Test", new White(), 12, 3);

            while (true)
            {
                DrawSkrom(happy, Skrom, color);

                iter = true;

                while (iter || write)
                {
                    iter = false;

                    if (write)
                    {
                        Layer.Draw(Skrom);
                        w1.Draw(Skrom);
                        write = !w1.Scroll();
                        if (!write)
                        {
                            DrawSkrom(happy, Skrom, color);
                        }
                    }

                    Thread.Sleep(100);
                    Mute.WaitOne();
                    byte[] buff2 = CommandType.SetBoxColor(Skrom.Board);
                    stream.Write(buff2, 0, buff2.Length);
                    Mute.ReleaseMutex();
                }

                string message = Console.ReadLine();

                if (message.Contains("happy"))
                {
                    happy = true;
                }
                else if (message.Contains("normal"))
                {
                    happy = false;
                }
                else if (message.Contains("blue"))
                {
                    color = "3";
                }
                else if (message.Contains("red"))
                {
                    color = "1";
                }
                else if (message.Contains("green"))
                {
                    color = "2";
                }
                else if (message.Contains("purple"))
                {
                    color = "5";
                }
                else if (message.Contains("gold"))
                {
                    color = "6";
                }
                else
                {
                    write = true;
                    w1.SetText(message, new White());
                }
            }
        }