Ejemplo n.º 1
0
        public Node(INodeConfigurator configurator)
        {
            _configurator = configurator;

            //Bus controller
            _bus = _configurator.Bus;
            _bus.CommandReceived += OnCommandReceived;
            _bus.AckReceived += OnAckReceived;

            //Hardware Abstraction Layer
            _hal = _configurator.Hal;

            //Scheduler
            _scheduler = _configurator.Scheduler;

            //Private members
            _pinSubscribers = new Dictionary<string, Pin>();
            _deviceSubscribers = new Dictionary<string, Device>();
            _sensorSubscribers = new List<SensorSubscriber>();
            _nodeSubscribers = new Dictionary<Address, byte>();

            //Public configuration
            Status = new NodeStatusInfo
            {
                Mask = 0,
                NodeStatus = NodeStatusValues.Reset,
                BusStatus = _bus.Status,
                LastError = 0,
                TotalErrors = 0,
                Time = 0,
                LastActivatedInput = string.Empty,
                LastActivatedOutput = string.Empty
            };
            //TODO: Add autostart property
            //if (AutoStart) {
            //Configure node
            //if (LoadConfiguration(false))
            //{
            //    //Full reset node
            //    Reset(true);
            //}
            //}
            //else
            //_bus.Open();    //Only bus start

            Log.Debug("Node created");
        }
Ejemplo n.º 2
0
        public Node()
        {
            _configurator = null;

            //Bus controller
            _bus = null;

            //Hardware Abstraction Layer
            _hal = null;

            //Scheduler
            _scheduler = null;

            //Private members
            _pinSubscribers = new Dictionary<string, Pin>();
            _deviceSubscribers = new Dictionary<string, Device>();
            _sensorSubscribers = new List<SensorSubscriber>();
            _nodeSubscribers = new Dictionary<Address, byte>();

            //Public configuration
            Status = new NodeStatusInfo
            {
                Mask = 0,
                NodeStatus = NodeStatusValues.Unknown,
                BusStatus = BusStatus.Reset,
                LastError = 0,
                TotalErrors = 0,
                Time = 0,
                LastActivatedInput = string.Empty,
                LastActivatedOutput = string.Empty
            };

            Log.Debug("Empty node created");
        }