Пример #1
0
 /// <summary>
 /// Create an instance of OneWireSensor
 /// </summary>
 /// <param name="adresse">Address of the sensor</param>
  /// <returns>Instance of sensor implementing <see cref="IOneWireSensor"/></returns>
 public static IOneWireSensor Create(RomAddress adresse)
 {
     DS18S20 sensor = new DS18S20(adresse);
     return sensor;
 }
Пример #2
0
        /// <summary>
        /// Perform a search on the OneWire bus
        /// </summary>
        public virtual RomAddress[] Discover()
        {
            this._states.Push(State.BUSY);

            ArrayList sensors = new ArrayList();
            Int16 addressLen = 8;
            byte[] romRegistre = new byte[addressLen];

            this.oneWire.Search_Restart();
            while (this.oneWire.Search_GetNextDevice(romRegistre))
            {
                RomAddress address = new RomAddress((byte[])romRegistre.Clone(), addressLen);
                sensors.Add(address);
            }

            this._states.Pop();

            RomAddress[] adresseList = new RomAddress[sensors.Count];
            for (int i = 0; i < adresseList.Length; i++)
            {
                adresseList[i] = (RomAddress)sensors[i];
            }
            return adresseList;
        }
Пример #3
0
        /// <summary>
        /// Dispose the instance
        /// </summary>
        /// <param name="dispose">Indicate that the disposing is explicit (not GC)</param>
        protected void Dispose(bool dispose)
        {
            if (dispose)
            {
                this._selectedSensor = null;
                this._states.Clear();
                this.IsDisposed = true;

                this.oneWire.Dispose();
                GC.SuppressFinalize(this);
            }
        }
Пример #4
0
 /// <summary>
 /// Initialize the network.
 /// </summary>
 public virtual void Reset()
 {
     this.oneWire.Reset();
     this._selectedSensor = null;
     this._states.Clear();
     this._states.Push(State.READY);
 }
Пример #5
0
        /// <summary>
        /// Select a device in the network
        /// </summary>
        /// <param name="address">Address of the device</param>
        public virtual void Select(RomAddress address)
        {
            this._states.Push(State.BUSY);
            byte[] bufferAdress = address.ToArray();
            this.oneWire.WriteByte(SELECT_ORDER);
            this.oneWire.Write(bufferAdress, 0, bufferAdress.Length);
            this._states.Pop();

            this._selectedSensor = address;
            this._states.Push(State.SELECTED);
        }
Пример #6
0
 /// <summary>
  /// Create a new instance of <see cref="OneWireSensor"/>
 /// </summary>
 /// <param name="address"></param>
  public OneWireSensor(RomAddress address)
  {
      this._address = address;
  }