Skip to content

Commit

Permalink
Přidána funkce měření teploty a odpovídající příklady do ukázkové apl…
Browse files Browse the repository at this point in the history
…ikace a do Wiki.
  • Loading branch information
Papouchcom committed Jun 11, 2018
1 parent b355009 commit de677f7
Show file tree
Hide file tree
Showing 10 changed files with 38 additions and 3 deletions.
Binary file modified Latest/Papouch.Comunication.dll
Binary file not shown.
Binary file modified Latest/Papouch.Comunication.pdb
Binary file not shown.
Binary file modified Latest/Papouch.Quido.dll
Binary file not shown.
Binary file modified Latest/Papouch.Quido.pdb
Binary file not shown.
Binary file modified Latest/Papouch.Utils.dll
Binary file not shown.
Binary file modified Latest/Papouch.Utils.pdb
Binary file not shown.
27 changes: 27 additions & 0 deletions Papouch.Spinel/Spinel97.Device.Quido.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public class Quido:Device
public byte S97_INST_QUIDO_SetOutput = 0x20; // Nastavení výstupů
public byte S97_INST_QUIDO_SetOutputTimered = 0x23; // Nastavení výstupů na určitou dobu
public byte S97_INST_QUIDO_GetOutputs = 0x30; // Čtení výstupů
public byte S97_INST_QUIDO_GetTemperature = 0x51; // Čtení teploty

public int InputCount = -1; // Počet vstupů Quida
public int OutputCount = -1; // Počet výstupů Quida
Expand Down Expand Up @@ -232,6 +233,32 @@ public Boolean CmdGetCounterSettings(byte index, out bool rising, out bool falli
return false;
}

/// <summary>
/// Čtení teploty z připojeného teplotního senzoru
/// </summary>
/// <param name="temp">Aktuálně naměřená teplota. Pokud z nějakého důvodu není dostupná, je zde konstanta float.NaN.</param>
/// <param name="index">Číslo teploměru, číslováno od 1. Ve standardních Quidech je zde vždy 1.</param>
/// <returns>Teplota v aktuálně nastavené teplotní jednotce.</returns>
public Boolean CmdGetTemperature(out float temp, byte index = 0x01)
{
byte[] data = { index };

PacketSpinel97 txPacket = new PacketSpinel97(S97_INST_QUIDO_GetTemperature, data);
txPacket.ADR = this.ADR;
PacketSpinel97 rxPacket;

if (SendAndReceive(ref txPacket, out rxPacket) && (rxPacket.INST == S97_ACK_OK))
{
if ((rxPacket.SDATA != null) && (rxPacket.SDATA.Length == 3))
{
temp = (float)(rxPacket.SDATA[1] * 256 + rxPacket.SDATA[2]) / 10;
return true;
}
}
temp = float.NaN;
return false;
}

/// <summary>
/// Nastavení samovolného vysílání
/// </summary>
Expand Down
5 changes: 4 additions & 1 deletion QuidoDemo_CS.NET/FormMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,10 @@ private void buttonGetTemp_Click(object sender, EventArgs e)
{
if (quido != null)
{
// quido. CmdGetCounter
if (quido.CmdGetTemperature(out float temp))
LogMsg($"Current temperature is {temp} °C");
else
LogMsg("Temperature is not available.");
}
}

Expand Down
7 changes: 6 additions & 1 deletion QuidoDemo_VB.NET/MainForm.vb
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,12 @@ Public Class FormMain
#Region "Commands: Temperature"

Private Sub buttonGetTemp_Click(sender As Object, e As EventArgs) Handles buttonGetTemp.Click

If quido IsNot Nothing Then
Dim temp As Single
If quido.CmdGetTemperature(temp) Then
LogMsg("Temperature is " + temp.ToString() + " °C")
End If
End If
End Sub

#End Region
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Quido.NET
Balíček knihoven a ukázkových aplikací pro práci s [I/O moduly Papouch Quido](https://www.papouch.com/cz/website/mainmenu/clanky/vyberte-si/io-pro-ethernet-usb-rs485-rs232/) na platformě Microsoft .NET.
Aktuální verze všech .NET projektů je kompatibilní s Microsoft Visual Studio 2015 Professional.
Aktuální verze projektu je testována v [Microsoft Visual Studio Community 2017](https://www.visualstudio.com/cs/downloads/).

Všechny části jsou napsané v jazyce C# a při použití využívají jen .NET Frameworku.
Knihovny je možné zkompilovat jako samostatné .NET assembly (DLL) a použít je ve Vašem projektu, nebo je možné tyto knihovny přímo přikompilovat do Vaší aplikace (do výsledného EXE).
Expand Down

0 comments on commit de677f7

Please sign in to comment.