Ejemplo n.º 1
0
        /// <summary>
        /// Class constructor. Instantiates a new <see cref="DataReader"/> object for the given connection
        /// interface using the given XBee operating mode and XBee device.
        /// </summary>
        /// <param name="connectionInterface">Connection interface to read data from.</param>
        /// <param name="mode">XBee operating mode.</param>
        /// <param name="xbeeDevice">Reference to the XBee device containing this <see cref="DataReader"/>
        /// object.</param>
        /// <exception cref="ArgumentNullException">If <c><paramref name="connectionInterface"/> == null</c>.</exception>
        /// <seealso cref="IConnectionInterface"/>
        /// <seealso cref="XBeeDevice"/>
        /// <seealso cref="OperatingMode"/>
        public DataReader(IConnectionInterface connectionInterface, OperatingMode mode, AbstractXBeeDevice xbeeDevice)
        {
            this.connectionInterface = connectionInterface ?? throw new ArgumentNullException("Connection interface cannot be null.");
            this.mode        = mode;
            this.xbeeDevice  = xbeeDevice;
            logger           = LogManager.GetLogger <DataReader>();
            parser           = new XBeePacketParser();
            XBeePacketsQueue = new XBeePacketsQueue();

            // Create the task.
            task = new Task(() => { Run(); }, TaskCreationOptions.LongRunning);
        }
Ejemplo n.º 2
0
        /**
         * Class constructor. Instantiates a new {@code DataReader} object for the
         * given connection interface using the given XBee operating mode and XBee
         * device.
         *
         * @param connectionInterface Connection interface to read data from.
         * @param mode XBee operating mode.
         * @param xbeeDevice Reference to the XBee device containing this
         *                   {@code DataReader} object.
         *
         * @throws ArgumentNullException if {@code connectionInterface == null} or
         *                                 {@code mode == null}.
         *
         * @see IConnectionInterface
         * @see com.digi.xbee.api.XBeeDevice
         * @see com.digi.xbee.api.models.OperatingMode
         */
        public DataReader(IConnectionInterface connectionInterface, OperatingMode mode, XBeeDevice xbeeDevice)
        {
            if (connectionInterface == null)
                throw new ArgumentNullException("Connection interface cannot be null.");
            if (mode == null)
                throw new ArgumentNullException("Operating mode cannot be null.");

            this.connectionInterface = connectionInterface;
            this.mode = mode;
            this.xbeeDevice = xbeeDevice;
            this.logger = LogManager.GetLogger<DataReader>();
            parser = new XBeePacketParser();
            xbeePacketsQueue = new XBeePacketsQueue();
        }
