private void AddHeaders(IGridList <View> gridList, int rowIndex) { GridUtil.AddLabel("Pin#", gridList, rowIndex, 0, 0, 1, Color.Blue, false, LayoutOptions.Start); GridUtil.AddLabel("Mode", gridList, rowIndex, 0, 1, 1, Color.Blue, false, LayoutOptions.Start); GridUtil.AddLabel("Value", gridList, rowIndex, 0, 2, 1, Color.Blue, false, LayoutOptions.Start); GridUtil.AddLabel("Value", gridList, rowIndex, 0, 3, 1, Color.Blue, false, LayoutOptions.Start); GridUtil.AddLabel("Mode", gridList, rowIndex, 0, 4, 1, Color.Blue, false, LayoutOptions.Start); GridUtil.AddLabel("Pin#", gridList, rowIndex, 0, 5, 1, Color.Blue, false, LayoutOptions.Start); }
private void Display() { IGridList <View> gridList = piStatsGrid.Children; gridList.Clear(); int rowIndex = 0; if (_piSystem == null) { AddLabel($"Service {_monitorTopic.Name} is not available at {_monitorTopic.Server}.", gridList, rowIndex++, 0, 5); AbortRefresh(); return; } HttpResponse response = _piSystem.CpuClient.GetResponse(); if (!response.Success) { AddLabel($"Error getting data for {_monitorTopic.Name} at {_monitorTopic.Server}", gridList, rowIndex++, 0, 5); GridUtil.AddLabel(response.ErrorMessage, gridList, rowIndex++, 0, 5, 10, Color.Default, false, LayoutOptions.End); StopRefresh(); return; } _piSystem.MemoryClient.Get(); CpuData cpu = _piSystem.CpuClient.CpuData; MemoryData memory = _piSystem.MemoryClient.MemoryData; DisplayHeaderAndValueRow("Server Address", _monitorTopic.Server, gridList, rowIndex++, 3); DisplayHeaderAndValueRow("CPU Core Temperature", cpu.Temperature.ToString(), gridList, rowIndex++, 3); AddLabel("Usage", gridList, rowIndex, 1, 1); AddLabel("User", gridList, rowIndex, 2, 1); AddLabel("System", gridList, rowIndex, 3, 1); AddLabel("Idle", gridList, rowIndex, 4, 1); rowIndex++; DisplayCpuRow(_monitorTopic.Name, cpu, gridList, rowIndex++); if (cpu.Cores != null) { foreach (var data in cpu.Cores) { DisplayCpuRow(data.Key, data.Value, gridList, rowIndex++); } } DisplayHeaderAndValueRow("Total Memory (MB)", memory.Total.ToString(), gridList, rowIndex++, 2); DisplayMemoryRow("Used Memory (MB)", memory.Used, memory.Total, gridList, rowIndex++); DisplayMemoryRow("Cached Memory (MB)", memory.Cached, memory.Total, gridList, rowIndex++); DisplayMemoryRow("Free Memory (MB)", memory.Free, memory.Total, gridList, rowIndex++); DisplayMemoryRow("Available Memory (MB)", memory.Available, memory.Total, gridList, rowIndex++); if (_hygroThermoSensor != null) { string json = _hygroThermoSensor.Get(); DisplayHeaderAndValueRow("Humidity (%)", _hygroThermoSensor.HygroThermoData.Humidity.ToString(), gridList, rowIndex++, 2); DisplayHeaderAndValueRow("Temperature (C)", _hygroThermoSensor.HygroThermoData.Temperature.ToString(), gridList, rowIndex++, 2); } }
private void AddLabel(string text, IGridList <View> gridList, int row, int col, int colSpan = 1) { GridUtil.AddLabel("Pin#", gridList, row, 0, 1, 1, Color.Blue, false, LayoutOptions.Start); Label label = GridUtil.AddLabel(text, gridList, row, col, colSpan); }
private void AddLabel(string text, IGridList <View> gridList, int row, int col, int colSpan = 1) { Label label = GridUtil.AddLabel(text, gridList, row, col, colSpan); }
private void Display() { IGridList <View> gridList = dataGrid.Children; gridList.Clear(); int rowIndex = 0; if (_hs1xxClient == null) { AddLabel($"Smart Plug {_DeviceTopic.Name} is not available at {_DeviceTopic.Server}.", gridList, rowIndex++, 0, 2); _initialized = false; return; } HttpResponse response = _hs1xxClient.System.GetResponse(); if (!response.Success) { AddLabel($"Error getting data for {_DeviceTopic.Name} at {_DeviceTopic.Server}", gridList, rowIndex++, 0, 2); GridUtil.AddLabel(response.ErrorMessage, gridList, rowIndex++, 0, 2, 10, Color.Default, false, LayoutOptions.End); return; } string timeJson = _hs1xxClient.Time.Get(); KasaHs1xxSystemData systemData = _hs1xxClient.System.SystemData; KasaHs1xxTimeData timeData = _hs1xxClient.Time.TimeData; if (systemData.Relay_state == 0) { OnOffToolbarItem.Text = "On"; } else { OnOffToolbarItem.Text = "Off"; } if (systemData.Led_off == 0) { LedOffToolbarItem.Text = "LedOff"; } else { LedOffToolbarItem.Text = "LedOn"; } DisplayHeaderAndValueRow("IP Address", systemData.Ipaddress, gridList, rowIndex++); DisplayHeaderAndValueRow("Alias", systemData.Alias, gridList, rowIndex++); DisplayHeaderAndValueRow("Time", timeData.Time, gridList, rowIndex++); DisplayHeaderAndValueRow("Relay State", systemData.Relay_state == 1 ? "On" : "Off", gridList, rowIndex++); DisplayHeaderAndValueRow("On Time", SecondToString(systemData.On_time), gridList, rowIndex++); DisplayHeaderAndValueRow("LED Always Off", systemData.Led_off == 1 ? "True" : "False", gridList, rowIndex++); DisplayHeaderAndValueRow("Next Action", systemData.next_action.Action.ToString(), gridList, rowIndex++); DisplayHeaderAndValueRow("Next Action Time", SecondToString(systemData.next_action.schd_sec), gridList, rowIndex++); DisplayHeaderAndValueRow("Next Action Type", systemData.next_action.Type.ToString(), gridList, rowIndex++); DisplayHeaderAndValueRow("WIFI Signal", systemData.Rssi.ToString(), gridList, rowIndex++); DisplayHeaderAndValueRow("Active Mode", systemData.Active_mode, gridList, rowIndex++); DisplayHeaderAndValueRow("Device Name", systemData.Dev_name, gridList, rowIndex++); DisplayHeaderAndValueRow("Error Code", systemData.Err_code.ToString(), gridList, rowIndex++); DisplayHeaderAndValueRow("Feature", systemData.Feature, gridList, rowIndex++); DisplayHeaderAndValueRow("HW Version", systemData.hw_ver, gridList, rowIndex++); DisplayHeaderAndValueRow("Icon Hash", systemData.Icon_hash, gridList, rowIndex++); DisplayHeaderAndValueRow("Latitude", systemData.Latitude_i.ToString(), gridList, rowIndex++); DisplayHeaderAndValueRow("Longitude", systemData.Longitude_i.ToString(), gridList, rowIndex++); DisplayHeaderAndValueRow("Mac Address", systemData.Mac, gridList, rowIndex++); DisplayHeaderAndValueRow("NTC State", systemData.Ntc_state.ToString(), gridList, rowIndex++); DisplayHeaderAndValueRow("Software Version", systemData.Sw_ver, gridList, rowIndex++); DisplayHeaderAndValueRow("Status", systemData.Status, gridList, rowIndex++); DisplayHeaderAndValueRow("Updating", systemData.Updating.ToString(), gridList, rowIndex++); // display IDs - 1st row for label 2nd row for data AddLabel("Device ID", gridList, rowIndex++, 0); GridUtil.AddLabel(systemData.DeviceId, gridList, rowIndex++, 0, 2, 1, Color.Default, false, LayoutOptions.End); AddLabel("Hardware ID", gridList, rowIndex++, 0); GridUtil.AddLabel(systemData.HwId, gridList, rowIndex++, 0, 2, 1, Color.Default, false, LayoutOptions.End); AddLabel("OEM ID", gridList, rowIndex++, 0); GridUtil.AddLabel(systemData.OemId, gridList, rowIndex++, 0, 2, 1, Color.Default, false, LayoutOptions.End); AddLabel("Next Action ID", gridList, rowIndex++, 0); GridUtil.AddLabel(systemData.next_action.Id, gridList, rowIndex++, 0, 2, 1, Color.Default, false, LayoutOptions.End); }