Exemple #1
0
        public override void Start()
        {
            logger.Log("Started: {0}", ToString());

            SmartCamSvc service = new SmartCamSvc(logger, this);

            serviceHost = new SafeServiceHost(logger, typeof(ISmartCamContract), service, this, Constants.AjaxSuffix, moduleInfo.BaseURL());
            serviceHost.Open();

            appServer = new WebFileServer(moduleInfo.BinaryDir(), moduleInfo.BaseURL(), logger);

            this.videosDir     = moduleInfo.WorkingDir() + "\\" + VIDEO_SUB_DIR_NAME;
            this.videosBaseUrl = moduleInfo.BaseURL() + "/" + VIDEO_SUB_DIR_NAME;

            recordingServer = new WebFileServer(videosDir, videosBaseUrl, logger);

            logger.Log("camera service is open for business at " + moduleInfo.BaseURL());

            //..... get the list of current ports from the platform
            IList <VPort> allPortsList = GetAllPortsFromPlatform();

            if (allPortsList != null)
            {
                foreach (VPort port in allPortsList)
                {
                    PortRegistered(port);
                }
            }
        }
Exemple #2
0
        public override void Start()
        {
            logger.Log("Started: {0} ", ToString());

            DummyService dummyService = new DummyService(logger, this);

            serviceHost = new SafeServiceHost(logger, typeof(IDummyContract), dummyService, this, Constants.AjaxSuffix, moduleInfo.BaseURL());
            serviceHost.Open();

            appServer = new WebFileServer(moduleInfo.BinaryDir(), moduleInfo.BaseURL(), logger);


            //........... instantiate the list of other ports that we are interested in
            accessibleDummyPorts = new List <VPort>();

            //..... get the list of current ports from the platform
            IList <VPort> allPortsList = GetAllPortsFromPlatform();

            if (allPortsList != null)
            {
                ProcessAllPortsList(allPortsList);
            }

            this.receivedMessageList = new List <string>();

            // remoteSync flag can be set to true, if the Platform Settings has the Cloud storage
            // information i.e., DataStoreAccountName, DataStoreAccountKey values
            datastream = base.CreateValueDataStream <StrKey, StrValue>("test", true /* remoteSync */);

            worker = new SafeThread(delegate()
            {
                Work();
            }, "AppDummy-worker", logger);
            worker.Start();
        }
        public override void Start()
        {
            logger.Log("Started: {0}", ToString());

            service = new AppValveControllerService(this, logger);

            serviceHost = AppValveControllerService.CreateServiceHost(logger, this, service, moduleInfo.BaseURL() + "/webapp");

            serviceHost.Open();

            webUiServer = new WebFileServer(moduleInfo.BinaryDir(), moduleInfo.BaseURL(), logger);

            logger.Log("{0}: service is open for business at {1}", ToString(), moduleInfo.BaseURL());

            //... get the list of current ports from the platform
            IList <VPort> allPortsList = GetAllPortsFromPlatform();

            if (allPortsList != null)
            {
                foreach (VPort port in allPortsList)
                {
                    PortRegistered(port);
                }
            }
        }
Exemple #4
0
        /// <summary>
        /// Starts the web service and initializes/registers the ports
        /// </summary>
        public override void Start()
        {
            logger.Log("Started: {0} ", ToString());

            MentalHouseService mentalService = new MentalHouseService(logger, this);

            serviceHost = new SafeServiceHost(logger, typeof(IMentalHouseContract), mentalService, this, Constants.AjaxSuffix, moduleInfo.BaseURL());
            serviceHost.Open();

            appServer = new WebFileServer(moduleInfo.BinaryDir(), moduleInfo.BaseURL(), logger);


            //Get the list of current ports from the platform
            IList <VPort> allPortsList = GetAllPortsFromPlatform();

            if (allPortsList != null)
            {
                foreach (VPort port in allPortsList)
                {
                    PortRegistered(port);
                }
            }

            this.receivedMessageList = new List <string>();
        }
Exemple #5
0
        public override void Start()
        {
            //Using "Sensor:" to indicate clearly in the log where this line came from.
            logger.Log("Sensor:Started: {0} ", ToString());


            SensorAppService sensorService = new SensorAppService(logger, this);

            serviceHost = new SafeServiceHost(logger, typeof(IDigitalMediaContract), sensorService, this, Constants.AjaxSuffix, moduleInfo.BaseURL());
            serviceHost.Open();

            appServer = new WebFileServer(moduleInfo.BinaryDir(), moduleInfo.BaseURL(), logger);


            //........... instantiate the list of other ports that we are interested in
            accessibleSensorPorts = new List <VPort>();

            //..... get the list of current ports from the platform
            IList <VPort> allPortsList = GetAllPortsFromPlatform();

            if (allPortsList != null)
            {
                ProcessAllPortsList(allPortsList);
            }

            this.receivedMessageList = new Queue <string>();


            //gAlertEmailAddress = GetPrivateConfSetting("NotificationEmail");
            gHome_Id = GetConfSetting("HomeId");

            //location to save information
            Directory.CreateDirectory(moduleInfo.WorkingDir());
        }
