コード例 #1
0
ファイル: CoreTests.cs プロジェクト: lulzzz/SmartWorld
        public void TestBatchSend()
        {
            IotApi api = new IotApi().
                         RegisterModule(getDefaultModule(false));

            api.Open(new System.Collections.Generic.Dictionary <string, object>());

            api.SendAsync(new List <object>
            {
                new { Prop1 = 1.23, Prop2 = ":)" },
                new { Prop1 = 1.2, Prop2 = ":):)" }
            },

                          (msgs) =>
            {
                Assert.True(msgs.Count == 2);
                Assert.True(((dynamic)msgs[0]).Prop1 == 1.23);
                Assert.True(((dynamic)msgs[1]).Prop2 == ":):)");
            },
                          (msgs, err) =>
            {
                throw err;
            },
                          null).Wait();
        }
コード例 #2
0
        /// <summary>
        /// Get IotApi
        /// </summary>
        /// <returns></returns>
        private IotApi getIotApi()
        {
            var api = new IotApi();

            api.UsePhilpsQueueRest(m_Input.GatewayUrl, m_Input.UserName);
            api.Open();
            return(api);
        }
コード例 #3
0
ファイル: TestClass.cs プロジェクト: lulzzz/SmartWorld
        /// <summary>
        /// Register CoAP module to IotApi module
        /// </summary>
        /// <param name="mock">read in a Mock Object of ICoAPEndpoint</param>
        /// <exception cref=""></exception>
        /// <remarks>N/a</remarks>
        /// <seealso cref=""/>
        /// <see cref=""/>
        /// <permission cref="">This method can be called by: every user</permission>
        /// <exception cref=""></exception>
        private IotApi getApi(Mock <ICoapEndpoint> mock)
        {
            Dictionary <string, object> agr = new Dictionary <string, object>();
            IotApi api = new IotApi().RegisterModule(new CoAPConnector.CoAPclientConnector());

            agr.Add("endPoint", mock.Object);
            api.Open(agr);
            return(api);
        }
コード例 #4
0
ファイル: CoreTests.cs プロジェクト: lulzzz/SmartWorld
        public void TestReceive()
        {
            IotApi api = new IotApi()
                         .RegisterPersistModule(new Dictionary <string, object>())
                         .RegisterModule(getDefaultModule(true));

            api.Open(new System.Collections.Generic.Dictionary <string, object>());

            var msg = api.ReceiveAsync().Result;
        }
コード例 #5
0
ファイル: UnitTests.cs プロジェクト: lulzzz/SmartWorld
        /// <summary>
        /// Used by all tests to create instance of IotApi.
        /// </summary>
        /// <returns></returns>
        private IotApi getApi()
        {
            IotApi api = new IotApi();

            api.UsePhilpsQueueRest(m_GtwUri, m_UsrName);

            api.Open();

            return(api);
        }
コード例 #6
0
ファイル: OpcUATest.cs プロジェクト: lulzzz/SmartWorld
        public void OpenTest()
        {
            Dictionary <string, object> arg = new Dictionary <string, object>();

            arg.Add("endpoint", "opc.tcp://aqib:51210/UA/SampleServer");

            IotApi api = new IotApi();

            api.RegisterModule(new OPCConnector());
            api.Open(arg);
            api.SendAsync("ffff").Wait();
        }
コード例 #7
0
ファイル: MainPage.xaml.cs プロジェクト: lulzzz/SmartWorld
        public MainPage()
        {
            this.InitializeComponent();
            Settings sett = new Settings(); //default setting

            m_Ccu.RegisterModule(new XmlRpc());

            Dictionary <string, object> agr = new Dictionary <string, object>()
            {
                { "Uri", "http://192.168.0.222:2001" }
            };

            m_Ccu.Open(agr);
        }
