public double GetTemp() { if (!connected) { InitDevice(); } double value = EntryAPI.EMyReadTemp(true); if (value == -100) { connected = false; throw new IOException("No sensor"); } else if (value == 888) { connected = false; throw new IOException("Device error"); } else if (value == 999) { connected = false; throw new IOException("Device error"); } else { return(Math.Round(value, 2)); } }
private void InitDevice() { if (DeviceConnected()) { int numberOfDevices = EntryAPI.EMyDetectDevice((long)hwnd); if (numberOfDevices > 0) { EntryAPI.EMySetCurrentDev(0); Thread.Sleep(100); EntryAPI.EMyInitConfig(true); connected = true; } } else { connected = false; } }
public void Dispose() { EntryAPI.EMyCloseDevice(); }