Exemplo n.º 1
0
 internal PositionSensor(Transport transport) :
     base(transport)
 {
     //register hook event for motion event
     //each motion event is characterized by x,y,z coordinates
     //this.OnGetContinuousDatacb += OnGetPositionData;
 }
Exemplo n.º 2
0
 static void Main(string[] args)
 {
     System.Diagnostics.Trace.Listeners.Add(new System.Diagnostics.TextWriterTraceListener(Console.Out));
     System.Diagnostics.Trace.AutoFlush = true;
     Transport trans = new Transport();
     //@"C:\Users\sodi\YodiwoDev\sw\projects\grovepi"
     trans.Init(@"/usr/bin/python", "/home/pi/YodiwoDev/skywriter_transport.py");
     SkyWriterNode skywriternode = new SkyWriterNode(trans);
     skywriternode.Start();
     while (true)
         Task.Delay(500).Wait();
 }
Exemplo n.º 3
0
 public SkyWriterNode(Transport trans)
 {
     this.pysharp = trans;
 }
Exemplo n.º 4
0
 //------------------------------------------------------------------------------------------------------------------------
 internal GestureSensor(Transport transport) :
     base(transport)
 {
     //register gesture events(tap,touch,doubletap,airwheel,flick)
     //this.OnGetContinuousDatacb += OnGetGestureEventsData;
 }
Exemplo n.º 5
0
 public SkyWriterNode(Transport trans)
 {
     this.pysharp = trans;
 }