コード例 #8
0
        public void TestOpen_Door()
        {
            IotApi connector = new IotApi()
                               .RegisterModule(new XmlRpc());

            Dictionary <string, object> agr = new Dictionary <string, object>()
            {
                { "Uri", "http://192.168.0.222:2001" },
                { "Mock", false }
            };

            connector.Open(agr);

            MethodCall request = new MethodCall()
            {
                MethodName = "setValue",
                SendParams = new List <Param>()
                {
                    new Param()
                    {
                        Value = (string)"LEQ1335713:1",
                    },
                    new Param()
                    {
                        Value = (string)"STATE",
                    },
                    new Param()
                    {
                        Value = (bool)true,
                    },
                }
            };

            try
            {
                connector.SendAsync(request,
                                    (onMessage) =>
                {
                    Assert.True(onMessage != null);
                },
                                    (error) =>
                {
                    throw error;
                }).Wait();
            }catch (Exception ex)
            {
                Assert.True(ex != null);
            }
        }
コード例 #9
0
ファイル: BasicTests.cs プロジェクト: lulzzz/SmartWorld
        public void TestSimpleSend()
        {
            IotApi api = new IotApi();

            api.Open();

            api.SendAsync(new { Prop1 = 1.2, Prop2 = ":)" },
                          (msgs) =>
            {
            },
                          (msgs, err) =>
            {
            },
                          null).Wait();
            ;
        }
コード例 #10
0
ファイル: BasicTests.cs プロジェクト: lulzzz/SmartWorld
        public void TestReceive()
        {
            IotApi api = new IotApi()
                         .RegisterPersist(new Dictionary <string, object>())
                         .RegisterModule(getDefaultModule(true));

            api.Open(new System.Collections.Generic.Dictionary <string, object>());

            api.ReceiveAsync(
                (msgs) =>
            {
            },
                (msgs, err) =>
            {
            }).Wait();
        }
コード例 #11
0
ファイル: CoreTests.cs プロジェクト: lulzzz/SmartWorld
        public void TestSimpleSend()
        {
            IotApi api = new IotApi();

            api.Open();

            api.SendAsync(new { Prop1 = 1.2, Prop2 = ":)" },
                          (msgs) =>
            {
                throw new InvalidOperationException("This should not be executed, because no pipeline is defined!");
            },
                          (msgs, err) =>
            {
                throw new InvalidOperationException("This should not be executed, because no pipeline is defined!");
            },
                          null).Wait();
        }
コード例 #12
0
ファイル: BasicTests.cs プロジェクト: lulzzz/SmartWorld
        public void TestSend()
        {
            IotApi api = new IotApi();

            api.Open(new System.Collections.Generic.Dictionary <string, object>());

            api.SendAsync(new { Prop1 = 1.2, Prop2 = ":)" },
                          (msgs) =>
            {
                Assert.IsTrue(msgs.Count == 1);
                // Assert.IsTrue(((dynamic)msgs[0]).Prop1 == 1.2);
            },
                          (msgs, err) =>
            {
                throw err;
            },
                          null).Wait();
        }
コード例 #13
0
ファイル: CoreTests.cs プロジェクト: lulzzz/SmartWorld
        public void TestSend()
        {
            IotApi api = new IotApi().
                         RegisterModule(getDefaultModule(false));

            api.Open(new System.Collections.Generic.Dictionary <string, object>());

            api.SendAsync(new { Prop1 = 1.2, Prop2 = ":)" },
                          (result) =>
            {
                Assert.True(((dynamic)result).Prop1 == 1.2);
                Assert.True(((dynamic)result).Prop2 == ":)");
            },
                          (msgs, err) =>
            {
                throw err;
            },
                          null).Wait();
        }
コード例 #14
0
ファイル: Program.cs プロジェクト: lulzzz/SmartWorld
        static void Main(string[] args)
        {
            IotApi iotApi = new IotApi()
                            .RegisterModule(new XmlRpc());

            Dictionary <string, object> agr = new Dictionary <string, object>()
            {
                { "Uri", "http://192.168.0.222:2001" },
                { "Mock", false }
            };

            iotApi.Open(agr);

            Console.WriteLine("Welcome to IOT Bridge Gateway!");
            Thread.Sleep(2000); // Wait two seconds
            Console.Clear();

            Functions(iotApi);
        }
