示例#1
0
        static void Main(string[] args)
        {
            Sensor ss = new Sensor("jl2", "user2", "bathstudent", "example");
            ss.SensorCreateEvent += new SensorCreateEventHandler(OnSensorCreated);

            JsonReading jr = new JsonReading();
            int cnt = 0;

            while (cnt < 152140)
            {
                TimeSpan ts = DateTime.UtcNow - dt;
                long millis = (long)ts.TotalMilliseconds;

                jr.AddValue("takenAt", (double)millis);
                jr.AddValue("ACTION", "convoyMember4,amMoving(true)");
                jr.AddValue("position", "153.04442797954152,0.0,262.3134876039802,149.5465600849747,0.0,262.43563584243896");

                ss.Publish(jr);
                jr.RemoveAll();
                cnt++;
                Thread.Sleep(100);

            }
        }
示例#2
0
        public void OnChatFromSimulator(object sender, ChatEventArgs e)
        {
            if (e.Message != "\n" && e.Message != " " && e.Message != "")
            {
                string msg = e.Message;
                string name = m_Client.Self.FirstName;
                string target = "mind" + name.ElementAt(name.Length - 1) + "@jlnetbook/smack";

                Console.WriteLine("Incoming Message : " + msg);

                JsonReading jr = new JsonReading();
                string evt = null;

                if (e.FromName.StartsWith(Constant.CONDUCTOR))
                {
                    // Case 1
                    if (msg.Equals("all aboard") == true)
                    {
                        SetDestination(e.Position); evt = "ready";
                    }
                    else
                    {
                        evt = msg;
                    }
                }
                else if (e.FromName.StartsWith(Constant.DISABLED))
                {
                    // Perceive as if it recognises disabled people
                    if (msg.Contains("space") == true)
                    {
                        evt = "detect(disabled)";
                    }
                }

                if (evt != null)
                {
                    jr.AddValue("EVENT", evt);
                    m_Sensor.Publish(jr);
                }
                else
                {
                    // no-op
                    Debug.WriteLine("No data published in Chat Message Handler!");
                }
            }
        }