Ejemplo n.º 3
0
        /**
         * Class constructor. Instantiates a new {@code DataReader} object for the
         * given connection interface using the given XBee operating mode and XBee
         * device.
         *
         * @param connectionInterface Connection interface to read data from.
         * @param mode XBee operating mode.
         * @param xbeeDevice Reference to the XBee device containing this
         *                   {@code DataReader} object.
         *
         * @throws ArgumentNullException if {@code connectionInterface == null} or
         *                                 {@code mode == null}.
         *
         * @see IConnectionInterface
         * @see com.digi.xbee.api.XBeeDevice
         * @see com.digi.xbee.api.models.OperatingMode
         */
        public DataReader(IConnectionInterface connectionInterface, OperatingMode mode, XBeeDevice xbeeDevice)
        {
            if (connectionInterface == null)
            {
                throw new ArgumentNullException("Connection interface cannot be null.");
            }
            if (mode == null)
            {
                throw new ArgumentNullException("Operating mode cannot be null.");
            }

            this.connectionInterface = connectionInterface;
            this.mode        = mode;
            this.xbeeDevice  = xbeeDevice;
            this.logger      = LogManager.GetLogger <DataReader>();
            parser           = new XBeePacketParser();
            xbeePacketsQueue = new XBeePacketsQueue();
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Class constructor. Instantiates a new <see cref="DigiMeshDevice"/> object with the given
 /// connection interface.
 /// </summary>
 /// <param name="connectionInterface">The connection interface with the physical DigiMesh device.</param>
 /// <exception cref="ArgumentNullException">If <c><paramref name="connectionInterface"/> == null</c>.
 /// </exception>
 /// <seealso cref="XBeeDevice(IConnectionInterface)"/>
 /// <seealso cref="IConnectionInterface"/>
 public DigiMeshDevice(IConnectionInterface connectionInterface)
     : base(connectionInterface)
 {
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Class constructor. Instantiates a new <see cref="DigiPointDevice"/> object with the given
 /// connection interface.
 /// </summary>
 /// <param name="connectionInterface">The connection interface with the physical point-to-multipoint
 /// device.</param>
 /// <exception cref="ArgumentNullException">If <c><paramref name="connectionInterface"/> == null</c>.
 /// </exception>
 /// <seealso cref="XBeeDevice(IConnectionInterface)"/>
 /// <seealso cref="IConnectionInterface"/>
 public DigiPointDevice(IConnectionInterface connectionInterface)
     : base(connectionInterface)
 {
 }
 /**
  * Class constructor. Instantiates a new {@code DigiPointDevice} object with the
  * given connection interface.
  *
  * @param connectionInterface The connection interface with the physical
  *                            point-to-multipoint device.
  *
  * @throws ArgumentNullException if {@code connectionInterface == null}
  *
  * @see IConnectionInterface
  */
 public DigiPointDevice(IConnectionInterface connectionInterface)
     : base(connectionInterface)
 {
 }
Ejemplo n.º 7
0
 /**
  * Class constructor. Instantiates a new {@code Raw802Device} object with the
  * given connection interface.
  *
  * @param connectionInterface The connection interface with the physical
  *                            802.15.4 device.
  *
  * @throws ArgumentNullException if {@code connectionInterface == null}
  *
  * @see IConnectionInterface
  */
 public Raw802Device(IConnectionInterface connectionInterface)
     : base(connectionInterface)
 {
 }
Ejemplo n.º 8
0
 /**
  * Class constructor. Instantiates a new {@code ZigBeeDevice} object with the
  * given connection interface.
  *
  * @param connectionInterface The connection interface with the physical
  *                            ZigBee device.
  *
  * @throws ArgumentNullException if {@code connectionInterface == null}
  *
  * @see com.digi.xbee.api.connection.IConnectionInterface
  */
 public ZigBeeDevice(IConnectionInterface connectionInterface)
     : base(connectionInterface)
 {
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Class constructor. Instantiates a new <c>XBeeDevice</c> object with the given connection
 /// interface.
 /// </summary>
 /// <param name="connectionInterface">The connection interface with the physical XBee device.</param>
 /// <exception cref="ArgumentNullException">If
 /// <c><paramref name="connectionInterface"/> == null</c>.</exception>
 /// <seealso cref="IConnectionInterface"/>
 protected XBeeDevice(IConnectionInterface connectionInterface)
     : base(connectionInterface)
 {
 }
Ejemplo n.º 10
0
 /**
  * Class constructor. Instantiates a new {@code Raw802Device} object with the
  * given connection interface.
  *
  * @param connectionInterface The connection interface with the physical
  *                            802.15.4 device.
  *
  * @throws ArgumentNullException if {@code connectionInterface == null}
  *
  * @see IConnectionInterface
  */
 public Raw802Device(IConnectionInterface connectionInterface)
     : base(connectionInterface)
 {
 }
Ejemplo n.º 11
0
 /// <summary>
 /// Class constructor. Instantiates a new <see cref="CellularDevice"/> object with the given
 /// connection interface.
 /// </summary>
 /// <param name="connectionInterface">The connection interface with the physical
 /// Cellular device.</param>
 /// <exception cref="ArgumentNullException">If <c><paramref name="connectionInterface"/> == null</c>.
 /// </exception>
 /// <seealso cref="XBeeDevice(IConnectionInterface)"/>
 /// <seealso cref="IConnectionInterface"/>
 public CellularDevice(IConnectionInterface connectionInterface)
     : base(connectionInterface)
 {
 }
Ejemplo n.º 12
0
 /**
  * Class constructor. Instantiates a new {@code XBeeDevice} object with the
  * given connection interface.
  *
  * @param connectionInterface The connection interface with the physical
  *                            XBee device.
  *
  * @throws ArgumentNullException if {@code connectionInterface == null}.
  *
  * @see #XBeeDevice(String, int)
  * @see #XBeeDevice(String, SerialPortParameters)
  * @see #XBeeDevice(String, int, int, int, int, int)
  * @see com.digi.xbee.api.connection.IConnectionInterface
  */
 public XBeeDevice(IConnectionInterface connectionInterface)
     : base(connectionInterface)
 {
     resetStatusListener = new CustomModemStatusReceiveListener(this);
 }
 /**
  * Class constructor. Instantiates a new {@code DigiMeshDevice} object with the
  * given connection interface.
  *
  * @param connectionInterface The connection interface with the physical
  *                            DigiMesh device.
  *
  * @throws ArgumentNullException if {@code connectionInterface == null}
  *
  * @see IConnectionInterface
  */
 public DigiMeshDevice(IConnectionInterface connectionInterface)
     : base(connectionInterface)
 {
 }
Ejemplo n.º 14
0
 /**
  * Class constructor. Instantiates a new {@code ZigBeeDevice} object with the
  * given connection interface.
  *
  * @param connectionInterface The connection interface with the physical
  *                            ZigBee device.
  *
  * @throws ArgumentNullException if {@code connectionInterface == null}
  *
  * @see com.digi.xbee.api.connection.IConnectionInterface
  */
 public ZigBeeDevice(IConnectionInterface connectionInterface)
     : base(connectionInterface)
 {
 }
		/**
		 * Class constructor. Instantiates a new {@code RemoteXBeeDevice} object 
		 * with the given local {@code XBeeDevice} which contains the connection 
		 * interface to be used.
		 * 
		 * @param localXBeeDevice The local XBee device that will behave as 
		 *                        connection interface to communicate with this 
		 *                        remote XBee device.
		 * @param addr64 The 64-bit address to identify this XBee device.
		 * @param addr16 The 16-bit address to identify this XBee device. It might 
		 *               be {@code null}.
		 * @param id The node identifier of this XBee device. It might be 
		 *           {@code null}.
		 * 
		 * @throws ArgumentException If {@code localXBeeDevice.isRemote() == true}.
		 * @throws ArgumentNullException If {@code localXBeeDevice == null} or
		 *                              if {@code addr64 == null}.
		 * 
		 * @see #AbstractXBeeDevice(IConnectionInterface)
		 * @see #AbstractXBeeDevice(String, int)
		 * @see #AbstractXBeeDevice(String, SerialPortParameters)
		 * @see #AbstractXBeeDevice(XBeeDevice, XBee64BitAddress)
		 * @see #AbstractXBeeDevice(String, int, int, int, int, int)
		 * @see com.digi.xbee.api.models.XBee16BitAddress
		 * @see com.digi.xbee.api.models.XBee64BitAddress
		 */
		public AbstractXBeeDevice(XBeeDevice localXBeeDevice, XBee64BitAddress addr64,
				XBee16BitAddress addr16, String id)
		{
			if (localXBeeDevice == null)
				throw new ArgumentNullException("Local XBee device cannot be null.");
			if (addr64 == null)
				throw new ArgumentNullException("XBee 64-bit address of the device cannot be null.");
			if (localXBeeDevice.IsRemote)
				throw new ArgumentException("The given local XBee device is remote.");

			XBeeProtocol = XBeeProtocol.UNKNOWN;
			this.localXBeeDevice = localXBeeDevice;
			this.connectionInterface = localXBeeDevice.GetConnectionInterface();
			this.xbee64BitAddress = addr64;
			this.xbee16BitAddress = addr16;
			if (addr16 == null)
				xbee16BitAddress = XBee16BitAddress.UNKNOWN_ADDRESS;
			this.nodeID = id;
			this.logger = LogManager.GetLogger(this.GetType());
			logger.DebugFormat(ToString() + "Using the connection interface {0}.",
					connectionInterface.GetType().Name);
			this.IOPacketReceiveListener = new CustomPacketReceiveListener(this);
		}
		/**
		 * Class constructor. Instantiates a new {@code XBeeDevice} object with the 
		 * given connection interface.
		 * 
		 * @param connectionInterface The connection interface with the physical 
		 *                            XBee device.
		 * 
		 * @throws ArgumentNullException if {@code connectionInterface == null}.
		 * 
		 * @see #AbstractXBeeDevice(String, int)
		 * @see #AbstractXBeeDevice(String, SerialPortParameters)
		 * @see #AbstractXBeeDevice(XBeeDevice, XBee64BitAddress)
		 * @see #AbstractXBeeDevice(XBeeDevice, XBee64BitAddress, XBee16BitAddress, String)
		 * @see #AbstractXBeeDevice(String, int, int, int, int, int)
		 * @see com.digi.xbee.api.connection.IConnectionInterface
		 */
		public AbstractXBeeDevice(IConnectionInterface connectionInterface)
		{
			Contract.Requires<ArgumentNullException>(connectionInterface != null, "ConnectionInterface cannot be null.");

			XBeeProtocol = XBeeProtocol.UNKNOWN;
			this.connectionInterface = connectionInterface;
			this.logger = LogManager.GetLogger(this.GetType());
			logger.DebugFormat(ToString() + "Using the connection interface {0}.",
					connectionInterface.GetType().Name);
			this.IOPacketReceiveListener = new CustomPacketReceiveListener(this);
		}