Esempio n. 1
0
        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);
        }
Esempio n. 2
0
    //*********************************//
    //*********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);
    }
Esempio n. 3
0
    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);
    }
Esempio n. 4
0
        public LegSensor(bool isLeft, DeviceView deviceView) : base(deviceView)
        {
            this.isLeft = isLeft;

            upperLeg = new TargetData();
            lowerLeg = new TargetData();
            foot     = new TargetData();
        }
Esempio n. 5
0
        private void DeleteDependentRecords(DeviceView device)
        {
            var inputs = _iPortRules.Get(device);

            foreach (var inputPortView in inputs)
            {
                _iPortRules.DeleteRecord(inputPortView.Id);
            }
        }
Esempio n. 6
0
    public void RemoveGameForPlayer(NetworkIdentity playerIdentitiy)
    {
        DeviceView associatedView = GetDeviceForPlayer(playerIdentitiy);

        if (associatedView != null)
        {
            associatedView.SetCurrentGame(null);
        }
    }
Esempio n. 7
0
    public GameData GetCurrentGame(Player player)
    {
        DeviceView currentDevice = GetDeviceForPlayer(player);

        if (currentDevice != null)
        {
            return(currentDevice.GetCurrentGame());
        }
        return(null);
    }
Esempio n. 8
0
    public void SetCurrentGame(Player player, GameData gameData)
    {
        DeviceView currentDevice = GetDeviceForPlayer(player);

        if (currentDevice != null)
        {
            currentDevice.SetCurrentGame(gameData);
            gameData.OnPlayerExitsGame += PlayerExitsGame;
        }
    }
Esempio n. 9
0
    private void RemoveClient(NetworkConnection conn)
    {
        DeviceView device = ConnectedDevices.First(x => x.player.Connection == conn);

        if (device != null)
        {
            ConnectedDevices.Remove(device);
            Destroy(device.gameObject);
        }
    }
Esempio n. 10
0
        protected override void RenderBody()
        {
            foreach (var device in Model)
            {
                var view = new DeviceView(device);
                MainContent.Controls.Add(view);
            }

            MainContent.Dock = DockStyle.Fill;
        }
Esempio n. 11
0
        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);
        }
Esempio n. 13
0
        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();
        }
Esempio n. 14
0
        public DeviceViewControler(Form frm, DeviceView deviceView, GCDeviceManager deviceMgt)
            : base(frm)
        {
            _deviceView    = deviceView;
            _deviceManager = deviceMgt;
            if (_deviceManager == null ||
                deviceView == null)
            {
                throw (new ArgumentNullException());
            }

            Initialize();
        }
Esempio n. 15
0
    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);
    }
Esempio n. 16
0
        //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;
    }
Esempio n. 18
0
 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);
 }
Esempio n. 19
0
        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();
        }
Esempio n. 20
0
        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"
                }));
            }
        }
Esempio n. 21
0
        /// <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);
            }
Esempio n. 22
0
    //********************************//
    //*********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);
    }
Esempio n. 23
0
        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);
        }
Esempio n. 24
0
        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"
                }));
            }
        }
Esempio n. 25
0
        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);
        }
Esempio n. 26
0
        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 = "輸入錯誤!";
            }
        }
Esempio n. 27
0
        /// <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);
                }
            }
Esempio n. 28
0
        /// <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;
                }
            }
Esempio n. 29
0
        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);
            }
        }
Esempio n. 30
0
 public TorsoSensor(DeviceView deviceView) : base(deviceView)
 {
     chest = new TargetData();
     spine = new TargetData();
     hips  = new TargetData();
 }