コード例 #1
0
 public ZoneList(XmlNode settings, GatewayList gateways, DeviceStateChangedDelegate stateChanged,
                 FeedbackReceivedFromDeviceDelegate feedbackReceived)
 {
     foreach (XmlNode child in settings.ChildNodes)
     {
         GenericZone zn = new GenericZone(child, gateways, stateChanged, feedbackReceived);
         this.Add(zn);
     }
 }
コード例 #2
0
        private void InitializeProcessor(string settingsFile)
        {
            XmlDocument doc = new XmlDocument();

            doc.Load(settingsFile);

            XmlNamespaceManager nsMgr = new XmlNamespaceManager(doc.NameTable);

            nsMgr.AddNamespace("def", "http://smarthomecontrol.voronin.co.uk");

            //Loading local settings first
            XmlNode settingsNode = doc.SelectSingleNode("/def:Definition/def:LocalSettings", nsMgr);

            LocalSettings.InitializeParameters(IPAddress.Parse(settingsNode.Attributes["address"].Value),
                                               settingsNode.Attributes["dbConnection"].Value, this,
                                               settingsNode.Attributes["macAddress"].Value,
                                               settingsNode.Attributes["homeCoordinates"].Value);

            //Now loading gateways
            XmlNode node = doc.SelectSingleNode("/def:Definition/def:Gateways", nsMgr);

            Gateways = new GatewayList(node);

            //Next we load remotes
            node    = doc.SelectSingleNode("/def:Definition/def:Remotes", nsMgr);
            Remotes = new RemoteList(node);
            Remotes.ButtonPressed += ProcessDeviceEvent;

            //Loading list of schedules
            node      = doc.SelectSingleNode("/def:Definition/def:Schedules", nsMgr);
            Schedules = new ScheduleList(node);
            Schedules.ScheduleFired += ProcessDeviceEvent;

            //Finally we load zones
            node  = doc.SelectSingleNode("/def:Definition/def:Zones", nsMgr);
            Zones = new ZoneList(node, Gateways, ProcessChangedDeviceState, ProcessDeviceEvent);

            TriggerStartupCommands();

            queueCleanUpTimer.Elapsed += new ElapsedEventHandler(CleanUpCommandQueue);
            queueCleanUpTimer.Enabled  = true;

            //Creating command server for external commands (Alexa, Mobile App, etc - received from IIS gateway)
            CommandServer.CommandServer comSrv = new CommandServer.CommandServer(GetCurrentDeviceState, SimulateSpecificCommand);
            host = new ServiceHost(comSrv);
            host.Open();
        }