예제 #1
0
        public async Task Start(string url, DeviceTypes deviceType, string emulator)
        {
            websocket = new ClientWebSocket();
            cancellationTokenSource = new CancellationTokenSource();
            string fullUrl = $"{url}{deviceType.ToString()}/{emulator}";
            await websocket.ConnectAsync(new Uri(fullUrl), cancellationTokenSource.Token);

            ThreadCreator.Create("Device emulator", HandleWebsocket).Start();
        }
예제 #2
0
        static KegLogger()
        {
            Init();

            //KegConfig kegConfig = GlobalSettings.GetKegSetting("fdaeadba-4027-407d-bd9a-dd679c223f65").Result;

            //Telemetry
            TelemetryConfiguration teleConfig = new TelemetryConfiguration
            {
                InstrumentationKey = Constants.INSTRUMENTKEY
            };

            teleConfig.TelemetryChannel.DeveloperMode = false;
            if (Constants.INSTRUMENTKEY.Trim().Length == 0)
            {
                teleConfig.DisableTelemetry = true;
            }
            //override as needed
            // true: disable telemetry, false: enables telemetry
            teleConfig.DisableTelemetry = false;

            telemetryClient = new TelemetryClient(teleConfig);

            telemetryClient.Context.User.Id        = deviceInfo.FriendlyName;
            telemetryClient.Context.Device.Type    = _type.ToString();
            telemetryClient.Context.Device.Model   = _productName;
            telemetryClient.Context.Device.Id      = deviceInfo.Id.ToString();
            telemetryClient.Context.Device.OemName = deviceInfo.SystemManufacturer;

            //Each reboot starts a new session
            telemetryClient.Context.Session.Id = Guid.NewGuid().ToString();

            if (!ulong.TryParse(Windows.System.Profile.AnalyticsInfo.VersionInfo.DeviceFamilyVersion, out ulong version))
            {
                //var loader = new Windows.ApplicationModel.Resources.ResourceLoader();
                //OSVersion.Text = loader.GetString("OSVersionNotAvailable");
                telemetryClient.Context.Device.OperatingSystem = deviceInfo.OperatingSystem;
            }
            else
            {
                telemetryClient.Context.Device.OperatingSystem = String.Format(CultureInfo.InvariantCulture, "{4}-IoTCore v{0}.{1}.{2}.{3}",
                                                                               (version & 0xFFFF000000000000) >> 48,
                                                                               (version & 0x0000FFFF00000000) >> 32,
                                                                               (version & 0x00000000FFFF0000) >> 16,
                                                                               version & 0x000000000000FFFF,
                                                                               deviceInfo.OperatingSystem);
            }

            KegLogTrace("App Started", "KegLogger", SeverityLevel.Information, null);
        }
예제 #3
0
 public BaseData(Delay delay, DeviceTypes deviceType)
 {
     this.Delay      = delay.ToString();
     this.DeviceType = deviceType.ToString();
 }
예제 #4
0
 internal static LightSwitchCommand CreateUpdateCmd(string name, string id, string level, DeviceTypes type)
 {
     return(new LightSwitchCommand($"UPDATE~{name}~{id}~{level}~{type.ToString()}{Environment.NewLine}"));
 }
예제 #5
0
 /// <summary>
 /// Set device type to cookies
 /// Next time will use this value instead of the value detect from user agent
 /// </summary>
 /// <param name="context">Http ccontext</param>
 /// <param name="type">Device type</param>
 public static void SetClientDeviceToCookies(this IHttpContext context, DeviceTypes type)
 {
     context.PutCookie(DeviceKey, type.ToString());
 }
 internal static LightSwitchCommand CreateUpdateCmd(string name, string id, string level, DeviceTypes type)
 {
     return new LightSwitchCommand($"UPDATE~{name}~{id}~{level}~{type.ToString()}{Environment.NewLine}");
 }
예제 #7
0
        public static void Load(this MainPage page)
        {
            page.btnShutdown.Command = AppCommands.AddAction(() => App.Current.Exit());
            var data = new Data {
                Page = page
            };

            data.Timer = new DispatcherTimer {
                Interval = TimeSpan.FromMilliseconds(500)
            };
            data.Timer.Tick += data.Timer_Tick;


            Exception lastError = null;

            page.GpioStatus.Text = "Loading device information...";
            try
            {
                var         processors   = Environment.ProcessorCount;
                var         envVariables = Environment.GetEnvironmentVariables();
                DeviceTypes type         = DeviceTypeInformation.Type;

                var product = String.Empty;
                if (DeviceTypeInformation.DeviceInfo != null)
                {
                    product = String.Format(", {0}", DeviceTypeInformation.DeviceInfo.SystemProductName);
                }

                page.GpioDevice.Text = string.Format("Device: {0} {1}, processors {2}", type.ToString(), product, processors);

                InitGPIO(page, data);
            }
            catch (Exception ex) { lastError = ex; }

            if (lastError != null)
            {
                var text = page.GpioStatus.Text;
                if (!string.IsNullOrWhiteSpace(text))
                {
                    text += text + Environment.NewLine;
                }

                page.GpioStatus.Text = text + lastError.Message;
            }
        }