Exemplo n.º 6
0
        public static void CreateThings(Transport trans, Node node)
        {
            //setup Position  thing
            //3 ports (x,y,z)
            #region Setup Position thing
            {
                var thing = new Yodiwo.API.Plegma.Thing()
                {
                    ThingKey = ThingKey.BuildFromArbitraryString("$NodeKey$", "PositionThing"),
                    Type = ThingTypeLibrary.PositionSensor.Type + PlegmaAPI.ThingModelTypeSeparatorPlusDefault,
                    Name = "Position",
                    Config = null,
                    UIHints = new ThingUIHints()
                    {
                        IconURI = "/Content/img/icons/Generic/position.png",
                    },
                };
                thing.Ports = new List<Yodiwo.API.Plegma.Port>()
                {
                    new Yodiwo.API.Plegma.Port()
                    {
                        ioDirection = Yodiwo.API.Plegma.ioPortDirection.Output,
                        Name = "Position x State",
                        State = "0",
                        Type = Yodiwo.API.Plegma.ePortType.String,
                        PortModelId = ModelTypeLibrary.PositionSensorModel_XId,
                        PortKey = PortKey.BuildFromArbitraryString("$ThingKey$", "0")
                    },
                    new Yodiwo.API.Plegma.Port()
                    {
                        ioDirection = Yodiwo.API.Plegma.ioPortDirection.Output,
                        Name = "Position y State",
                        State = "0",
                        Type = Yodiwo.API.Plegma.ePortType.String,
                        PortModelId = ModelTypeLibrary.PositionSensorModel_YId,
                        PortKey = PortKey.BuildFromArbitraryString("$ThingKey$", "1")
                    },
                    new Yodiwo.API.Plegma.Port()
                    {
                        ioDirection = Yodiwo.API.Plegma.ioPortDirection.Output,
                        Name = "Position z State",
                        State = "0",
                        Type = Yodiwo.API.Plegma.ePortType.String,
                        PortModelId = ModelTypeLibrary.PositionSensorModel_ZId,
                        PortKey = PortKey.BuildFromArbitraryString("$ThingKey$", "2")
                    },
                };
                PositionThing = thing = node.AddThing(thing);
            }
            #endregion

            //setup Gesture thing
            // 5 ports(i.e tap:'center','flick':north2south,'touch':west...)
            #region Setup Gesture thing
            {
                var thing = new Yodiwo.API.Plegma.Thing()
                {
                    ThingKey = ThingKey.BuildFromArbitraryString("$NodeKey$", "GestureThing"),
                    Type = ThingTypeLibrary.GestureSensor.Type + PlegmaAPI.ThingModelTypeSeparatorPlusDefault,
                    Name = "Gesture",
                    Config = null,
                    UIHints = new ThingUIHints()
                    {
                        IconURI = "/Content/img/icons/Generic/motion.png",
                    },
                };
                thing.Ports = new List<Yodiwo.API.Plegma.Port>()
                {
                    new Yodiwo.API.Plegma.Port()
                    {
                        ioDirection = Yodiwo.API.Plegma.ioPortDirection.Output,
                        Name = "Tap",
                        State = "false",
                        Type = Yodiwo.API.Plegma.ePortType.String,
                        PortModelId = ModelTypeLibrary.GestureSensorModel_TapId,
                        PortKey = PortKey.BuildFromArbitraryString("$ThingKey$", "0")
                    },
                    new Yodiwo.API.Plegma.Port()
                    {
                        ioDirection = Yodiwo.API.Plegma.ioPortDirection.Output,
                        Name = "Touch",
                        State = "false",
                        Type = Yodiwo.API.Plegma.ePortType.String,
                        PortModelId = ModelTypeLibrary.GestureSensorModel_TouchId,
                        PortKey = PortKey.BuildFromArbitraryString("$ThingKey$", "1")
                    },
                    new Yodiwo.API.Plegma.Port()
                    {
                        ioDirection = Yodiwo.API.Plegma.ioPortDirection.Output,
                        Name = "DoubleTap",
                        State = "false",
                        Type = Yodiwo.API.Plegma.ePortType.String,
                        PortModelId = ModelTypeLibrary.GestureSensorModel_DoubleTapId,
                        PortKey = PortKey.BuildFromArbitraryString("$ThingKey$", "2")
                    },
                    new Yodiwo.API.Plegma.Port()
                    {
                        ioDirection = Yodiwo.API.Plegma.ioPortDirection.Output,
                        Name = "Airwheel",
                        State = "false",
                        Type = Yodiwo.API.Plegma.ePortType.String,
                        PortModelId = ModelTypeLibrary.GestureSensorModel_AirwheelId,
                        PortKey = PortKey.BuildFromArbitraryString("$ThingKey$", "3")
                    },
                    new Yodiwo.API.Plegma.Port()
                    {
                        ioDirection = Yodiwo.API.Plegma.ioPortDirection.Output,
                        Name = "Flick",
                        State = "false",
                        Type = Yodiwo.API.Plegma.ePortType.String,
                        PortModelId = ModelTypeLibrary.GestureSensorModel_FlickId,
                        PortKey = PortKey.BuildFromArbitraryString("$ThingKey$", "4")
                    },
                };
                GestureThing = thing = node.AddThing(thing);
            }
            #endregion

            //add things
            Things.Add(PositionThing);
            Things.Add(GestureThing);

            //create skywriter sensors
            PositionSensor positionsensor = new PositionSensor(trans);
            GestureSensor gesturesensor = new GestureSensor(trans);
            //update dictinaries
            Lookup.Add(PositionThing, positionsensor);
            Lookup.Add(GestureThing, gesturesensor);
            SkyWriterSensors.Add(PositionThing.Name, positionsensor);
            SkyWriterSensors.Add(GestureThing.Name, gesturesensor);

            //register events
            positionsensor.OnGetContinuousDatacb += p => OnGetPositionDatacb(positionsensor, p);
            gesturesensor.OnGetContinuousDatacb += p => OnGetGestureDatacb(gesturesensor, p);
        }