Exemple #6
0
        public override void Start()
        {
            logger.Log("Started: {0} ", ToString());

            BluetoothAppService bluetoothService = new BluetoothAppService(logger, this);

            serviceHost = new SafeServiceHost(logger, typeof(IBluetoothAppContract), bluetoothService, this, Constants.AjaxSuffix, moduleInfo.BaseURL());
            serviceHost.Open();
            //create the app server
            appServer = new WebFileServer(moduleInfo.BinaryDir(), moduleInfo.BaseURL(), logger);
            //Create a new thread that will try connect to all configured device asynchroniously every 10 sec
            worker = new SafeThread(delegate() { tryConnectToDevices(); }, "AppBluetoothPing-worker", logger);
            worker.Start();
        }
        public override void Start()
        {
            logger.Log("Started: {0} ", ToString());

            PowerMeterService powermeterService = new PowerMeterService(logger, this);

            serviceHost = new SafeServiceHost(logger, typeof(IPowerMeterContract), powermeterService, this, Constants.AjaxSuffix, moduleInfo.BaseURL());
            serviceHost.Open();

            appServer = new WebFileServer(moduleInfo.BinaryDir(), moduleInfo.BaseURL(), logger);


            //........... instantiate the list of other ports that we are interested in
            accessiblePowerMeterPorts = new List <VPort>();

            //..... get the list of current ports from the platform
            IList <VPort> allPortsList = GetAllPortsFromPlatform();

            if (allPortsList != null)
            {
                ProcessAllPortsList(allPortsList);
            }

            this.receivedMessageList = new List <string>();

            // remoteSync flag can be set to true, if the Platform Settings has the Cloud storage
            // information i.e., DataStoreAccountName, DataStoreAccountKey values
            datastream = base.CreateFileStream <StrKey, StrValue>("dumb", false /* remoteSync */);


            //you can change SerialportName:"COM3",Maybe yours is not "COM3"
            foreach (VPort port in accessiblePowerMeterPorts)
            {
                Invoke(port, RolePowerMeter.Instance, RolePowerMeter.OpOpenSerialPort, new ParamType(ParamType.SimpleType.text, "SerialPortName", "COM3"));
            }

            SendCommand("status");

            GetAllPowerMeterStatus();

            worker = new SafeThread(delegate()
            {
                Work();
            }, "AppPowerMeter-worker", logger);
            worker.Start();
        }
        public override void Start()
        {
            logger.Log("Started: {0} ", ToString());

            AirConditionCtrlService airConditionCtrlService = new AirConditionCtrlService(logger, this);

            serviceHost = new SafeServiceHost(logger, typeof(IAirConditionCtrlContract), airConditionCtrlService, this, Constants.AjaxSuffix, moduleInfo.BaseURL());
            serviceHost.Open();

            appServer = new WebFileServer(moduleInfo.BinaryDir(), moduleInfo.BaseURL(), logger);


            //........... instantiate the list of other ports that we are interested in
            accessibleAirConditionCtrlPorts = new List <VPort>();

            //..... get the list of current ports from the platform
            IList <VPort> allPortsList = GetAllPortsFromPlatform();

            if (allPortsList != null)
            {
                ProcessAllPortsList(allPortsList);
            }

            receivedMessageList = new List <string>();

            readMsgByIdList = new List <string>();
            rcvdNewMsgList  = new List <string>();
            //remoteSync flag can be set to true, if the Platform Settings has the Cloud storage
            //information i.e., DataStoreAccountName, DataStoreAccountKey values
            datastream = base.CreateFileStream <StrKey, StrValue>("dumb", false /* remoteSync */);

            worker = new SafeThread(delegate()
            {
                Work();
            }, "AppAirConditionCtrl-worker", logger);
            worker.Start();


            //gm.ComPort = "COM6";
            //gm.BaudRate = 9600;
            //gm.Open();


            //gm.SmsRecieved += new EventHandler(gm_SmsRecieved);
        }
