static void switchLight(Connector connector, bool enabled) { BaosDatapoint d = new BaosDatapoint(connector, 1); if (d.getBoolean() != enabled) { string description = d.getDescription(); string action = enabled ? "on" : "off"; Console.WriteLine("Switching {0} : {1}", description, action); d.setBoolean(enabled); } }
/// <summary> /// Sends the datapoint value write request to the BAOS device /// Our datapoint is a 1 bit boolean value, so we use the setBoolean function /// There are several other encoding functions available, please refer to the /// documentation /// </summary> private void sendBoolean(ushort id, bool enabled) { try { if (connector != null) { BaosDatapoint datapoint = new BaosDatapoint(connector, id); datapoint.setBoolean(enabled); } } catch (kdrive.KdriveException exception) { MessageBox.Show(exception.Message, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }