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(); }
/// <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); }
/// <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); }
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; }
/// <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); }
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(); }
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); }
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); } }
public void TestSimpleSend() { IotApi api = new IotApi(); api.Open(); api.SendAsync(new { Prop1 = 1.2, Prop2 = ":)" }, (msgs) => { }, (msgs, err) => { }, null).Wait(); ; }
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(); }
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(); }
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(); }
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(); }
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); }
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(); }
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(); // }
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(); }
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); }
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(); }); }