Ejemplo n.º 1
0
        public void TryFindDeviceVersionId()
        {
            int             goodDeviceId          = 1;
            int             badDeviceId           = int.MaxValue;
            SemanticVersion inside1stBlockVersion = SemanticVersion.Parse("3.0.0");
            SemanticVersion inside2ndBlockVersion = SemanticVersion.Parse("100.43.0");
            SemanticVersion outsideAllVersion     = SemanticVersion.Parse("10.43.0");

            using (var context = new DeviceDatabaseContext(this.database))
            {
                DeviceVersion foundDeviceVersion = null;

                Assert.IsTrue(context.TryFindDeviceVersionId(goodDeviceId, inside1stBlockVersion, out foundDeviceVersion), $"Cannot find 'good' device-version ID for device '{goodDeviceId}', inside-block-1 version {inside1stBlockVersion}");
                Assert.AreEqual(1, foundDeviceVersion, $"Wrong device-version ID found for 'good' device ID '{goodDeviceId}', inside-block-1 version {inside1stBlockVersion}");

                Assert.IsTrue(context.TryFindDeviceVersionId(goodDeviceId, inside2ndBlockVersion, out foundDeviceVersion), $"Cannot find 'good' device-version ID for device '{goodDeviceId}', inside-block-2 version {inside2ndBlockVersion}");
                Assert.AreEqual(2, foundDeviceVersion, $"Wrong device-version ID found for 'good' device ID '{goodDeviceId}', inside-block-2 version {inside2ndBlockVersion}");

                Assert.IsFalse(context.TryFindDeviceVersionId(goodDeviceId, outsideAllVersion, out foundDeviceVersion), $"Found 'good' device-version ID for device '{goodDeviceId}' using version outside all blocks.");

                Assert.IsTrue(context.TryFindDeviceVersionId(goodDeviceId, null, out foundDeviceVersion), $"Cannot find 'good' device-version ID for device '{goodDeviceId}', null version (i.e. highest available minimum version)");
                Assert.AreEqual(2, foundDeviceVersion, $"Wrong device-version ID found for 'good' device ID '{goodDeviceId}', null version (i.e. highest available minimum version)");

                Assert.IsFalse(context.TryFindDeviceVersionId(badDeviceId, null, out foundDeviceVersion), $"Found 'bad' device ID '{badDeviceId}'");
            }
        }
Ejemplo n.º 2
0
 public void CopyTo(DeviceVersion deviceVersion)
 {
     deviceVersion.ApplicationNumber  = ApplicationNumber;
     deviceVersion.ApplicationVersion = ApplicationVersion;
     deviceVersion.HardwareVersion    = HardwareVersion;
     deviceVersion.SoftwareVersion    = SoftwareVersion;
 }
Ejemplo n.º 3
0
        public async Task <DeviceDescriptionPayload> Download(string channelId, DeviceVersion deviceVersion)
        {
            DeviceDescriptionPayload result = null;

            try
            {
                var query = HttpUtility.ParseQueryString(string.Empty);

                query["callerId"]           = channelId;
                query["hardwareVersion"]    = $"{deviceVersion.HardwareVersion}";
                query["softwareVersion"]    = $"{deviceVersion.SoftwareVersion}";
                query["applicationNumber"]  = $"{deviceVersion.ApplicationNumber}";
                query["applicationVersion"] = $"{deviceVersion.ApplicationVersion}";

                var url = UrlHelper.BuildUrl(Url, "api/description/download", query);

                var json = await Transporter.Get(_identity, url);

                if (!string.IsNullOrEmpty(json))
                {
                    result = json.TryDeserializeObject <DeviceDescriptionPayload>();

                    if (result != null)
                    {
                        result.Version = deviceVersion;
                    }
                }
            }
            catch (Exception e)
            {
                MsgLogger.Exception($"{GetType().Name} - Download", e);
            }

            return(result);
        }
