From 36776bfbff6f15f7239924777651392945ebb2a0 Mon Sep 17 00:00:00 2001 From: James Barnett Date: Thu, 27 Jul 2017 13:02:31 +0100 Subject: Rejig folder structure --- NucLedController/WMISystemManagement.cs | 41 +++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 NucLedController/WMISystemManagement.cs (limited to 'NucLedController/WMISystemManagement.cs') diff --git a/NucLedController/WMISystemManagement.cs b/NucLedController/WMISystemManagement.cs new file mode 100644 index 0000000..bd3b9cd --- /dev/null +++ b/NucLedController/WMISystemManagement.cs @@ -0,0 +1,41 @@ +using System; +using System.Management; + +namespace NucLedController +{ + public sealed class WMISystemManagement + { + private static readonly string OBJECT_SEARCHER_SCOPE = "\\root\\WMI"; + private static readonly string OBJECT_SEARCHER_QUERY_STRING = "SELECT * FROM CISD_WMI"; + private static readonly string SET_LED_METHOD_NAME = "SetState"; + + private static readonly WMISystemManagement INSTANCE = new WMISystemManagement(); + + private EnumerationOptions enumerationOptions; + private ManagementObjectSearcher objectSearcher; + + private WMISystemManagement() + { + enumerationOptions = new EnumerationOptions(); + enumerationOptions.ReturnImmediately = false; + objectSearcher = new ManagementObjectSearcher(OBJECT_SEARCHER_SCOPE, OBJECT_SEARCHER_QUERY_STRING, enumerationOptions); + } + + public static WMISystemManagement Instance + { + get { return INSTANCE; } + } + + public void WriteData(byte[] data) + { + + foreach (ManagementObject queryObj in objectSearcher.Get()) + { + queryObj.InvokeMethod(SET_LED_METHOD_NAME, new object[] { BitConverter.ToInt32(data, 0) }); + queryObj.Dispose(); + } + + } + + } +} -- cgit v1.2.3