71 lines
1.6 KiB
C#
71 lines
1.6 KiB
C#
/*using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using SanShared;
|
|
using Tinkerforge;
|
|
|
|
namespace TempCAN
|
|
{
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public class TinkerForgeTemperatur : ITemperature
|
|
{
|
|
private static string HOST = "localhost";
|
|
private static int PORT = 4223;
|
|
private static string UID = "dW3";
|
|
double temperatur;
|
|
bool erfolg = true;
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public TinkerForgeTemperatur()
|
|
{
|
|
IPConnection ipcon = new IPConnection();
|
|
BrickletTemperature t = new BrickletTemperature(UID, ipcon);
|
|
try
|
|
{
|
|
ipcon.Connect(HOST, PORT);
|
|
}
|
|
catch(Exception)
|
|
{
|
|
erfolg = false;
|
|
ipcon = null;
|
|
t = null;
|
|
return;
|
|
}
|
|
|
|
short temp;
|
|
try
|
|
{
|
|
temp = t.GetTemperature();
|
|
|
|
}
|
|
catch(Tinkerforge.TimeoutException)
|
|
{
|
|
temp = 100;
|
|
erfolg = false;
|
|
}
|
|
temperatur = (temp / 100.0);
|
|
ipcon.Disconnect();
|
|
t = null;
|
|
ipcon = null;
|
|
}
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public double GetTemperatur(out string message)
|
|
{
|
|
message = "";
|
|
if (!erfolg) message = "Es konnte keine Verbindung mit der TemperaturSystem aufgebaut werden";
|
|
return temperatur;
|
|
}
|
|
}
|
|
}
|
|
*/
|
|
|