Exemple #9
0
        public BluetoothScoutService(string baseAddress, BluetoothScout btScout, ScoutViewOfPlatform platform, VLogger logger)
        {
            this.logger         = logger;
            this.bluetoothScout = btScout;

            service = new SafeServiceHost(logger, platform, this, baseAddress);

            var contract = ContractDescription.GetContract(typeof(IBluetoothScoutContract));

            var webBinding  = new WebHttpBinding();
            var webEndPoint = new ServiceEndpoint(contract, webBinding, new EndpointAddress(baseAddress));

            webEndPoint.EndpointBehaviors.Add(new WebHttpBehavior());

            service.AddServiceEndpoint(webEndPoint);
            service.AddServiceMetadataBehavior(new ServiceMetadataBehavior());

            service.Open();
        }
Exemple #10
0
        public override void Start()
        {
            //Using "Sensor:" to indicate clearly in the log where this line came from.
            logger.Log("Sensor:Started: {0} ", ToString());

            // remoteSync flag can be set to true, if the Platform Settings has the Cloud storage
            // information i.e., DataStoreAccountName, DataStoreAccountKey values
            datastream = base.CreateValueDataStream <StrKey, StrValue>("data", true, 10 * 60);

            SensorService sensorService = new SensorService(logger, this);

            serviceHost = new SafeServiceHost(logger, typeof(ISensorContract), sensorService, this, Constants.AjaxSuffix, moduleInfo.BaseURL());
            serviceHost.Open();

            appServer = new WebFileServer(moduleInfo.BinaryDir(), moduleInfo.BaseURL(), logger);


            //........... instantiate the list of other ports that we are interested in
            accessibleSensorPorts = new List <VPort>();

            //..... get the list of current ports from the platform
            IList <VPort> allPortsList = GetAllPortsFromPlatform();

            if (allPortsList != null)
            {
                ProcessAllPortsList(allPortsList);
            }

            this.receivedMessageList = new Queue <string>();
            mTimer          = new Timer(60000); //1 minute
            mTimer.Elapsed += new ElapsedEventHandler(doDataMonitoring);

            gAlertEmailAddress = GetPrivateConfSetting("NotificationEmail");
            gHome_Id           = GetConfSetting("HomeId");

            //location to save information
            Directory.CreateDirectory(moduleInfo.WorkingDir());

            gMonitoringMemoryFile = moduleInfo.WorkingDir() + "\\" + "monitoringMemory.txt";

            CheckForPreviousMonitoringValues();
        }
Exemple #11
0
        public override void Start()
        {
            logger.Log("Started: {0}", ToString());

            SwitchSvc service = new SwitchSvc(logger, this);

            serviceHost = new SafeServiceHost(logger, typeof(ISwitchSvcContract), service, this, Constants.AjaxSuffix, moduleInfo.BaseURL());
            serviceHost.Open();

            appServer = new WebFileServer(moduleInfo.BinaryDir(), moduleInfo.BaseURL(), logger);

            logger.Log("switch controller is open for business at " + moduleInfo.BaseURL());

            //..... get the list of current ports from the platform
            IList <VPort> allPortsList = GetAllPortsFromPlatform();

            foreach (VPort port in allPortsList)
            {
                PortRegistered(port);
            }
        }
Exemple #12
0
        public KinectScoutService(string baseAddress, KinectScout kinectScout, ScoutViewOfPlatform platform, VLogger logger)
        {
            this.logger      = logger;
            this.kinectScout = kinectScout;

            service = new SafeServiceHost(logger, platform, this, baseAddress);

            var contract = ContractDescription.GetContract(typeof(IKinectScoutContract));

            var webBinding  = new WebHttpBinding();
            var webEndPoint = new ServiceEndpoint(contract, webBinding, new EndpointAddress(baseAddress));

            webEndPoint.EndpointBehaviors.Add(new WebHttpBehavior());

            service.AddServiceEndpoint(webEndPoint);

            //service.Description.Behaviors.Add(new ServiceMetadataBehavior());
            //service.AddServiceEndpoint(typeof(IMetadataExchange), MetadataExchangeBindings.CreateMexHttpBinding(), "mex");
            service.AddServiceMetadataBehavior(new ServiceMetadataBehavior());

            service.Open();
        }
Exemple #13
0
        public override void Start()
        {
            logger.Log("Started: {0} ", ToString());

            WeatherService dummyService = new WeatherService(logger, this);

            serviceHost = new SafeServiceHost(logger, typeof(IWeatherContract), dummyService, this, Constants.AjaxSuffix, moduleInfo.BaseURL());
            serviceHost.Open();

            appServer = new WebFileServer(moduleInfo.BinaryDir(), moduleInfo.BaseURL(), logger);


            //........... instantiate the list of other ports that we are interested in
            accessibleWeatherPorts = new List <VPort>();

            //..... get the list of current ports from the platform
            IList <VPort> allPortsList = GetAllPortsFromPlatform();

            if (allPortsList != null)
            {
                ProcessAllPortsList(allPortsList);
            }
        }
