コード例 #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)}");
            }
        }
コード例 #2
0
ファイル: Utils.cs プロジェクト: coolbas87/OneWireTempLib
        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));
            }
        }
コード例 #3
0
 public OneWireDevice(UART_Adapter UARTAdapter)
 {
     uart = UARTAdapter;
 }
コード例 #4
0
 public DS18B20(UART_Adapter UARTAdapter, byte[] rom = null) :
     base(UARTAdapter, rom)
 {
     SetTempConv(GetResolution());
 }
コード例 #5
0
 public DS1822(UART_Adapter UARTAdapter, byte[] rom = null) :
     base(UARTAdapter, rom)
 {
 }