Exemplo n.º 7
0
        public static List <Thing> GatherThings(Transport trans)
        {
            //setup Position  thing
            //3 ports (x,y,z)
            #region Setup Position thing
            {
                var thing = PositionThing = new Yodiwo.API.Plegma.Thing()
                {
                    Type    = "yodiwo.output.sensors.position",
                    Name    = "Position",
                    Config  = null,
                    UIHints = new ThingUIHints()
                    {
                        IconURI = "/Content/SkyWriter/img/position.png",
                    },
                };
                thing.Ports = new List <Yodiwo.API.Plegma.Port>()
                {
                    new Yodiwo.API.Plegma.Port()
                    {
                        ioDirection = Yodiwo.API.Plegma.ioPortDirection.Output,
                        Name        = "Position x State",
                        State       = "0",
                        Type        = Yodiwo.API.Plegma.ePortType.String,
                        PortKey     = PortKey.BuildFromArbitraryString("$ThingKey$", "0")
                    },
                    new Yodiwo.API.Plegma.Port()
                    {
                        ioDirection = Yodiwo.API.Plegma.ioPortDirection.Output,
                        Name        = "Position y State",
                        State       = "0",
                        Type        = Yodiwo.API.Plegma.ePortType.String,
                        PortKey     = PortKey.BuildFromArbitraryString("$ThingKey$", "1")
                    },
                    new Yodiwo.API.Plegma.Port()
                    {
                        ioDirection = Yodiwo.API.Plegma.ioPortDirection.Output,
                        Name        = "Position z State",
                        State       = "0",
                        Type        = Yodiwo.API.Plegma.ePortType.String,
                        PortKey     = PortKey.BuildFromArbitraryString("$ThingKey$", "2")
                    },
                };
            }
            #endregion

            //setup Gesture thing
            // 5 ports(i.e tap:'center','flick':north2south,'touch':west...)
            #region Setup Gesture thing
            {
                var thing = GestureThing = new Yodiwo.API.Plegma.Thing()
                {
                    Type    = "yodiwo.output.gesture",
                    Name    = "Gesture",
                    Config  = null,
                    UIHints = new ThingUIHints()
                    {
                        IconURI = "/Content/SkyWriter/img/motion.png",
                    },
                };
                thing.Ports = new List <Yodiwo.API.Plegma.Port>()
                {
                    new Yodiwo.API.Plegma.Port()
                    {
                        ioDirection = Yodiwo.API.Plegma.ioPortDirection.Output,
                        Name        = "Tap",
                        State       = "false",
                        Type        = Yodiwo.API.Plegma.ePortType.String,
                        PortKey     = PortKey.BuildFromArbitraryString("$ThingKey$", "0")
                    },
                    new Yodiwo.API.Plegma.Port()
                    {
                        ioDirection = Yodiwo.API.Plegma.ioPortDirection.Output,
                        Name        = "Touch",
                        State       = "false",
                        Type        = Yodiwo.API.Plegma.ePortType.String,
                        PortKey     = PortKey.BuildFromArbitraryString("$ThingKey$", "1")
                    },
                    new Yodiwo.API.Plegma.Port()
                    {
                        ioDirection = Yodiwo.API.Plegma.ioPortDirection.Output,
                        Name        = "DoubleTap",
                        State       = "false",
                        Type        = Yodiwo.API.Plegma.ePortType.String,
                        PortKey     = PortKey.BuildFromArbitraryString("$ThingKey$", "2")
                    },
                    new Yodiwo.API.Plegma.Port()
                    {
                        ioDirection = Yodiwo.API.Plegma.ioPortDirection.Output,
                        Name        = "Airwheel",
                        State       = "false",
                        Type        = Yodiwo.API.Plegma.ePortType.String,
                        PortKey     = PortKey.BuildFromArbitraryString("$ThingKey$", "3")
                    },
                    new Yodiwo.API.Plegma.Port()
                    {
                        ioDirection = Yodiwo.API.Plegma.ioPortDirection.Output,
                        Name        = "Flick",
                        State       = "false",
                        Type        = Yodiwo.API.Plegma.ePortType.String,
                        PortKey     = PortKey.BuildFromArbitraryString("$ThingKey$", "4")
                    },
                };
            }
            #endregion

            //add things
            Things.Add(PositionThing);
            Things.Add(GestureThing);

            //create skywriter sensors
            PositionSensor positionsensor = new PositionSensor(trans);
            GestureSensor  gesturesensor  = new GestureSensor(trans);
            //update dictinaries
            Lookup.Add(PositionThing, positionsensor);
            Lookup.Add(GestureThing, gesturesensor);
            SkyWriterSensors.Add(PositionThing.Name, positionsensor);
            SkyWriterSensors.Add(GestureThing.Name, gesturesensor);

            //register events
            positionsensor.OnGetContinuousDatacb += p => OnGetPositionDatacb(positionsensor, p);
            gesturesensor.OnGetContinuousDatacb  += p => OnGetGestureDatacb(gesturesensor, p);

            return(Things);
        }
Exemplo n.º 8
0
        //------------------------------------------------------------------------------------------------------------------------
        #endregion

        #region Constructor
        //------------------------------------------------------------------------------------------------------------------------
        public SkyWriterSensor(Transport trans, Type datatype = null)
        {
            this.transport = trans;
            watcher        = new SensorWatcher(this, trans);
        }