public void Activate(DeviceConfiguration config)
 {
     pointCloudImage.Init(config);
     if (!pointCloudImage.IsRenderingActive)
     {
         pointCloudImage.StartRendering();
     }
     pointCloudImage.Visibility = System.Windows.Visibility.Visible;
 }
예제 #2
0
        public void AddConfiguration(DeviceConfiguration config)
        {
            //TODO: transfer DeviceConfiguration to Configuration
            var configEntity = new Configuration();
            configEntity.ConfigurationJson = DateTime.Now.Ticks.ToString();
            configEntity.ExaminationId = DateTime.Now.Ticks;

            SaveOrUpdate(configEntity);
        }
        public async Task Save(DeviceConfiguration deviceConfiguration)
        {
            var file = (IStorageFile) await storageFolder.TryGetItemAsync(filename);

            if(file == null)
            {
                file = await storageFolder.CreateFileAsync(filename);
            }

            var configString = JsonConvert.SerializeObject(deviceConfiguration);
            await FileIO.WriteTextAsync(file, configString);
        }
예제 #4
0
        public void SaveConfiguration()
        {
            var config1 = new DeviceConfiguration();
            var config2 = new DeviceConfiguration();

            var trans = _session.BeginTransaction();

            _examinationsDal.AddConfiguration(config1);
            _examinationsDal.AddConfiguration(config2);

            trans.Commit();
        }
