Ejemplo n.º 1
0
        private void DeInitFlicClient()
        {
            foreach (var chan in ButtonChannels.Values)
            {
                _flicClient.RemoveConnectionChannel(chan);
            }

            _flicClient.Disconnect();
            _flicClient = null;

            ButtonChannels.Clear();
            flicThings.Clear();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Stop broker
        /// </summary>
        public void Stop()
        {
            running = false;
            this.commLayer.Stop();
            this.publisherManager.Stop();

            // close connection with all clients, in transit ones..
            foreach (var client in this.PreClients)
            {
                client.Close();
            }
            PreClients.Clear();
            PreClients = null;

            //and "real" ones
            foreach (var client in this.Clients.Values)
            {
                client.Close();
            }
            Clients.Clear();
            Clients = null;
        }
Ejemplo n.º 3
0
        //------------------------------------------------------------------------------------------------------------------------
        private IEnumerable <Thing> SetupSerialPortThing()
        {
            // Clean old things
            things.Clear();

            // mNode transport conncted event
            {
                var isTransportConnected = new Port()
                {
                    ioDirection = Yodiwo.API.Plegma.ioPortDirection.Output,
                    Name        = "Connected",
                    State       = "",
                    ConfFlags   = ePortConf.IsTrigger,
                    Type        = Yodiwo.API.Plegma.ePortType.Boolean,
                    PortKey     = PortKey.BuildFromArbitraryString("$ThingKey$", "0")
                };
                Ports.Add("isTransportConnected", isTransportConnected);

                var connectionTimestamp = new Port()
                {
                    ioDirection = Yodiwo.API.Plegma.ioPortDirection.Output,
                    Name        = "Timestamp",
                    State       = "",
                    ConfFlags   = ePortConf.None,
                    Type        = Yodiwo.API.Plegma.ePortType.Timestamp,
                    PortKey     = PortKey.BuildFromArbitraryString("$ThingKey$", "1")
                };
                Ports.Add("connectionTimestamp", connectionTimestamp);

                var t = new Yodiwo.API.Plegma.Thing()
                {
                    ThingKey = ThingKey.BuildFromArbitraryString("$NodeKey$", CreateThingKey("0")),
                    Type     = "",
                    Name     = "Transport",
                    Config   = new List <ConfigParameter>(),
                    UIHints  = new ThingUIHints()
                    {
                        IconURI = "http://simpleicon.com/wp-content/uploads/cloud-connection-1.png",
                    },

                    Ports = new List <Port>()
                    {
                        isTransportConnected,
                        connectionTimestamp
                    }
                };

                t = AddThing(t);
                things.Add("Transport", t);
            }

            // mNode periodic send
            {
                var periodicTimestamp = new Port()
                {
                    ioDirection = Yodiwo.API.Plegma.ioPortDirection.Output,
                    Name        = "Timestamp",
                    State       = "",
                    ConfFlags   = ePortConf.None,
                    Type        = Yodiwo.API.Plegma.ePortType.Timestamp,
                    PortKey     = PortKey.BuildFromArbitraryString("$ThingKey$", "0")
                };
                Ports.Add("periodicTimestamp", periodicTimestamp);

                var t = new Yodiwo.API.Plegma.Thing()
                {
                    ThingKey = ThingKey.BuildFromArbitraryString("$NodeKey$", CreateThingKey("1")),
                    Type     = "",
                    Name     = "Periodic",
                    Config   = new List <ConfigParameter>()
                    {
                        // TODO: Use the actual value of the thing
                        new ConfigParameter()
                        {
                            Description = "Period Seconds",
                            Name        = "Period",
                            Value       = "10"
                        }
                    },
                    UIHints = new ThingUIHints()
                    {
                        IconURI = "https://openreferral.org/wp-content/uploads/2015/02/icon_4034-300x300.png",
                    },

                    Ports = new List <Port>()
                    {
                        periodicTimestamp
                    }
                };

                t = AddThing(t);
                things.Add("Periodic", t);
            }

            // mNode Ping
            {
                var echoPortOut = new Port()
                {
                    ioDirection = Yodiwo.API.Plegma.ioPortDirection.Output,
                    Name        = "Echo",
                    State       = "",
                    ConfFlags   = ePortConf.None,
                    Type        = Yodiwo.API.Plegma.ePortType.String,
                    PortKey     = PortKey.BuildFromArbitraryString("$ThingKey$", "0")
                };
                Ports.Add("echoPortOut", echoPortOut);

                var echoPortIn = new Port()
                {
                    ioDirection = Yodiwo.API.Plegma.ioPortDirection.Input,
                    Name        = "Echo",
                    State       = "",
                    ConfFlags   = ePortConf.None,
                    Type        = Yodiwo.API.Plegma.ePortType.String,
                    PortKey     = PortKey.BuildFromArbitraryString("$ThingKey$", "1")
                };
                Ports.Add("echoPortIn", echoPortIn);

                var t = new Yodiwo.API.Plegma.Thing()
                {
                    ThingKey = ThingKey.BuildFromArbitraryString("$NodeKey$", CreateThingKey("2")),
                    Type     = "",
                    Name     = "Ping",
                    Config   = new List <ConfigParameter>(),
                    UIHints  = new ThingUIHints()
                    {
                        IconURI = "https://apk-dl.com/detail/image/com.lipinic.ping-w250.png",
                    },

                    Ports = new List <Port>()
                    {
                        echoPortIn,
                        echoPortOut
                    }
                };

                t = AddThing(t);
                things.Add("Ping", t);
            }

            return(things.Values);
        }