public void ThrowsAnExceptionWhenTheServiceLocatorIsNull() { Assert.Throws <ArgumentNullException>(() => { _ = new DeviceTypeFactory(null); }); }
public override Task OnStartAsync(StartKind startKind, IActivatedEventArgs args) { // long-running startup tasks go here db = new DataService(); db.createDB(); foreach (var device in db.DevicesTable) { IDevice dev = DeviceTypeFactory.MakeDevice(device.FirmwareName, device); dev.DeviceDetails.Status = DeviceStatus.Missing; devices.Add(dev); } NavigationService.Navigate(typeof(Views.MainPage)); ssdpClient.Search(); wifiClient.Search(); searchTimer.Tick += SearchTimer_Tick; searchTimer.Interval = new TimeSpan(0, 1, 0); searchTimer.Start(); return(Task.CompletedTask); }
//Called on the first frame in which the script is active // (Often the first frame of the application) void Start() { //speed = 1.0f; //This would always reset speed to 1, regardless of value entered in Inspector //Count of objects collected //****** NB: displayed in UI Text component, //****** which must be a child of a Canvas to display properly // //Set Text anchor to Top Left (Anchor Presets view under Inspector>Rect transform) // also set Pivot(Shift key) and Position(Alt key) // //***** NB: Set both Horiz and Vert Overflow to "Overflow" (instead of Wrap or Truncate) //***** in order to see full text if it is too long for text box ... count = 0; UpdateStatsDisplay(); //winText.text = ""; //see "Bonus, not in tutorial" //Gets attached Rigidbody if there is one rb = GetComponent <Rigidbody>(); if (rb == null) { throw new System.Exception("No RigidBody attached to Component"); } //Bonus, not in tutorial deviceType = DeviceTypeFactory.getDeviceType(); //TODO: place in separate object string devicename = deviceType.ToString(); winText.text = "applem34 Demo:\n" + devicename.TrimStart("Assets.Scripts.".ToCharArray()); }
public void ReturnsAnUnknownDeviceWhenNotExpected() { var serviceLocator = new Mock <IServiceProvider>(); var target = new DeviceTypeFactory(serviceLocator.Object); var result = target.Create("unknown-name", "unknown-device"); Assert.IsInstanceOf <Unknown>(result); var device = (Unknown)result; Assert.AreEqual("unknown-name", device.Name); Assert.AreEqual("unknown-device", device.DeviceType); }
private async void WifiClient_DeviceFound(object sender, WiFiClient.DeviceFoundEventArgs e) { var device = devices.FirstOrDefault(D => D.GivenName == e.Device.GivenName); await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.High, () => { if (device == null) { devices.Add(DeviceTypeFactory.MakeDevice(e.Device.FirmwareName, e.Device)); db.InsertNewDevice(e.Device); } else { device.DeviceDetails.Status = DeviceStatus.UnProvisioned; } }); }
private async void SsdpClient_DeviceFound(object sender, DeviceFoundEventArgs e) { if (e.Device.DeviceType.manufacturer == "IOESPT") { var foundDevice = devices.FirstOrDefault(D => D.DeviceDetails.ChipId == e.Device.DeviceType.serialNumber); Uri uri = new Uri(e.Device.URLBase); if (foundDevice != null) { await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.High, () => { foundDevice.DeviceDetails.Status = DeviceStatus.Online; foundDevice.DeviceDetails.Ip = uri.Host; }); } else { //We have a new device online var newDevice = new RegisteredDevice(); newDevice.ChipId = e.Device.DeviceType.serialNumber; newDevice.FirmwareName = e.Device.DeviceType.modelName; newDevice.ModuleType = e.Device.DeviceType.modelName; newDevice.FirmwareVersion = e.Device.DeviceType.modelNumber; newDevice.GivenName = e.Device.DeviceType.friendlyName; newDevice.Status = DeviceStatus.Online; newDevice.ConnectedTo = "None"; newDevice.Ip = uri.Host; db.InsertNewDevice(newDevice); await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.High, () => { devices.Add(DeviceTypeFactory.MakeDevice(newDevice.FirmwareName, newDevice)); }); } } }
public void Demo5() { JT808GlobalConfig.Instance .Register(Assembly.GetCallingAssembly()); JT808Package jT808Package = JT808MsgId.位置信息汇报.Create("123456789012", new JT808_0x0200 { AlarmFlag = 1, Altitude = 40, GPSTime = DateTime.Parse("2018-12-20 20:10:10"), Lat = 12222222, Lng = 132444444, Speed = 60, Direction = 0, StatusFlag = 2, JT808CustomLocationAttachData = new Dictionary <byte, JT808_0x0200_CustomBodyBase> { { 0x81, new JT808_0x0200_DT1_0x81 { Age = 15, Gender = 1, UserName = "******" } } } }); byte[] data = JT808Serializer.Serialize(jT808Package); var jT808PackageResult = JT808Serializer.Deserialize <JT808Package>(data); JT808_0x0200 jT808_0X0200 = jT808PackageResult.Bodies as JT808_0x0200; var attach = DeviceTypeFactory.Create(cache[jT808PackageResult.Header.TerminalPhoneNo], jT808_0X0200.JT808CustomLocationAttachOriginalData); var extJson = attach.ExtData.Data.ToString(Formatting.None); var attachinfo81 = (JT808_0x0200_DT1_0x81)attach.JT808CustomLocationAttachData[0x81]; Assert.Equal((uint)15, attachinfo81.Age); Assert.Equal(1, attachinfo81.Gender); Assert.Equal("smallchi", attachinfo81.UserName); }