Exemple #14
0
 protected override void OnStart(string[] args)
 {
     try
     {
         foreach (ServiceHostFactory factory in _serviceHostsFactories)
         {
             SafeServiceHost host = factory.Create();
             host.Open();
             _hosts.Add(host);
         }
     }
     catch (Exception ex)
     {
         _logger.Error(ex);
         LogEvent($"OnStart: {ex}");
         SentrySdk.WithScope(scope =>
         {
             scope.Level = SentryLevel.Error;
             scope.SetTag("captured_in", "Service_OnStart");
             SentrySdk.CaptureException(ex);
         });
     }
 }
Exemple #15
0
        public override void Start()
        {
            logger.Log("Started: {0} ", ToString());

            DoorjambService simplexService = new DoorjambService(logger, this);

            simplexServiceHost = DoorjambService.CreateServiceHost(logger, this, simplexService, moduleInfo.BaseURL() + "/webapp");

            simplexServiceHost.Open();

            appServer = new WebFileServer(moduleInfo.BinaryDir(), moduleInfo.BaseURL(), logger);


            //........... instantiate the list of other ports that we are interested in
            accessibleDoorjambPorts = new List <VPort>();

            //..... get the list of current ports from the platform
            IList <VPort> allPortsList = GetAllPortsFromPlatform();

            if (allPortsList != null)
            {
                ProcessAllPortsList(allPortsList);
            }

            this.receivedMessageList = new List <string>();
            this.irDataList          = new List <string>();
            this.irDataList.Add("");
            this.usDataList = new List <string>();
            this.usDataList.Add("");
            this.eventTime = "";

            worker = new SafeThread(delegate()
            {
                Work();
            }, "AppDoorjamb-worker", logger);
            worker.Start();
        }
Exemple #16
0
        ////Email address to receive the alert pictures.
        //string emailAdrs;

        public override void Start()
        {
            logger.Log("Started: {0}", ToString());

            try
            {
                settings = new AlertSettings();


                settings.Mode = (moduleInfo.Args().Length > 0) ?
                                (AlertMode)Enum.Parse(typeof(AlertMode), moduleInfo.Args()[0], true) :
                                AlertMode.emailonly;

                settings.StartHourMin = (moduleInfo.Args().Length > 1) ? int.Parse(moduleInfo.Args()[1]) : 0;

                settings.EndHourMin = (moduleInfo.Args().Length > 2) ? int.Parse(moduleInfo.Args()[2]) : 2400;

                settings.SuppressSeconds = (moduleInfo.Args().Length > 3) ? int.Parse(moduleInfo.Args()[3]) : 5;  //AJB shorten suppression

                settings.UserName = (moduleInfo.Args().Length > 4) ? moduleInfo.Args()[4] : "user";

                settings.emailAddress = GetPrivateConfSetting("NotificationEmail");
            }
            catch (Exception exception)
            {
                logger.Log("{0}: error parsing arguments: {1}", exception.ToString(), String.Join(" ", moduleInfo.Args()));
            }

            picStream  = base.CreateFileDataStream <StrKey, ByteValue>("H2OAlertsPics", true, 0);
            textStream = base.CreateValueDataStream <StrKey, StrValue>("H2OAlertsText", true, 0);

            DoorNotifierSvc service = new DoorNotifierSvc(logger, this);

            //serviceHost = DoorNotifierSvc.CreateServiceHost(
            //    service,
            //    new Uri(moduleInfo.BaseURL()+"/webapp"));

            serviceHost = DoorNotifierSvc.CreateServiceHost(logger, this, service, moduleInfo.BaseURL() + "/webapp");

            serviceHost.Open();

            webUiServer = new WebFileServer(moduleInfo.BinaryDir(), moduleInfo.BaseURL(), logger);

            logger.Log("{0}: service is open for business at {1}", ToString(), moduleInfo.BaseURL());

            //no services are exported by this application

            //..... get the list of current ports from the platform
            IList <VPort> allPortsList = GetAllPortsFromPlatform();

            if (allPortsList != null)
            {
                foreach (VPort port in allPortsList)
                {
                    PortRegistered(port);
                }
            }

            //insert a fake notification for testing
            Alert newAlert = new Alert()
            {
                TimeTriggered      = DateTime.Now,
                SensorFriendlyName = "fake sensor",
                SensorLocation     = "fake location",
                Value        = 1,
                Acknowledged = false,
            };

            InsertAlert(newAlert);
        }