public override void DigitalSmartObjectEventIn(CrestronDevice device, byte id, ushort idx, bool val) { //OnDebug(eDebugEventType.Info, "DigitalSmartObjectEventIn, ID:{0}, join:{1}, val:{2}", id.ToString(), idx.ToString(), val.ToString()); var so = device.smartObjects.Find(x => x.id == id); Digital sig = null; if (so != null) { sig = so.digitalInputs.Find(x => x.pos == idx); } if (sig == null || sig.value != val) // changed { OnDebug(eDebugEventType.Info, "DigitalSmartObjectEventIn (changed), ID:{0}, join:{1}, val:{2}", id.ToString(), idx.ToString(), val.ToString()); switch (id) { case SG_DPAD: SmartObject_DPad_DigSigChange(device, idx, val); break; case SG_KEYPAD: SmartObject_KeyPad_DigSigChange(device, idx, val); break; case SG_BTN_LIST: SmartObject_BtnList_DigSigChange(device, idx, val); break; case SG_DYNAMIC_BTN_LIST: SmartObject_DynBtnList_DigSigChange(device, idx, val); break; case SG_DYNAMIC_ICON_LIST: SmartObject_DynIconList_DigSigChange(device, idx, val); break; } } else // held { OnDebug(eDebugEventType.Info, "DigitalSmartObjectEventIn (held), ID:{0}, join:{1}, val:{2}", id.ToString(), idx.ToString(), val.ToString()); switch (id) { case SG_DPAD: SmartObject_DPad_DigSigChange(device, idx, val); break; } } }
private void setOutputSigState(CrestronDevice device, byte id, ushort idx, bool val) { CrestronJoins joins = id > 0 ? getSmartObject(device, id) : device; var sig = joins.digitalOutputs.Find(x => x.pos == idx); if (sig == null) { sig = new Digital(idx, val); joins.digitalOutputs.Add(sig); } else { sig.value = val; } }
public void ToggleDigitalSmartObject(CrestronDevice device, byte id, ushort idx) { OnDebug(eDebugEventType.Info, "ToggleDigitalSmartObject:{0}:{1} ", id, idx); CrestronJoins smartObject = device.smartObjects.Find(x => x.id == id); if (smartObject == null) { smartObject = new CrestronJoins(id); device.smartObjects.Add(smartObject); } Digital dig = smartObject.digitalOutputs.Find(x => x.pos == idx); if (dig == null) { dig = new Digital(idx, false); device.smartObjects.Add(smartObject); } SendDigitalSmartObject(device, id, idx, !dig.value); }
public void SendDigital(CrestronDevice device, ushort idx, bool val) { setOutputSigState(device, 0, idx, val); ushort NewIdx = (ushort)StringHelper.SetBit(idx - 1, 15, !val); byte[] b = { (byte)(NewIdx % 0x100), (byte)(NewIdx / 0x100) }; string str = "\x05\x00\x06\x00\x00\x03\x00" + StringHelper.GetString(b); Send(device, str); //Debug("SendDigital: " + StringHelper.CreateHexPrintableString(str)); // local feedback if (device.digitalOutputs.Where(x => x.pos == idx).Count() == 0) { device.digitalOutputs.Add(new Digital(idx, false)); } Digital d = device.digitalOutputs.Find(x => x.pos == idx); d.value = val; }