diff --git a/Latest/Papouch.Comunication.dll b/Latest/Papouch.Comunication.dll index 775b845..a313db3 100644 Binary files a/Latest/Papouch.Comunication.dll and b/Latest/Papouch.Comunication.dll differ diff --git a/Latest/Papouch.Comunication.pdb b/Latest/Papouch.Comunication.pdb index 140d3b7..c107313 100644 Binary files a/Latest/Papouch.Comunication.pdb and b/Latest/Papouch.Comunication.pdb differ diff --git a/Latest/Papouch.Quido.dll b/Latest/Papouch.Quido.dll index 4ac27e7..88692dc 100644 Binary files a/Latest/Papouch.Quido.dll and b/Latest/Papouch.Quido.dll differ diff --git a/Latest/Papouch.Quido.pdb b/Latest/Papouch.Quido.pdb index 09a02c3..c1167e1 100644 Binary files a/Latest/Papouch.Quido.pdb and b/Latest/Papouch.Quido.pdb differ diff --git a/Latest/Papouch.Utils.dll b/Latest/Papouch.Utils.dll index 59e4153..652fe3d 100644 Binary files a/Latest/Papouch.Utils.dll and b/Latest/Papouch.Utils.dll differ diff --git a/Latest/Papouch.Utils.pdb b/Latest/Papouch.Utils.pdb index 2eabfdc..ceef8a5 100644 Binary files a/Latest/Papouch.Utils.pdb and b/Latest/Papouch.Utils.pdb differ diff --git a/Papouch.Spinel/Spinel97.Device.Quido.cs b/Papouch.Spinel/Spinel97.Device.Quido.cs index c78f9a1..42892ec 100644 --- a/Papouch.Spinel/Spinel97.Device.Quido.cs +++ b/Papouch.Spinel/Spinel97.Device.Quido.cs @@ -1,10 +1,8 @@ using System; -using System.Text; using System.Diagnostics; - using Papouch.Spinel.Spinel97; using Papouch.Communication; - +using System.Collections.Generic; namespace Papouch.Spinel.Spinel97.Device.Quido { @@ -39,11 +37,11 @@ public Boolean CmdSetRele(byte rele, Boolean value, byte timer = 0) /// /// Nastavení výstupu /// - /// výstup (indexováno od 1) + /// výstup (indexováno od 1) /// požadovaný stav /// čas po který bude výstup nastaven do požadovaného stavu, poté dojde ke změně na opačný stav. ( 1-255 * 0.5s ) /// vrací True v případě potvrzení příkazu modulem - public Boolean CmdSetOutput(byte rele, Boolean value, byte timer = 0) + public Boolean CmdSetOutput(byte outid, Boolean value, byte timer = 0) { PacketSpinel97 txPacket = new PacketSpinel97(); byte[] data; @@ -53,7 +51,7 @@ public Boolean CmdSetOutput(byte rele, Boolean value, byte timer = 0) txPacket.INST = S97_INST_QUIDO_SetOutput; data = new byte[1]; - data[0] = (byte)(((value) ? 0x80 : 0x00) | (rele & 0x7F)); + data[0] = (byte)(((value) ? 0x80 : 0x00) | (outid & 0x7F)); } else { @@ -61,7 +59,82 @@ public Boolean CmdSetOutput(byte rele, Boolean value, byte timer = 0) data = new byte[2]; data[0] = timer; - data[1] = (byte)(((value) ? 0x80 : 0x00) | (rele & 0x7F)); + data[1] = (byte)(((value) ? 0x80 : 0x00) | (outid & 0x7F)); + } + + txPacket.ADR = this.ADR; + + txPacket.SDATA = data; + + PacketSpinel97 rxPacket; + + if (this.SendAndReceive(ref txPacket, out rxPacket) && (rxPacket.INST == (byte)ResponseACK.AllIsOk)) + { + return true; + } + return false; + + } + + /// + /// Definuje stav jednoho výstupu. Obsahuje id výstupu (OUT1 = 1) a jeho stav (state) jako true/false. + /// + public struct OutputState + { + /// + /// Číslo výstupu. OUT1 = 1. + /// + public byte id; + /// + /// SET = true + /// + public bool state; + + /// + /// Inicializuje strukturu id výstupu a stavem. + /// + /// Číslo výstupu. OUT1 = 1. + /// SET = true + public OutputState(byte outid, bool outstate) + { + id = outid; + state = outstate; + } + } + + /// + /// Nastavení více výstupů najednou. Může obsahovat nastavení jednoho nebo až všech výstupů do požadovaného stavu. Stav může být pro každý výstup jiný. + /// + /// List struktur . (Obsahují byte číslo výstupu a bool stav výstupu.) + /// čas po který bude výstup nastaven do požadovaného stavu, poté dojde ke změně na opačný stav. ( 1-255 * 0.5s ) + /// vrací True v případě potvrzení příkazu modulem + public Boolean CmdSetOutputs(List outs, byte timer = 0) + { + PacketSpinel97 txPacket = new PacketSpinel97(); + byte[] data; + + if (outs.Count == 0) return false; + + if (timer == 0) + { + txPacket.INST = S97_INST_QUIDO_SetOutput; + + data = new byte[outs.Count]; + for (int i = 0; i < outs.Count; i++) + { + data[i] = (byte)(((outs[i].state) ? 0x80 : 0x00) | (outs[i].id & 0x7F)); + } + } + else + { + txPacket.INST = S97_INST_QUIDO_SetOutputTimered; + + data = new byte[outs.Count + 1]; + data[0] = timer; + for (int i = 0; i < outs.Count; i++) + { + data[i+1] = (byte)(((outs[i].state) ? 0x80 : 0x00) | (outs[i].id & 0x7F)); + } } txPacket.ADR = this.ADR;