static void Main() { var deviceId = ConfigurationManager.AppSettings["deviceId"]; var authenticationMethod = new DeviceAuthenticationWithRegistrySymmetricKey( deviceId, ConfigurationManager.AppSettings["deviceKey"] ) ; var transportType = TransportType.Mqtt; if (!string.IsNullOrWhiteSpace(ConfigurationManager.AppSettings["transportType"])) { transportType = (TransportType) Enum.Parse(typeof(TransportType), ConfigurationManager.AppSettings["transportType"], true); } var client = DeviceClient.Create( ConfigurationManager.AppSettings["hostName"], authenticationMethod, transportType ); var view = new DeviceView(); var viewModel = new DeviceViewModel(deviceId, client); view.DataContext = viewModel; var app = new Application(); app.Run(view); }
//*********************************// //*********DEVICE INTERFACE********// //*********************************// public ICollection <DeviceView> GetAllDevice() { ICollection <DeviceView> devices = new Collection <DeviceView>(); string test = settings["urlJee"].ConnectionString; ICollection <Device> listDevices = serviceDao.GetAllDevicesEnabled(); foreach (Device device in listDevices) { DeviceView deviceView = new DeviceView(); deviceView.id = device.id; deviceView.name = device.name; deviceView.addressMac = device.adressMac; deviceView.disabled = device.disabled.Value; TypeDevice typeDevice = device.TypeDevice; if (typeDevice != null) { TypeDeviceView typeDeviceView = new TypeDeviceView(); typeDeviceView.id = typeDevice.id; typeDeviceView.name = typeDevice.name; deviceView.typeDevices = typeDeviceView; } devices.Add(deviceView); } return(devices); }
private void AddPlayer(Player player) { DeviceView createdDevice = Instantiate(_deviceTemplate, Vector3.zero, Quaternion.identity, transform); createdDevice.transform.localPosition = Vector3.zero; createdDevice.player = player; ConnectedDevices.Add(createdDevice); }
public LegSensor(bool isLeft, DeviceView deviceView) : base(deviceView) { this.isLeft = isLeft; upperLeg = new TargetData(); lowerLeg = new TargetData(); foot = new TargetData(); }
private void DeleteDependentRecords(DeviceView device) { var inputs = _iPortRules.Get(device); foreach (var inputPortView in inputs) { _iPortRules.DeleteRecord(inputPortView.Id); } }
public void RemoveGameForPlayer(NetworkIdentity playerIdentitiy) { DeviceView associatedView = GetDeviceForPlayer(playerIdentitiy); if (associatedView != null) { associatedView.SetCurrentGame(null); } }
public GameData GetCurrentGame(Player player) { DeviceView currentDevice = GetDeviceForPlayer(player); if (currentDevice != null) { return(currentDevice.GetCurrentGame()); } return(null); }
public void SetCurrentGame(Player player, GameData gameData) { DeviceView currentDevice = GetDeviceForPlayer(player); if (currentDevice != null) { currentDevice.SetCurrentGame(gameData); gameData.OnPlayerExitsGame += PlayerExitsGame; } }
private void RemoveClient(NetworkConnection conn) { DeviceView device = ConnectedDevices.First(x => x.player.Connection == conn); if (device != null) { ConnectedDevices.Remove(device); Destroy(device.gameObject); } }
protected override void RenderBody() { foreach (var device in Model) { var view = new DeviceView(device); MainContent.Controls.Add(view); } MainContent.Dock = DockStyle.Fill; }
public IEnumerable <OutputPortView> Get(DeviceView deviceView) { if (deviceView == null) { return(null); } var outputs = _deviceContext.OutputPorts.Where(i => i.DeviceId == deviceView.Id); var inputPortViewList = Mapper.Map <List <OutputPortView> >(outputs.ToList()); return(inputPortViewList); }
public void DeviceViewMatrixSimplePasses([ValueSource(nameof(DeviceViewMatrixCases))] DeviceViewMatrixCase testData) { m_DeviceView = new DeviceView(Quaternion.Euler(0, 0, testData.Rotation), testData.Scale); var screen = testData.DeviceInfo.Screens[0]; m_DeviceView.SetDevice(screen.width, screen.height, screen.presentation.borderSize); var output = (Vector2)m_DeviceView.ViewToScreen.MultiplyPoint(testData.InputPosition); Assert.AreEqual(testData.ResultPosition.x, output.x, 0.1); Assert.AreEqual(testData.ResultPosition.y, output.y, 0.1); }
private void ProcessOpenView(OpenWindowMessage msg) { var view = new DeviceView() { DataContext = msg.DataContext }; view.BorderThickness = new Thickness(1); view.GlowBrush = null; view.SetResourceReference(MetroWindow.BorderBrushProperty, "AccentColorBrush"); view.ShowDialog(); }
public DeviceViewControler(Form frm, DeviceView deviceView, GCDeviceManager deviceMgt) : base(frm) { _deviceView = deviceView; _deviceManager = deviceMgt; if (_deviceManager == null || deviceView == null) { throw (new ArgumentNullException()); } Initialize(); }
public DeviceView GetDeviceById(string id) { DeviceView deviceView = new DeviceView(); Device device = serviceDao.GetDeviceById(Int32.Parse(id)); deviceView.name = device.name; deviceView.disabled = device.disabled.Value; deviceView.nameDeviceType = device.TypeDevice.name; deviceView.id = device.id; deviceView.addressMac = device.adressMac; deviceView.EmployeeToEmployeeView(device.DeviceEmployees); return(deviceView); }
//public TrackedBrow leftBrow; //public TrackedBrow rightBrow; //public TrackedEye leftEye; //public TrackedEye rightEye; //public TrackedMouth mouth; //public TargetData jaw; //public float smile; public HeadSensor(DeviceView deviceView) : base(deviceView) { neck = new TargetData(); head = new TargetData(); // leftBrow = new TrackedBrow(); // rightBrow = new TrackedBrow(); // leftEye = new TrackedEye(); // rightEye = new TrackedEye(); // mouth = new TrackedMouth(); // jaw = new TargetData(); }
public void DeviceToDeviceView(ICollection <DeviceEmployee> deviceEmployees) { ICollection <DeviceView> listdeviceView = new Collection <DeviceView>(); foreach (DeviceEmployee device in deviceEmployees) { DeviceView deviceView = new DeviceView(); deviceView.id = device.Device.id; deviceView.name = device.Device.name; deviceView.addressMac = device.Device.adressMac; deviceView.disabled = device.Device.disabled.Value; deviceView.nameDeviceType = device.Device.TypeDevice.name; listdeviceView.Add(deviceView); } this.devices = listdeviceView; }
public bool AddRecord(ref DeviceView deviceView) { try { var newRecord = Mapper.Map <Device>(deviceView); _deviceContext.Devices.Add(newRecord); _deviceContext.SaveChanges(); deviceView = Mapper.Map <DeviceView>(newRecord); } catch (Exception e) { LogTo.Fatal("Database insert failed.\r\n Error Message :" + e.Message); return(false); } return(true); }
public DeviceToolControler(Form frm, DeviceView view, SliderPanel panel, GCDeviceManager deviceMgt, GCInterfaceManager interfaceMgt) : base(frm) { _deviceView = view; _viewPanel = panel; _deviceManager = deviceMgt; _interfaceMgt = interfaceMgt; if (_viewPanel == null || _deviceView == null || _deviceManager == null || _interfaceMgt == null) { throw (new ArgumentNullException()); } Initialize(); }
public ActionResult Create(DeviceView deviceView) { if (deviceView != null && User != null) { deviceView.UserName = User.Identity.Name; } try { if (!ModelState.IsValid) { var errors = ModelState.GetEnumerator(); var message = errors.ToNullSafeString(); return(Json(new { Result = "ERROR", Message = "Form is not valid! Error " + message })); } if (_deviceRules.AddRecord(ref deviceView)) { return(Json(new { Result = "OK", Record = deviceView })); } return(Json(new { Result = "ERROR", Message = "We tried hard but beyond control\r\n " + "Please try later" })); } catch (Exception exception) { LogTo.Fatal("{0}{1}", _exceptionMessage, exception.Message); return(Json(new { Result = "ERROR", Message = "We tried hard but beyond control\r\n " + "Please try later" })); } }
/// <summary> /// Gets a new instance of the device user interface. /// </summary> public static bool GetDeviceView(IAdminContext adminContext, CommApp commApp, DeviceConfig deviceConfig, out DeviceView deviceView, out string errMsg) { ArgumentNullException.ThrowIfNull(adminContext, nameof(adminContext)); ArgumentNullException.ThrowIfNull(commApp, nameof(commApp)); ArgumentNullException.ThrowIfNull(deviceConfig, nameof(deviceConfig)); deviceView = null; if (string.IsNullOrEmpty(deviceConfig.Driver)) { errMsg = ExtensionPhrases.DriverNotSpecified; return(false); } else if (!GetDriverView(adminContext, commApp, deviceConfig.Driver, out DriverView driverView, out errMsg)) { return(false); }
//********************************// //*********CALUL INTERFACE********// //********************************// public ICollection <DeviceView> GetListDevicesByEmployee() { ICollection <DeviceView> devices = new Collection <DeviceView>(); ICollection <Device> listDevices = serviceDao.GetAllDevicesDao(); foreach (Device device in listDevices) { DeviceView deviceView = new DeviceView(); deviceView.id = device.id; deviceView.name = device.name; deviceView.addressMac = device.adressMac; deviceView.disabled = device.disabled.Value; deviceView.nameDeviceType = device.TypeDevice.name; deviceView.EmployeeToEmployeeView(device.DeviceEmployees); devices.Add(deviceView); } return(devices); }
private DeviceView CreatePugioDeviceView() { BitmapImage bitmapImage = new BitmapImage(new Uri(this.BaseUri, "/Assets/PUGIO.png")); DeviceModel pugioDM = new DeviceModel { Name = "Pugio", Image = bitmapImage, PixelLeft = 1 * GridPixels, PixelTop = 1 * GridPixels, PixelWidth = 8 * GridPixels, PixelHeight = 10 * GridPixels }; var view = new DeviceView { DataContext = pugioDM }; return(view); }
public ActionResult Edit(int id, DeviceView deviceView) { try { if (!ModelState.IsValid) { var errors = ModelState.GetEnumerator(); var message = errors.ToNullSafeString(); return(Json(new { Result = "ERROR", Message = "Form is not valid! Error " + message })); } if (deviceView != null && id != deviceView.Id) { deviceView.Id = id; } _deviceRules.UpdateRecord(ref deviceView); return(Json(new { Result = "OK", Record = 1 })); } catch (Exception e) { LogTo.Fatal("Error while adding record \r\nMessage:" + e.Message); return(Json(new { Result = "ERROR", Message = "Error while editing record" + "Please try later" })); } }
public bool UpdateRecord(ref DeviceView deviceView) { var device = _deviceContext.Devices.Find(deviceView.Id); if (device == null) { return(false); } Mapper.Map(deviceView, device); try { _deviceContext.SaveChanges(); Mapper.Map(device, deviceView); } catch (Exception exception) { LogTo.Fatal("Error while updating record\r\n Message: "); LogTo.Fatal(exception.Message); return(false); } return(true); }
private async Task StartPreviewAsync(StorageFolder folder) { try { VerifyCanvas.Children.Remove(gVerifyDV); DeviceModel dm = await DeviceModel.GetDeviceModel(folder); gVerifyDV = new DeviceView(); gVerifyDV.DataContext = dm; VerifyCanvas.Children.Add(gVerifyDV); var allzones = dm.AllZones; SortByZIndex(allzones); SetMouseDectectedRegion(new Point(dm.PixelLeft, dm.PixelTop), allzones); VerifyStatus.Text = ""; } catch { VerifyStatus.Text = "輸入錯誤!"; } }
/// <summary> /// Sets the default polling options of the added device. /// </summary> private void SetPollingOptions() { if (!string.IsNullOrEmpty(DeviceConfig.Driver)) { if (ExtensionUtils.GetDriverView(adminContext, Instance.CommApp, DeviceConfig.Driver, out DriverView driverView, out string message)) { if (driverView.CanCreateDevice) { DeviceView deviceView = driverView.CreateDeviceView(LineConfig, DeviceConfig); PollingOptions pollingOptions = deviceView?.GetPollingOptions(); if (pollingOptions != null) { pollingOptions.CopyTo(DeviceConfig.PollingOptions); } } } else { ScadaUiUtils.ShowError(message); } }
/// <summary> /// Sets the default polling options for the specified device. /// </summary> private void SetPollingOptions(DeviceConfig deviceConfig) { if (!string.IsNullOrEmpty(deviceConfig.Driver)) { if (ExtensionUtils.GetDriverView(adminContext, commApp, deviceConfig.Driver, out DriverView driverView, out string message)) { if (driverView.CanCreateDevice) { DeviceView deviceView = driverView.CreateDeviceView(deviceConfig.ParentLine, deviceConfig); PollingOptions pollingOptions = deviceView?.GetPollingOptions(); if (pollingOptions != null) { pollingOptions.CopyTo(deviceConfig.PollingOptions); } } } else { lastErrorMessage = message; } }
public void RefreshStage() { List <MouseDetectedRegion> regions = new List <MouseDetectedRegion>(); SpaceCanvas.Children.Clear(); SpaceCanvas.Children.Add(GridImage); SpaceCanvas.Children.Add(RestrictLineLeft); SpaceCanvas.Children.Add(RestrictLineRight); SpaceCanvas.Children.Add(RestrictLineTop); SpaceCanvas.Children.Add(RestrictLineBottom); SpaceCanvas.Children.Add(MouseRectangle); var onStageList = DeviceModelCollection.FindAll(d => d.Plugged == true && d.Sync == true); foreach (var dm in onStageList) { List <ZoneModel> allzones = dm.AllZones; SortByZIndex(allzones); foreach (var zone in allzones) { Rect relative = zone.GetRect(); Rect absolute = new Rect( new Point(relative.Left + dm.PixelLeft, relative.Top + dm.PixelTop), new Point(relative.Right + dm.PixelLeft, relative.Bottom + dm.PixelTop) ); MouseDetectedRegion r = new MouseDetectedRegion() { RegionIndex = -1, DetectionRect = absolute, GroupIndex = dm.Type }; r.Callback = zone.OnReceiveMouseEvent; regions.Add(r); } DeviceView view = new DeviceView(); view.DataContext = dm; SpaceCanvas.Children.Add(view); } m_MouseEventCtrl.DetectionRegions = regions.ToArray(); GoToBlankEditing(); StopScrollTimer(); if (DeviceModelCollection.FindAll(find => find.Plugged == true).Count == 0) { MaskManager.GetInstance().ShowMask(MaskType.NoSupportDevice); } else if (DeviceModelCollection.Find(find => find.Sync == true) == null) { MaskManager.GetInstance().ShowMask(MaskType.NoSyncDevice); } else { MaskManager.GetInstance().ShowMask(MaskType.None); } }
public TorsoSensor(DeviceView deviceView) : base(deviceView) { chest = new TargetData(); spine = new TargetData(); hips = new TargetData(); }