Ejemplo n.º 4
0
        public async Task <DeviceVersion> When(HeartbeatReceived command)
        {
            var heartbeat = command.Heartbeat;

            // Create domain model for the device associated with the current context and
            // record the received heartbeat information.
            var deviceStatus = DeviceStatus.ForExistingDevice(command.DeviceId,
                                                              status => status.RecordHeartbeat(
                                                                  heartbeat.State,
                                                                  heartbeat.UptimeSeconds,
                                                                  heartbeat.AgentVersion,
                                                                  heartbeat.ApplicationVersion,
                                                                  heartbeat.RootFileSystemVersion));

            DeviceVersion deviceVersion = null;

            using (_repoContext)
            {
                // Update the device status and return it's current configuration version.
                await _deviceRepo.UpdateDeviceStatus(deviceStatus);

                deviceVersion = await _deviceRepo.GetDeviceVersionInfo(deviceStatus.DeviceId);
            }

            _logger.LogTrace(
                "Heartbeat received for device {DeviceId}. Device has been up for {UptimeSeconds} " +
                "seconds and is using ConfigurationVersion {ConfigurationVersion} sent.",
                deviceStatus.DeviceId, deviceStatus.UptimeSeconds, deviceVersion.ConfigurationVersion);

            return(deviceVersion);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Changes the device.
        /// </summary>
        /// <param name="deviceVersion">The device version.</param>
        /// <param name="windowed">if set to <c>true</c>, the application will run in windowed mode instead of full screen.</param>
        /// <param name="desiredWidth">Desired width of the window.</param>
        /// <param name="desiredHeight">Desired height of the window.</param>
        /// <exception cref="NoCompatibleDevicesException">Thrown when the framework cannot find a suitable graphics device.</exception>
        /// <exception cref="DeviceCreationException">Thrown when device creation fails.</exception>
        public void ChangeDevice(DeviceVersion deviceVersion, bool windowed, int desiredWidth, int desiredHeight)
        {
            DeviceSettings desiredSettings = new DeviceSettings();

            desiredSettings.DeviceVersion    = deviceVersion;
            desiredSettings.Windowed         = windowed;
            desiredSettings.BackBufferWidth  = desiredWidth;
            desiredSettings.BackBufferHeight = desiredHeight;

            ChangeDevice(desiredSettings, null);
        }
Ejemplo n.º 6
0
 public void Constructor_CheckValidDeviceVerification(DeviceVersion version, DeviceOutputs outputs, bool valid)
 {
     if (valid)
     {
         _ = new Si5351(new I2cTestDevice(), version, outputs);
     }
     else
     {
         Assert.Throws <ArgumentException>(() => new Si5351(new I2cTestDevice(), version, outputs));
     }
 }
Ejemplo n.º 7
0
        void ReleaseDesignerOutlets()
        {
            if (Button != null)
            {
                Button.Dispose();
                Button = null;
            }

            if (DeviceName != null)
            {
                DeviceName.Dispose();
                DeviceName = null;
            }

            if (DeviceOS != null)
            {
                DeviceOS.Dispose();
                DeviceOS = null;
            }

            if (DeviceUID != null)
            {
                DeviceUID.Dispose();
                DeviceUID = null;
            }

            if (DeviceVersion != null)
            {
                DeviceVersion.Dispose();
                DeviceVersion = null;
            }

            if (LatitudeLabel != null)
            {
                LatitudeLabel.Dispose();
                LatitudeLabel = null;
            }

            if (LongitudeLabel != null)
            {
                LongitudeLabel.Dispose();
                LongitudeLabel = null;
            }

            if (OpenCamera != null)
            {
                OpenCamera.Dispose();
                OpenCamera = null;
            }
        }
Ejemplo n.º 8
0
        public bool Parse(XmlNode profileBodyNode)
        {
            bool result = false;

            if (profileBodyNode != null)
            {
                foreach (XmlNode childNode in profileBodyNode.ChildNodes)
                {
                    if (childNode.Name == "vendorName")
                    {
                        VendorName = childNode.InnerXml;
                    }
                    else if (childNode.Name == "deviceFamily")
                    {
                        if (!DeviceFamily.Parse(childNode))
                        {
                            result = false;
                            break;
                        }
                    }
                    else if (childNode.Name == "productFamily")
                    {
                        ProductFamily = childNode.InnerXml;
                    }
                    else if (childNode.Name == "productName")
                    {
                        ProductName = childNode.InnerXml;
                        result      = true;
                    }
                    else if (childNode.Name == "productText")
                    {
                        if (!ProductText.Parse(childNode))
                        {
                            result = false;
                            break;
                        }
                    }
                    else if (childNode.Name == "productUrl")
                    {
                        if (!ProductUrl.Parse(childNode))
                        {
                            result = false;
                            break;
                        }
                    }
                    else if (childNode.Name == "productPicture")
                    {
                        ProductPicture = childNode.InnerXml;
                    }
                    else if (childNode.Name == "orderNumber")
                    {
                        OrderNumber = childNode.InnerXml;
                    }
                    else if (childNode.Name == "version")
                    {
                        if (!DeviceVersion.Parse(childNode))
                        {
                            result = false;
                            break;
                        }
                    }
                }

                if (result)
                {
                    UpdateDeviceVersion();
                    UpdateProductName();
                    UpdateProductPicture();
                }
            }

            return(result);
        }
Ejemplo n.º 9
0
 private void UpdateDeviceVersion()
 {
     DeviceVersion.UpdateVersion();
 }
Ejemplo n.º 10
0
 public DeviceVersion_dst_adapter(DeviceVersion dst)
 {
     this.dst = dst;
 }
 public Task <DeviceDescriptionIdentity> GetDeviceDescriptionIdentity(string channelId, DeviceVersion deviceVersion)
 {
     return(DeviceAdapter.GetDeviceDescriptionIdentity(channelId, deviceVersion));
 }
 public Task <DeviceDescriptionPayload> DownloadDeviceDescription(string channelId, DeviceVersion deviceVersion)
 {
     return(DeviceAdapter.DownloadDeviceDescription(channelId, deviceVersion));
 }
Ejemplo n.º 13
0
 public static void onDeviceVersion(DeviceVersion p0)
 {
     var some_DevID = p0.DevID();
     var some_Ver   = p0.Ver();
 }