示例#1
0
        public Form1()
        {
            InitializeComponent();
            mega = new Arduino("", 19200);

            DataInterpretor dataman = new DataInterpretor();

            dataman.addString("{1,\"hallo, kaas\",5}");

            ComData comdata = dataman.getComData();

            int    param1 = 0;
            string param2 = "";
            int    param3 = 0;

            comdata.Get(0, ref param1);
            comdata.Get(1, ref param2);
            comdata.Get(1, ref param3);

            Debug.Write(param1 + "," + param2 + "," + param3);

            /*StringEater eater = new StringEater();
             *
             * eater.String("hallo there dude");
             * eater.eatUntil(test);
             *
             * Debug.Write(eater.buffer);*/
            tmrConnectionCheck.Enabled = true;
        }
示例#2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="devicename"></param>
        /// <param name="executable">This is a void function that will deal with the incoming commands from the communiation line</param>
        public Communication(string devicename, Action <ComData, Communication> executable)
        {
            reader = new DataInterpretor();
            comID  = 0;

            UpdateLifetime();

            DeviceName = devicename;

            unhandledcommands = new CommandExecution(executable);
        }
示例#3
0
        CTrafficMessage()
        {
            MessagesList = new List <ComData>();
            data         = new DataInterpretor();
            devices      = new DeviceRouting();
            Commandslist = new Commands();

            DeviceRegistry Server = new DeviceRegistry("FTG-SERVER", "server");

            devices.Add(Server);

            myserverID = devices.FindIDByDevice(Server);
        }
示例#4
0
        /// <summary>
        /// Converts stringified ComData to comdata and moves it over
        /// </summary>
        /// <param name="rawcommand">A stringified ComData</param>
        /// <returns></returns>
        public bool Send(string rawcommand)
        {
            DataInterpretor reader = new DataInterpretor();

            reader.addString(rawcommand);

            if (reader.usableInput)
            {
                ComData comdata    = reader.getComData();
                bool    succession = Send(comdata);

                if (succession == true)
                {
                    UpdateLifetime();
                }

                return(succession);
            }
            else
            {
                return(false);
            }
        }
示例#5
0
        /// <summary>
        /// Sends a message to a client
        /// </summary>
        /// <param name="deviceID"></param>
        /// <returns></returns>
        public string RetrieveMessage(int deviceID)
        {
            ComData data;
            string  message = ",";

            DeviceRegistry device = devices.FindByID(deviceID);

            if (MessagesList.Count == 0 || device == null)
            {
                return("{}");
            }
            else
            {
                devices.UpdateLiveTime(deviceID);

                data = MessagesList[0];
                MessagesList.RemoveAt(0);

                int i = 0;

                while (data.GetType(i) > 0)
                {
                    string messagepiece = "";

                    data.Get(i, ref messagepiece);
                    message += messagepiece + ",";
                    i++;
                }
                message = message.Substring(0, message.Length - 1);
                if (message.Length > 0)
                {
                    message = "{" + message + "}";
                }

                return(message);
            }
        }