Exemplo n.º 1
0
        private OpenTSPSPerson addPerson(ArrayList args)
        {
            OpenTSPSPerson newPerson = new OpenTSPSPerson();

            updatePerson(newPerson, args);
            people.Add(newPerson.id, newPerson);
            for (int i = 0; i < listeners.Count; i++)
            {
                OpenTSPSListener listener = (OpenTSPSListener)listeners[i];
                if (listener != null)
                {
                    listener.personEntered(newPerson);
                }
            }
            return(newPerson);
        }
Exemplo n.º 2
0
 public void removePersonListener(OpenTSPSListener listener)
 {
     listeners.Remove(listener);
 }
Exemplo n.º 3
0
        /*private void updateScene(OpenTSPSScene scene, ArrayList args)
         * {
         *      /*scene.currentTime = (int)args[0];
         *      scene.percentCovered = (int)args[1];
         *      scene.numPeople = (int)args[2];
         *      scene.averageMotionX = (float)args[3];
         *      scene.averageMotionY = (float)args[4];
         * }*/

        public void addPersonListener(OpenTSPSListener listener)
        {
            listeners.Add(listener);
        }
Exemplo n.º 4
0
        private void processMessage(OSCMessage message)
        {
            string    address = message.Address;
            ArrayList args    = message.Values;

            if (address == "/TSPS/personEntered/")
            {
                addPerson(args);
            }
            else if (address == "/TSPS/personMoved/" || address == "/TSPS/personUpdated/")
            {
                int            person_id = (int)args[0];
                OpenTSPSPerson person    = null;
                if (!people.ContainsKey(person_id))
                {
                    person = addPerson(args);
                }
                else
                {
                    person = people[person_id];
                    updatePerson(person, args);
                    for (int i = 0; i < listeners.Count; i++)
                    {
                        OpenTSPSListener listener = (OpenTSPSListener)listeners[i];
                        if (listener != null)
                        {
                            if (address == "/TSPS/personMoved/")
                            {
                                listener.personMoved(person);
                            }
                            else
                            {
                                listener.personUpdated(person);
                            }
                        }
                    }
                }
            }
            else if (address == "/TSPS/personWillLeave/")
            {
                int person_id = (int)args[0];
                if (people.ContainsKey(person_id))
                {
                    OpenTSPSPerson personToRemove = people[person_id];
                    people.Remove(person_id);
                    for (int i = 0; i < listeners.Count; i++)
                    {
                        OpenTSPSListener listener = (OpenTSPSListener)listeners[i];
                        if (listener != null)
                        {
                            listener.personWillLeave(personToRemove);
                        }
                    }
                }
            }
            else if (address == "/TSPS/scene/")
            {
                //TODO
                //create a scene object that can store global optical flow
                //and scene time parameters
                //OpenTSPSScene scene = new OpenTSPSScene();

                /*if (scene == null)
                 * {
                 *      scene = addScene(args);
                 * }
                 * updateScene(scene, args);
                 * for (int i = 0; i < listeners.Count; i++) {
                 *      OpenTSPSListener listener = (OpenTSPSListener)listeners[i];
                 *      if (listener!=null){
                 *              listener.sceneUpdated(scene);
                 *      }
                 * }*/
            }
        }