예제 #5
0
        public void GetConfigByExamId_Success()
        {
            var config1 = new DeviceConfiguration();
            var config2 = new DeviceConfiguration();

            var trans = _session.BeginTransaction();

            _examinationsDal.AddConfiguration(config1);
            _examinationsDal.AddConfiguration(config2);

            trans.Commit();

            var result = _examinationsDal.GetDeviceConfigurationByExaminationId(0);
        }
        protected void DisplayDeviceCongifuration()
        {
            DeviceConfiguration currentDeviceConfiguration;
            History             currentHistoryNote;

            // Initializing selected in SuperUserWindow list Device state
            try
            {
                currentDeviceConfiguration =
                    DeviceConfiguration.
                    GetDeviceConfiguration(
                        SelectedDevice
                        );

                // Defining which IP do device have
                for (int i = 0; i < ipAddressBox.Items.Count; i++)
                {
                    if ((ipAddressBox.Items[i] as IPAddress).ID ==
                        currentDeviceConfiguration.IP.ID)
                    {
                        ipAddressBox.SelectedIndex = i;
                    }
                }

                // Displaying device password in passwordTextBox
                passwordBox.Text =
                    currentDeviceConfiguration.
                    AccountPassword;
                // Same for account name
                accoutNameBox.Text = currentDeviceConfiguration.AccountName;
            }
            catch (NoSuchDataException) { }

            try
            {
                currentHistoryNote = History.GetDeviceLastHistoryNote(SelectedDevice);

                // Setting device's Corps
                for (int i = 0; i < corpsBox.Items.Count; i++)
                {
                    if ((corpsBox.Items[i] as Corps).ID == currentHistoryNote.CorpsID)
                    {
                        corpsBox.SelectedIndex = i;
                    }
                }
            }
            catch (NoSuchDataException) { }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="AndroidDevice"/> class.
        /// </summary>
        /// <param name="configuration">Device Configuration</param>
        public AndroidDevice(DeviceConfiguration configuration)
        {
            Configuration = configuration;
            var server = new UiAutomatorServer(new Terminal(configuration), configuration.Port, configuration.DumpTimeout);

            Adb = new AdbService(new Terminal(configuration));
            Ui  = new UiService(
                new ScreenDumper(server, configuration.DumpTries),
                new NodeParser(),
                new NodeFinder());
            Settings    = new SettingsService();
            Activity    = new ActivityService();
            Interaction = new InteractionService(server);
            SetOwner();
            InstallHelperApks();
        }
예제 #8
0
 /// <summary>
 /// Most pcap configuration functions have the signature int pcap_set_foo(pcap_t, int)
 /// This is a helper method to use them and detect/report errors
 /// </summary>
 /// <param name="configuration"></param>
 /// <param name="setter"></param>
 /// <param name="property"></param>
 /// <param name="value"></param>
 protected void Configure(
     DeviceConfiguration configuration,
     string property,
     Func <IntPtr, int, int> setter,
     int?value
     )
 {
     if (value.HasValue)
     {
         var retval = setter(PcapHandle, value.Value);
         if (retval != 0)
         {
             configuration.RaiseConfigurationFailed(property, retval);
         }
     }
 }
            /// <summary>
            /// Simple, non-critical maintenance task assigned to the shift closing event.
            /// </summary>
            /// <param name="requestContext">The request context.</param>
            private void PurgeSalesTransactionData(RequestContext requestContext)
            {
                if (requestContext == null || requestContext.Runtime == null)
                {
                    return;
                }

                // Get retention period in days from device configuration
                Terminal            terminal            = requestContext.GetTerminal();
                DeviceConfiguration deviceConfiguration = requestContext.GetDeviceConfiguration();

                // Purge transactions
                PurgeSalesTransactionsDataRequest dataServiceRequest = new PurgeSalesTransactionsDataRequest(terminal.ChannelId, terminal.TerminalId, deviceConfiguration.RetentionDays);

                requestContext.Runtime.Execute <NullResponse>(dataServiceRequest, this.Context);
            }
        public void UpdateMotionFrame(DeviceConfiguration config, MotionFrame frame)
        {
            if (!Dispatcher.CheckAccess())
            {
                Dispatcher.BeginInvoke((Action) delegate
                {
                    UpdateMotionFrame(config, frame);
                });
                return;
            }

            sensorImage.ProcessDepthFrame(frame.DepthFrame);
            depthImage.Source    = sensorImage.DepthImageSource;
            rgbImage.Source      = frame.RGBFrame.AsRgbBitmapSource();
            skeletonImage.Source = frame.Skeletons.AsSkeletonBitmapSource(frame.DepthFrame.Width, frame.DepthFrame.Height);
        }
        public void UpdateMotionFrame(DeviceConfiguration config, MotionFrame frame)
        {
            if (!Dispatcher.CheckAccess())
            {
                Dispatcher.BeginInvoke((Action)delegate
                {
                    UpdateMotionFrame(config, frame);
                });
                return;
            }

            sensorImage.ProcessDepthFrame(frame.DepthFrame);
            depthImage.Source = sensorImage.DepthImageSource;
            rgbImage.Source = frame.RGBFrame.AsRgbBitmapSource();
            skeletonImage.Source = frame.Skeletons.AsSkeletonBitmapSource(frame.DepthFrame.Width, frame.DepthFrame.Height);
        }
예제 #12
0
 /// <summary>
 /// Most pcap configuration functions have the signature int pcap_set_foo(pcap_t, int)
 /// those functions also set the error buffer, so we read it
 /// This is a helper method to use them and detect/report errors
 /// </summary>
 /// <param name="configuration"></param>
 /// <param name="setter"></param>
 /// <param name="property"></param>
 /// <param name="value"></param>
 protected void Configure(
     DeviceConfiguration configuration,
     string property,
     Func <PcapHandle, int, PcapError> setter,
     int?value
     )
 {
     if (value.HasValue)
     {
         var retval = setter(Handle, value.Value);
         if (retval != 0)
         {
             configuration.RaiseConfigurationFailed(property, retval, GetLastError(Handle));
         }
     }
 }
예제 #13
0
        /// <summary>
        /// Open the device. To start capturing call the 'StartCapture' function
        /// </summary>
        /// <param name="configuration">
        /// A <see cref="DeviceConfiguration"/>
        /// </param>
        public virtual void Open(DeviceConfiguration configuration)
        {
            // Caches linkType value.
            // Open refers to the device being "created"
            // This method is called by sub-classes in the override method
            int dataLink = 0;

            if (Opened)
            {
                dataLink = LibPcapSafeNativeMethods.pcap_datalink(Handle);
            }
            if (dataLink >= 0)
            {
                linkType = (PacketDotNet.LinkLayers)dataLink;
            }
        }
        public async Task <SparkDeviceOperationState> RequestCurrentState(DeviceConfiguration deviceConfig)
        {
            ParticleDevice device = await LoginAndGetParticleDevice(deviceConfig);

            ParticleVariableResponse currentStateResult = await device.GetVariableAsync(SPARKVARIABLE_CURRENTSTATE);

            try
            {
                SparkDeviceOperationState operationState = (SparkDeviceOperationState)int.Parse(currentStateResult.Result);
                return(operationState);
            }
            catch (Exception e)
            {
                throw new InvalidOperationException("Enum value not supported for SparkDeviceOperationState");
            }
        }
예제 #15
0
        private async void Page_Loaded(object sender, RoutedEventArgs e)
        {
            deviceConfigurationRepo = new LocalDeviceConfigurationRepo();
            deviceConfiguration     = await deviceConfigurationRepo.Get();

            if (deviceConfiguration == null)
            {
                deviceConfiguration = new DeviceConfiguration();
            }
            else
            {
                ToggleMenu();
                Address.Text = deviceConfiguration.DefaulUrl;
                MyWebView.Navigate(new Uri(deviceConfiguration.DefaulUrl));
            }
        }
예제 #16
0
        private void RunRequests(DeviceConfiguration config)
        {
            var ac = config.Agent;

            if (ac != null)
            {
                // Run a Probe request and get the returned data
                if (probeData == null)
                {
                    probeData = GetProbe(ac);

                    // Send the Probe data to other plugins
                    SendProbeData(probeData, config);
                }

                if (probeData != null)
                {
                    // Run a Current request and get the returned data
                    currentData = GetCurrent(ac);
                    if (currentData != null && currentData.Header != null)
                    {
                        // Send the Current data to other plugins
                        SendCurrentData(currentData, config);

                        //Run a Sample request and get the returned data
                        var sampleData = GetSample(currentData.Header, ac, config);

                        //Send the Sample data to other plugins
                        if (sampleData != null)
                        {
                            SendSampleData(sampleData, config);
                        }

                        UpdateAgentData(currentData.Header.InstanceId, currentData.Header.LastSequence);
                    }
                    else
                    {
                        probeData = null;
                        SendAvailability(false, ac.Heartbeat, config);
                    }
                }
                else
                {
                    SendAvailability(false, ac.Heartbeat, config);
                }
            }
        }
예제 #17
0
        private static Image CreateTestDepthImage(DeviceConfiguration config, Microseconds64 colorTimestamp)
        {
            if (!config.DepthMode.HasDepth())
            {
                return(null);
            }

            var width  = config.DepthMode.WidthPixels();
            var height = config.DepthMode.HeightPixels();
            var buffer = new short[width * height];

            var image = Image.CreateFromArray(buffer, ImageFormat.Depth16, width, height);

            image.DeviceTimestamp = colorTimestamp + config.DepthDelayOffColor;

            return(image);
        }
예제 #18
0
        public void UpdateMotionFrame(DeviceConfiguration config, MotionFrame frame)
        {
            if (!Dispatcher.CheckAccess())
            {
                Dispatcher.BeginInvoke((Action) delegate
                {
                    UpdateMotionFrame(config, frame);
                });
                return;
            }

            if (!pointCloudImage.IsInitialized)
            {
                Activate(config);
            }
            pointCloudImage.SetMotionFrame(frame);
        }
예제 #19
0
        private void LoadLocalDevices()
        {
            var deviceConfigs = DeviceConfiguration.ReadAll(FileLocations.Devices);

            if (deviceConfigs != null)
            {
                foreach (var deviceConfig in deviceConfigs)
                {
                    if (deviceConfig.Description != null)
                    {
                        AddDevice(new DeviceDescription(deviceConfig));
                    }
                }
            }

            SendDevicesLoadedMessage();
        }
예제 #20
0
        public T CreateDeviceInstance <T>(DeviceConfiguration configuration) where T : IDevice
        {
            Type deviceType = typeof(T);

            switch (deviceType.Name)
            {
            case nameof(FilterWheel):
                IDevice device = new FilterWheel(configuration, _clientTransactionIdGenerator);
                return((T)device);

            case nameof(SafetyMonitor):
                IDevice safetyMonitor = new SafetyMonitor(configuration, _clientTransactionIdGenerator);
                return((T)safetyMonitor);

            case nameof(Dome):
                IDevice dome = new Dome(configuration, _clientTransactionIdGenerator);
                return((T)dome);

            case nameof(Camera):
                IDevice camera = new Camera(configuration, _clientTransactionIdGenerator);
                return((T)camera);

            case nameof(Focuser):
                IDevice focuser = new Focuser(configuration, _clientTransactionIdGenerator);
                return((T)focuser);

            case nameof(ObservingConditions):
                IDevice observingConditions = new ObservingConditions(configuration, _clientTransactionIdGenerator);
                return((T)observingConditions);

            case nameof(Rotator):
                IDevice rotator = new Rotator(configuration, _clientTransactionIdGenerator);
                return((T)rotator);

            case nameof(Switch):
                IDevice @switch = new Switch(configuration, _clientTransactionIdGenerator);
                return((T)@switch);

            case nameof(Telescope):
                IDevice telescope = new Telescope(configuration, _clientTransactionIdGenerator);
                return((T)telescope);

            default:
                throw new InvalidOperationException($"Type {deviceType.Name} is not supported");
            }
        }
        private static void AddCaptureItems(string prefix, DataTable table, List <DataItem> dataItems)
        {
            string capturePrefix = prefix + "/Capture";

            var item = dataItems.Find(x => x.Category == DataItemCategory.EVENT && x.Type == "PROGRAM");

            if (item != null)
            {
                DeviceConfiguration.EditTable(table, capturePrefix + "/Item||00", null, "id||00;name||program_name;link||" + item.Id + ";");
            }

            item = dataItems.Find(x => x.Category == DataItemCategory.EVENT && x.Type == "EXECUTION");
            if (item != null)
            {
                DeviceConfiguration.EditTable(table, capturePrefix + "/Item||01", null, "id||01;name||execution_mode;link||" + item.Id + ";");
            }
        }
예제 #22
0
        public ConfigDialog(DeviceConfiguration deviceConfiguration)
        {
            this.InitializeComponent();

            this.comboBoxCameraImageUrl.DataSource = new string[]
            {
                "/jpg/image.jpg",          //Axis
                "/snapshot/1/snapshot.jpg" //Eneo
            };

            this.comboBoxPanTiltControl.DataSource = ((PanTiltControlType[])Enum.GetValues(typeof(PanTiltControlType))).OrderBy(x => x.ToString()).ToList();
            this.comboBoxComType.DataSource        = ((CommunicationType[])Enum.GetValues(typeof(CommunicationType))).OrderBy(x => x.ToString()).ToList();
            this.comboBoxPort.DataSource           = SerialPort.GetPortNames();

            if (deviceConfiguration == null)
            {
                this.DeviceConfiguration = new DeviceConfiguration();
            }
            else
            {
                this.DeviceConfiguration = deviceConfiguration;
                this.comboBoxPanTiltControl.SelectedItem = this.DeviceConfiguration.PanTiltControlType;
                this.comboBoxComType.SelectedItem        = this.DeviceConfiguration.CommunicationType;
                this.textBoxPanTilt.Text          = this.DeviceConfiguration.PanTiltIpAddress;
                this.comboBoxPort.Text            = this.DeviceConfiguration.ComPort;
                this.checkBoxCameraActive.Checked = this.DeviceConfiguration.CameraActive;
                this.textBoxCameraIpAddress.Text  = this.DeviceConfiguration.CameraIpAddress;
                this.comboBoxCameraImageUrl.Text  = this.DeviceConfiguration.CameraJpegUrl;
                this.textBoxCameraIpAddress.Text  = this.DeviceConfiguration.CameraIpAddress;
            }

            #region Discover devices

            this.comboBoxDiscoverd.DisplayMember = "Name";
            this.comboBoxDiscoverd.ValueMember   = "IpAddress";
            var discoveredDevices = new List <DiscoveredDevice>
            {
                new DiscoveredDevice {
                    Manufacturer = "Discover network ..."
                }
            };
            this.comboBoxDiscoverd.DataSource = discoveredDevices;
            _ = Task.Run(async() => await this.DiscoverDevicesAsync());

            #endregion
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="AndroidDevice"/> class.
 /// </summary>
 /// <param name="configuration">Device Configuration</param>
 /// <param name="adbService">Service to handle communication with adb</param>
 /// <param name="uiService">Service to handle UI</param>
 /// <param name="settingsService">Service to handle settings</param>
 /// <param name="activityService">Service to handle activities</param>
 /// <param name="interactionService">Service to handle interaction with the device</param>
 public AndroidDevice(
     DeviceConfiguration configuration,
     IAdbService adbService,
     IUiService uiService,
     ISettingsService settingsService,
     IActivityService activityService,
     IInteractionService interactionService)
 {
     Configuration = configuration;
     Adb           = adbService;
     Ui            = uiService;
     Settings      = settingsService;
     Activity      = activityService;
     Interaction   = interactionService;
     SetOwner();
     InstallHelperApks();
 }
예제 #24
0
        // Example URL (GET)
        // -----------------------------------------------------

        // ../api/devices/get?token=01234&sender_id=56789                     (Get all devices for the user)
        // OR
        // ../api/devices/get?token=01234&sender_id=56789&unique_id=ABCDEFG   (Get only the device with the specified 'unique_id')

        // -----------------------------------------------------

        // Example Post Data
        // -----------------------------------------------------

        // name = 'token'
        // value = 01234 (Session Token)

        // name = 'sender_id'
        // value = 56789 (Sender ID)

        // (Optional)
        // name = 'devices'
        // value =  [
        //	{ "unique_id": "ABCDEFG" },
        //  { "unique_id": "HIJKLMN" }
        //	]
        // -----------------------------------------------------

        /// <summary>
        /// Get a single DeviceConfiguration
        /// </summary>
        /// <param name="userConfig">UserConfiguration object for the current user</param>
        /// <param name="deviceUniqueId">The Unique ID of the device to return</param>
        /// <returns></returns>
        public static DeviceConfiguration Get(UserConfiguration userConfig, string deviceUniqueId)
        {
            if (!string.IsNullOrEmpty(deviceUniqueId))
            {
                Uri apiHost = ApiConfiguration.AuthenticationApiHost;

                string url = new Uri(apiHost, "devices/get/index.php").ToString();

                string format = "{0}?token={1}&sender_id={2}&unique_id={3}";

                string token    = userConfig.SessionToken;
                string senderId = UserManagement.SenderId.Get();

                url = string.Format(format, url, token, senderId, deviceUniqueId);

                string response = HTTP.GET(url);
                if (response != null)
                {
                    bool success = ApiError.ProcessResponse(response, "Get Devices");
                    if (success)
                    {
                        var deviceInfos = JSON.ToType <List <DeviceInfo> >(response);
                        if (deviceInfos != null && deviceInfos.Count > 0)
                        {
                            var deviceInfo = deviceInfos[0];

                            var table = deviceInfo.ToTable();
                            if (table != null)
                            {
                                var xml = DeviceConfiguration.TableToXml(table);
                                if (xml != null)
                                {
                                    var deviceConfig = DeviceConfiguration.Read(xml);
                                    if (deviceConfig != null && !string.IsNullOrEmpty(deviceConfig.UniqueId))
                                    {
                                        return(deviceConfig);
                                    }
                                }
                            }
                        }
                    }
                }
            }

            return(null);
        }
예제 #25
0
        public static void SaveDeviceConfig(string connString, DeviceConfiguration config)
        {
            MySqlConnection conn = null;

            conn = OpenConnection(connString);
            var          query = "UPDATE device_config SET configuration=@Configuration WHERE device_id=@DeviceId";
            MySqlCommand cmd   = new MySqlCommand(query, conn);

            cmd.Parameters.AddWithValue("@DeviceId", config.DeviceId);
            cmd.Parameters.AddWithValue("@Configuration", JsonConvert.SerializeObject(config));
            cmd.ExecuteNonQuery();

            if (conn != null && conn.State == ConnectionState.Open)
            {
                conn.Close();
            }
        }
        public void UpdateMotionFrame(DeviceConfiguration config, MotionFrame frame)
        {
            if (!Dispatcher.CheckAccess())
            {
                Dispatcher.BeginInvoke((Action)delegate
                {
                    UpdateMotionFrame(config, frame);
                });
                return;
            }

            if (!pointCloudImage.IsInitialized)
            {
                Activate(config);
            }
            pointCloudImage.SetMotionFrame(frame);
        }
예제 #27
0
        public void Initialize(DeviceConfiguration config)
        {
            configuration = config;

            var agentData = AgentData.Load(config);

            if (agentData != null)
            {
                agentInstanceId     = agentData.InstanceId;
                lastInstanceId      = agentData.InstanceId;
                lastSequenceSampled = agentData.LastSequence;

                System.Console.WriteLine(config.UniqueId + " :: " + agentInstanceId + " : " + lastSequenceSampled);
            }

            Start(config);
        }
예제 #28
0
        public void NonCompatibleModes()
        {
            using var device = GetPcapDevice();

            var config = new DeviceConfiguration
            {
                Mode       = DeviceModes.NoCaptureLocal,
                BufferSize = 128 * 1024,
            };

            var ex = Assert.Throws <PcapException>(() => device.Open(config));

            if (ex.Error != PcapError.PlatformNotSupported)
            {
                StringAssert.Contains(nameof(DeviceConfiguration.BufferSize), ex.Message);
            }
        }
        public bool OpenSensor(int deviceIndex = 0)
        {
            _KinectSensor = Device.Open(deviceIndex);
            if (_KinectSensor == null)
            {
                Debug.LogError("AzureKinect cannot be opened.");
                return(false);
            }

            DeviceConfiguration kinectConfig = new DeviceConfiguration();

            kinectConfig.ColorFormat     = _ColorImageFormat;
            kinectConfig.ColorResolution = (ColorResolution)_ColorCameraMode;
            kinectConfig.DepthMode       = (DepthMode)_DepthCameraMode;

            if (_ColorCameraMode != ColorCameraMode._4096_x_3072_15fps &&
                _DepthCameraMode != DepthCameraMode._1024x1024_15fps)
            {
                kinectConfig.CameraFPS = FPS.FPS30;
            }
            else
            {
                kinectConfig.CameraFPS = FPS.FPS15;
            }

            _KinectSensor.StartCameras(kinectConfig);
            _IsCameraStarted = true;

            _KinectSensor.StartImu();

            _DeviceCalibration = _KinectSensor.GetCalibration();
            _Transformation    = _DeviceCalibration.CreateTransformation();

            CameraCalibration colorCamera = _DeviceCalibration.ColorCameraCalibration;

            _ColorImageWidth  = colorCamera.ResolutionWidth;
            _ColorImageHeight = colorCamera.ResolutionHeight;

            CameraCalibration depthCamera = _DeviceCalibration.DepthCameraCalibration;

            _DepthImageWidth  = depthCamera.ResolutionWidth;
            _DepthImageHeight = depthCamera.ResolutionHeight;

            return(true);
        }
예제 #30
0
        public void TestAttachments()
        {
            var mkvPath = GenerateTempMkvFilePath();

            var config = new DeviceConfiguration
            {
                CameraFps       = FrameRate.Fifteen,
                ColorFormat     = ImageFormat.ColorNV12,
                ColorResolution = ColorResolution.R720p,
                DepthMode       = DepthMode.NarrowView2x2Binned,
            };

            var deviceTimestamp0 = Microseconds64.FromMilliseconds(1.0);
            var deviceTimestamp1 = Microseconds64.FromMilliseconds(7.7);

            var attachment1Name = "\ud182\ud0b5\ud181\ud182 \ud0ba\ud0be\ud0b4\ud0b8\ud180\ud0be\ud0b2\ud0ba\ud0b8";
            var attachment1Data = new byte[] { 1, 255, 0, 8, 7, 254, 128, 3, 127, 65, 179 };

            var attachment2Name = "another_attachment.file";
            var attachment2Data = new byte[] { 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200, 210, 220, 230, 240, 250 };

            using (var recorder = new Recorder(mkvPath, null, config))
            {
                recorder.AddAttachment(attachment1Name, attachment1Data);
                recorder.AddAttachment(attachment2Name, attachment2Data);

                recorder.WriteHeader();

                WriteTestCaptures(recorder, deviceTimestamp0, deviceTimestamp1);
            }

            using (var playback = new Playback(mkvPath))
            {
                Assert.IsTrue(playback.TryGetAttachment(attachment1Name, out var data1));
                AssertAreEqual(attachment1Data, data1);

                Assert.IsTrue(playback.TryGetAttachment(attachment2Name, out var data2));
                AssertAreEqual(attachment2Data, data2);

                Assert.IsFalse(playback.TryGetAttachment("some_unknown_attachment_name", out var tmp));
                Assert.IsNull(tmp);
            }

            File.Delete(mkvPath);
        }
예제 #31
0
        private void Device_MessageReceived(object sender, MrsMessage e)
        {
            Device dvc = (Device)sender;

            Console.WriteLine($"{e.MrsMessageType} received from {dvc.DeviceIP}:{dvc.DevicePort}");
            switch (e.MrsMessageType)
            {
            case MrsMessageTypes.DeviceConfiguration:
                // save config
                _deviceConfiguration = (DeviceConfiguration)e;
                // override ip and port
                _deviceConfiguration.NotificationServiceIPAddress = _configuration.ListenIP;
                _deviceConfiguration.NotificationServicePort      = _configuration.ListenPort.ToString();
                break;

            case MrsMessageTypes.DeviceStatusReport:
                // save status
                // if status contain already values - update
                _statusReport =
                    (DeviceStatusReport)(_statusReport == null
                            ? e
                            : _statusReport.UpdateValues(e));
                if (_sensor == null)
                {
                    // now that we have config and status, start the sensor (listening side)
                    _sensor = new Sensor(_deviceConfiguration, _statusReport)
                    {
                        ValidateMessages = false
                    };
                    _sensor.MessageSent            += Sensor_MessageSent;
                    _sensor.MessageReceived        += Sensor_MessageReceived;
                    _sensor.ValidationErrorOccured += Sensor_ValidationErrorOccured;
                    Console.WriteLine("Starting sensor...");
                    _sensor.Start();
                    Console.WriteLine($"Sensor started on {_sensor.IP}:{_sensor.Port}");
                }

                break;

            case MrsMessageTypes.DeviceIndicationReport:
                var indicationReport = (DeviceIndicationReport)e;
                _sensor?.RegisterIndications(ExtractIndications(indicationReport));
                break;
            }
        }
예제 #32
0
        private static bool ScanWeekendPoints(DeviceConfiguration config, ref float tempTarget)
        {
            DateTime now = DateTime.Now;

            foreach (var point in config.WeekendPoints)
            {
                if (point.IsSaturday && now.DayOfWeek == DayOfWeek.Saturday || point.IsSunday && now.DayOfWeek == DayOfWeek.Sunday)
                {
                    if ((now.Hour * 100 + now.Minute >= point.StartHour * 100 + point.StartMinute) && (now.Hour * 100 + now.Minute <= point.EndHour * 100 + point.EndMinute))
                    {
                        tempTarget = point.Temperature;
                        return(true);
                    }
                }
            }

            return(false);
        }
예제 #33
0
        private static int GetBuiltInTrackCount(DeviceConfiguration config)
        {
            var count = 0;

            if (config.ColorResolution != ColorResolution.Off)
            {
                count++;
            }
            if (config.DepthMode.HasDepth())
            {
                count++;
            }
            if (config.DepthMode.HasPassiveIR())
            {
                count++;
            }
            return(count);
        }
예제 #34
0
        public string GetSegmentEnd(DeviceConfiguration config)
        {
            //var sc = TrakHound.Server.Plugins.Shifts.ShiftConfiguration.Get(config);
            //if (sc != null)
            //{
            //    var shift = sc.shifts.Find(x => x.id == Shift);
            //    if (shift != null)
            //    {
            //        var segment = shift.segments.Find(x => x.id == Segment);
            //        if (segment != null)
            //        {
            //            return segment.endTime.To24HourString();
            //        }
            //    }
            //}

            return(null);
        }
예제 #35
0
        public bool TryCreateDevice(string id, DeviceConfiguration deviceConfiguration, out IDevice device)
        {
            switch (deviceConfiguration.Driver.Type)
            {
            case "Outpost.LpdBridge":
            {
                return(CreateGetLpdBridgeAdapter(id, deviceConfiguration, out device));
            }

            case "I2CHardwareBridge":
            {
                return(CreateI2CHardwareBridge(id, deviceConfiguration, out device));
            }
            }

            device = null;
            return(false);
        }
        public DeviceSetup Update(DeviceSetup deviceSetup)
        {
            DeviceConfiguration existingConfiguration = GetSingle(deviceSetup.Id);

            if (existingConfiguration != null)
            {
                _dbContext.Update(existingConfiguration);

                existingConfiguration.PollingEnabled          = deviceSetup.PollingEnabled;
                existingConfiguration.PostBackIntervalMinutes = deviceSetup.PostBackIntervalMinutes;
                existingConfiguration.PostBackUrl             = deviceSetup.PostBackUrl;
                existingConfiguration.PostBackPort            = deviceSetup.PostBackPort;

                _dbContext.SaveChanges();
            }

            return(existingConfiguration);
        }
예제 #37
0
        private static Image CreateTestColorImage(DeviceConfiguration config, Microseconds64 colorTimestamp)
        {
            if (config.ColorResolution == ColorResolution.Off)
            {
                return(null);
            }

            var width  = config.ColorResolution.WidthPixels();
            var height = config.ColorResolution.HeightPixels();
            var stride = config.ColorFormat.StrideBytes(width);
            var buffer = new byte[config.ColorFormat.ImageSizeBytes(stride, height)];

            var image = Image.CreateFromArray(buffer, config.ColorFormat, width, height);

            image.DeviceTimestamp = colorTimestamp;

            return(image);
        }
 private void UpdateFrameViewer(MotionFrame frame)
 {
     if (pointCloudFrameViewer != null)
     {
         currentConfiguration = new DeviceConfiguration()
             {
                 DepthBufferFormat = new BufferFormat(frame.DepthFrame.Width, frame.DepthFrame.Height, frame.DepthFrame.PixelFormat),
                 VideoBufferFormat = new BufferFormat(frame.RGBFrame.Width, frame.RGBFrame.Height, frame.RGBFrame.PixelFormat),
             };
         pointCloudFrameViewer.UpdateMotionFrame(currentConfiguration, frame);
     }
 }
        private void InitConfiguration()
        {
            var config = new DeviceConfiguration();
            config.DepthBufferFormat = DepthBufferFormats.Format320X240X16;
            config.VideoBufferFormat = ImageBufferFormats.Format1280X960X32;

            //config.DepthBufferFormat = DepthBufferFormats.Format640X480X16;
            //config.VideoBufferFormat = ImageBufferFormats.Format1280X960X32;
            currentConfiguration = config;
        }
예제 #40
0
 public static DeviceConfiguration CreateDeviceConfiguration(string objectId, global::System.Collections.ObjectModel.Collection<byte[]> publicIssuerCertificates, global::System.Collections.ObjectModel.Collection<byte[]> cloudPublicIssuerCertificates)
 {
     DeviceConfiguration deviceConfiguration = new DeviceConfiguration();
     deviceConfiguration.objectId = objectId;
     if ((publicIssuerCertificates == null))
     {
         throw new global::System.ArgumentNullException("publicIssuerCertificates");
     }
     deviceConfiguration.publicIssuerCertificates = publicIssuerCertificates;
     if ((cloudPublicIssuerCertificates == null))
     {
         throw new global::System.ArgumentNullException("cloudPublicIssuerCertificates");
     }
     deviceConfiguration.cloudPublicIssuerCertificates = cloudPublicIssuerCertificates;
     return deviceConfiguration;
 }
 private void InitSensor()
 {
     sensorDevice = new KinectSdkDevice();
     var config = new DeviceConfiguration();
     config.DepthBufferFormat = DepthBufferFormats.Format320X240X16;
     config.VideoBufferFormat = ImageBufferFormats.Format640X480X32;
     sensorDevice.Initialize(config);
     sensorDevice.SetTiltAngle(0);
     sensorDevice.CompositeFrameAvailable += new CompositeFrameAvailableEventHandler(device_CompositeFrameAvailable);
 }
 public void Activate(DeviceConfiguration config)
 {
     imageContext = new ImageProcessorContext();
     sensorImage = new SensorImageProcessor(imageContext);
 }