Exemplo n.º 1
0
        public OneWireSensor(UART_Adapter UARTAdapter, byte[] rom = null) :
            base(UARTAdapter)
        {
            TempConversionTime = DefTempConversionTime;
            WriteTime          = DefWriteTime;

            if (rom == null)
            {
                isSingleMode = true;
                romCode      = ReadROM();
            }
            else
            {
                isSingleMode = false;
                romCode      = rom;
                if (!IsConnected(romToBits(romCode)))
                {
                    throw new DeviceError($"Device with ROM code {romCode} not found");
                }
                uart.Reset();
            }
            isParasiticPwr = IsPowerSupply();

            if (romCode[0] != FamilyCode)
            {
                throw new DeviceError($"The device is not a {DeviceName(FamilyCode)}");
            }
        }
Exemplo n.º 2
0
        public static OneWireSensor CreateSensor(byte sensorType, UART_Adapter UARTAdapter, byte[] rom = null)
        {
            switch (sensorType)
            {
            case 0x01:
                return(new OneWireSensor(UARTAdapter, rom));

            case 0x10:
                return(new OneWireSensor(UARTAdapter, rom));

            case 0x22:
                return(new DS1822(UARTAdapter, rom));

            case 0x28:
                return(new DS18B20(UARTAdapter, rom));

            default:
                return(new OneWireSensor(UARTAdapter, rom));
            }
        }
Exemplo n.º 3
0
 public OneWireDevice(UART_Adapter UARTAdapter)
 {
     uart = UARTAdapter;
 }
Exemplo n.º 4
0
 public DS18B20(UART_Adapter UARTAdapter, byte[] rom = null) :
     base(UARTAdapter, rom)
 {
     SetTempConv(GetResolution());
 }
Exemplo n.º 5
0
 public DS1822(UART_Adapter UARTAdapter, byte[] rom = null) :
     base(UARTAdapter, rom)
 {
 }