コード例 #15
0
ファイル: CoreTests.cs プロジェクト: lulzzz/SmartWorld
        public void TestSendWithRetry()
        {
            IotApi api = new IotApi()
                         .RegisterRetryModule(2, TimeSpan.FromSeconds(1))
                         .RegisterPersistModule(new Dictionary <string, object>())
                         .RegisterModule(getDefaultModule(false));


            api.Open();

            api.SendAsync(new { Prop1 = 1.2, Prop2 = ":)" },
                          (result) =>
            {
                Assert.True(((dynamic)result).Prop1 == 1.2);
            },
                          (msgs, err) =>
            {
                throw err;
            },
                          null).Wait();
        }
コード例 #16
0
ファイル: OpcUATest.cs プロジェクト: lulzzz/SmartWorld
        public void NodeWriteTest()
        {
            Dictionary <string, object> arg = new Dictionary <string, object>();

            arg.Add("endpoint", "opc.tcp://aqib:51210/UA/SampleServer");

            IotApi api = new IotApi();

            api.RegisterModule(new OPCConnector());
            api.Open(arg);


            var list = new List <MonitoredItem> {
                new MonitoredItem(new Subscription().DefaultItem)
                {
                    DisplayName = "ServerStatusCurrentTime", StartNodeId = "i=2267"
                }
            };

            api.SendAsync(list).Wait();
            //
        }
コード例 #17
0
ファイル: BasicTests.cs プロジェクト: lulzzz/SmartWorld
        public void TestSendWithRetry()
        {
            IotApi api = new IotApi();

            api
            .RegisterRetry(2, TimeSpan.FromSeconds(1))
            .RegisterPersist(new Dictionary <string, object>())
            .RegisterModule(getDefaultModule(true));

            api.Open(new System.Collections.Generic.Dictionary <string, object>());

            api.SendAsync(new { Prop1 = 1.2, Prop2 = ":)" },
                          (msgs) =>
            {
                Assert.IsTrue(msgs.Count == 1);
            },
                          (msgs, err) =>
            {
                throw err;
            },
                          null).Wait();
        }
コード例 #18
0
        public static void RegisterTest()
        {
            IotApi api = new IotApi();

            api.RegisterModule(new MQTTSnConnector());

            Dictionary <string, object> agr = new Dictionary <string, object>();

            agr.Add("ip", "127.0.0.1");

            agr.Add("port", 100);

            api.Open(agr);

            MessageInterface.RegisterWrk register = new MessageInterface.RegisterWrk();
            register.register.topicId   = new byte[] { };
            register.register.topicName = ASCIIEncoding.ASCII.GetBytes("");
            register.register.messageId = ASCIIEncoding.ASCII.GetBytes(Convert.ToString(2).PadLeft(2, '0'));
            register.register.length    = Convert.ToByte(6 + "ff".Length);

            api.SendAsync(register);
        }
コード例 #19
0
ファイル: CoreTests.cs プロジェクト: lulzzz/SmartWorld
        public void TestFailSendWithRetry()
        {
            Assert.Throws(typeof(AggregateException), () =>
            {
                IotApi api = new IotApi();
                api
                .RegisterRetryModule(2, TimeSpan.FromSeconds(1))
                .RegisterPersistModule(new Dictionary <string, object>())
                .RegisterModule(getDefaultModule(true));

                api.Open(new System.Collections.Generic.Dictionary <string, object>());

                api.SendAsync(new { Prop1 = 1.2, Prop2 = ":)" },
                              (result) =>
                {
                    Assert.True(((dynamic)result).Prop1 == 1.2);
                },
                              (msgs, err) =>
                {
                    throw err;
                },
                              null).Wait();
            });
        }