Exemplo n.º 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);
                }
            }
        }
        public override void Start()
        {
            
           

            logger.Log("Started: {0} ", ToString());
            
            string meterDevice = moduleInfo.Args()[0];

            //Instantiate the port
            VPortInfo portInfo = GetPortInfoFromPlatform(meterDevice);
            powermeterPort = InitPort(portInfo);
            //Initialize the list of roles we are going to export and bind to the role
            List<VRole> listRole = new List<VRole>() {RolePowerMeter.Instance};
            BindRoles(powermeterPort, listRole);

            //Register the port after the binding is complete
            RegisterPortWithPlatform(powermeterPort);

            imageServer = new WebFileServer(moduleInfo.BinaryDir(), moduleInfo.BaseURL(), logger);
            
         
            System.Threading.Thread.Sleep(1 * 10 * 1000);
           
          
        }
Exemplo n.º 3
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();
        }
        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);
                }
            }
        }
        public override void Start()
        {
            try
            {
                string[] words = moduleInfo.Args();

                deviceId = words[0];
            }
            catch (Exception e)
            {
                logger.Log("{0}: Improper arguments: {1}. Exiting module", this.ToString(), e.ToString());
                return;
            }

            //get the IP address
            PortName = GetDevicePort(deviceId);
            logger.Log("Got a port name of {0}", new string[] { PortName });

            if (PortName == null)
            {
                logger.Log("{0} did not get a device ip for deviceId: {1}. Returning", base.moduleInfo.BinaryName(), deviceId.ToString());
                return;
            }

            //add the service port
            VPortInfo pInfo = GetPortInfoFromPlatform("valve-" + deviceId);
            devicePort = InitPort(pInfo);

            // add role and register with platform
            BindRoles(devicePort, GetRoleList(), OnOperationInvoke);
            RegisterPortWithPlatform(devicePort);

            imageServer = new WebFileServer(moduleInfo.BinaryDir(), moduleInfo.BaseURL(), logger);
        }
        public override void Start()
        {
            logger.Log("Started: {0} ", ToString());

            DummyService dummyService = new DummyService(logger, this);
            serviceHost = new SafeServiceHost(logger,typeof(IMatlabInterfaceContract), 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>();
            this.receivedMessageListMatlab = 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", false /* remoteSync */);

            worker = new SafeThread(delegate()
            {
                Work();
            }, "AppDummy-worker", logger);
            worker.Start();
        }
Exemplo n.º 7
0
        public override void Start()
        {

            logger.Log("Started: {0}", ToString());

            try
            {
                string[] words = moduleInfo.Args();

                bridgeId = words[0];
                bridgeUser = words[1];
            }
            catch (Exception e)
            {
                logger.Log("{0}: Improper arguments: {1}. Exiting module", this.ToString(), e.ToString());
                return;
            }

            //get the IP address
            bridgeIp = GetBridgeIp(bridgeId);

            if (bridgeIp == null)
                return;

            lightManager = new LightsManager(bridgeIp, bridgeUser, logger);

            
            workThread = new SafeThread(delegate() {InitBridge(); } , "HueBridge init thread" , logger);
            workThread.Start();

            imageServer = new WebFileServer(moduleInfo.BinaryDir(), moduleInfo.BaseURL(), logger);
        }
Exemplo n.º 8
0
        public override void Start()
        {
            if (moduleInfo.Args().Length == 0 || moduleInfo.Args()[0].Equals(""))
            {
                ListAvailableCameras();
                return;
            }

            cameraStr = moduleInfo.Args()[0];

            _frameSource = FindConnectedCamera(cameraStr);

            if (_frameSource != null)
            {
                InitCamera(_frameSource);
            }
            else 
            {
                logger.Log("Camera matching {0} not found", cameraStr);
                ListAvailableCameras();
                logger.Log("Will keep looking");
            }

            cameraSearchTimer = new Timer(PeriodicCameraSearch, null, (int) SearchPeriod.TotalMilliseconds, (int) SearchPeriod.TotalMilliseconds);

            imageServer = new WebFileServer(moduleInfo.BinaryDir(), moduleInfo.BaseURL(), logger);
        }
        public override void Start()
        {
            logger.Log("Started: {0}", ToString());

            string dummyDeviceId = moduleInfo.Args()[0];
            serialPortNameforArudino = moduleInfo.Args()[1];

            //.... Open the serial port - AJB TODO - error checking on port name
            serialPortOpen = OpenSerialPort();
         
            //.................instantiate the port
            VPortInfo portInfo = GetPortInfoFromPlatform("arduino-" + dummyDeviceId);
            dummyPort = InitPort(portInfo);

            // ..... initialize the list of roles we are going to export and bind to the role
            List<VRole> listRole = new List<VRole>() { RoleDummy.Instance};
            BindRoles(dummyPort, listRole);

            //.................register the port after the binding is complete
            RegisterPortWithPlatform(dummyPort);

            workThread = new SafeThread(delegate() { Work(); } , "ArduinoDriverDummy work thread" , logger);
            workThread.Start();

            imageServer = new WebFileServer(moduleInfo.BinaryDir(), moduleInfo.BaseURL(), logger);
        }
        public override void Start()
        {
            logger.Log("Started: {0}", ToString());

            string airConditionCtrlDevice = moduleInfo.Args()[0];

            //.................instantiate the port
            VPortInfo portInfo = GetPortInfoFromPlatform(airConditionCtrlDevice);
            airConditionCtrlPort = InitPort(portInfo);

            // ..... initialize the list of roles we are going to export and bind to the role
            List<VRole> listRole = new List<VRole>() { RoleSwitchMultiLevel.Instance };
            BindRoles(airConditionCtrlPort, listRole);

            //.................register the port after the binding is complete
            RegisterPortWithPlatform(airConditionCtrlPort);

            workThread = new SafeThread(delegate() { Work(); }, "DriverAirConditionCtrl work thread", logger);
            workThread.Start();

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

            gm.ComPort = "COM6";
            gm.BaudRate = 9600;
            gm.Open();
            gm.SmsRecieved+=new EventHandler(gm_SmsRecieved);

            
        
        }
Exemplo n.º 11
0
        public void Init(string baseUrl, string baseDir, ScoutViewOfPlatform platform, VLogger logger) {
            this.baseUrl = baseUrl;
            this.platform = platform;
            this.logger = logger;

            scoutService = new BluetoothScoutService(baseUrl + "/webapp", this, platform, logger);

            appServer = new WebFileServer(baseDir, baseUrl, logger);

            logger.Log("BluetoothScout initialized.");
        }
Exemplo n.º 12
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 asynchronously every 10 sec
            worker = new SafeThread(delegate() { tryConnectToDevices(); }, "AppBluetoothPing-worker", logger);
            worker.Start();
        }
        public void Init(string baseUrl, string baseDir, ScoutViewOfPlatform platform, VLogger logger)
        {
            this.baseUrl = baseUrl;
            this.platform = platform;
            this.logger = logger;

            scoutService = new SynapseWirelessScoutService(baseUrl + "/webapp", this, logger);

            appServer = new WebFileServer(baseDir, baseUrl, logger);

            startSynapseController();

            logger.Log("SynapseWirelessScout initialized");
        }
Exemplo n.º 14
0
        public void ConfiguredStart()
        {
            string svcBase = Common.Constants.InfoServiceAddress + "/" + Settings.HomeId + "/";

            //let us start serving the files
            string webBase = svcBase + Common.Constants.GuiServiceSuffixWeb;
            webFileServerHomeId = new WebFileServer(Common.Constants.DashboardRoot, webBase, logger);

            serviceHostWebHomeId = OpenSafeServiceWeb(webBase + Common.Constants.AjaxSuffix);

            string webSecBase = svcBase + Common.Constants.GuiServiceSuffixWebSec;

            serviceHostWebSecHomeId = OpenSafeServiceWebSec(webSecBase + Common.Constants.AjaxSuffix);
        }
Exemplo n.º 15
0
        public GuiService(Platform platform, Configuration config, HomeStoreInfo hsInfo, VLogger logger)
        {
            this.platform = platform;
            this.config = config;
            this.homeStoreInfo = hsInfo;
            this.logger = logger;

            string svcBase = Common.Constants.InfoServiceAddress + "/" ;

            //let us start serving the files
            string webBase = svcBase + Common.Constants.GuiServiceSuffixWeb;
            webFileServer = new WebFileServer(Common.Constants.DashboardRoot, webBase, logger);

            serviceHostWeb = OpenUnsafeServiceWeb(webBase + Common.Constants.AjaxSuffix);
        }
Exemplo n.º 16
0
        public void Init(string baseUrl, string baseDir, ScoutViewOfPlatform platform, VLogger logger)
        {
            this.baseUrl = baseUrl;
            this.platform = platform;
            this.logger = logger;

            scoutService = new AxisCamScoutService(baseUrl + "/webapp", this, logger);

            appServer = new WebFileServer(baseDir, baseUrl, logger);

            logger.Log("AxisCamScout initialized");

            //create a time that fires ScanNow() periodically
            var scanTimer = new System.Timers.Timer(ScoutHelper.DefaultDeviceDiscoveryPeriodSec * 1000);
            scanTimer.Enabled = true;
            scanTimer.Elapsed += new System.Timers.ElapsedEventHandler(ScanNow);
        }
Exemplo n.º 17
0
        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();

        }
Exemplo n.º 18
0
        public void Init(string baseUrl, string baseDir, ScoutViewOfPlatform platform, VLogger logger)
        {
            this.baseUrl = baseUrl;
            this.platform = platform;
            this.logger = logger;

            scoutService = new OwmScoutService(baseUrl + "/webapp", this, platform, logger);

            appServer = new WebFileServer(baseDir, baseUrl, logger);

            //initialize the device we'll use
            device = new Device("OpenWeatherMap", UniqueDeviceId(), "", DateTime.Now, "HomeOS.Hub.Drivers.OpenWeatherMap");

            // the parameters are: uniqueName, appid, lattitude, longitude
            device.Details.DriverParams = new List<string>() { device.UniqueName, DefaultAppId, "", "" };

            logger.Log("DummyScout initialized");
        }
        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);
            }
        }
        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);

          }
Exemplo n.º 21
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);
        }
        public override void Start()
        {
            try
            {
                string[] words = moduleInfo.Args();

                deviceId = words[0];
            }
            catch (Exception e)
            {
                logger.Log("{0}: Improper arguments: {1}. Exiting module", this.ToString(), e.ToString());
                return;
            }

            //get the IP address
            deviceIp = GetDeviceIp(deviceId);

            if (deviceIp == null)
            {
                logger.Log("{0} did not get a device ip for deviceId: {1}. Returning", base.moduleInfo.BinaryName(), deviceId.ToString());
                return;
            }

            //add the service port
            VPortInfo pInfo = GetPortInfoFromPlatform("gadgeteer-" + deviceId);
            devicePort = InitPort(pInfo);

            // add role and register with platform
            BindRoles(devicePort, GetRoleList(), OnOperationInvoke);
            RegisterPortWithPlatform(devicePort);

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

            imageServer = new WebFileServer(moduleInfo.BinaryDir(), moduleInfo.BaseURL(), logger);
        }
        public override void Start()
        {
            logger.Log("Started: {0}", ToString());

            string dummyDevice = moduleInfo.Args()[0];

            //.................instantiate the port
            VPortInfo portInfo = GetPortInfoFromPlatform(dummyDevice);
            dummyPort = InitPort(portInfo);

            // ..... initialize the list of roles we are going to export and bind to the role
            List<VRole> listRole = new List<VRole>() { RoleProximitySensor.Instance };
            BindRoles(dummyPort, listRole);

            //.................register the port after the binding is complete
            RegisterPortWithPlatform(dummyPort);

            workThread = new SafeThread(delegate() { Work(); } , "DriverBLEProximity work thread" , logger);
            workThread.Start();

            imageServer = new WebFileServer(moduleInfo.BinaryDir(), moduleInfo.BaseURL(), logger);
        }
Exemplo n.º 24
0
        public void Init(string baseUrl, string baseDir, ScoutViewOfPlatform platform, VLogger logger)
        {
            this.baseUrl = baseUrl;
            this.platform = platform;
            this.logger = logger;

            scoutService = new ValveScoutService(baseUrl + "/webapp", this, platform, logger);

            appServer = new WebFileServer(baseDir, baseUrl, logger);

            //IPEndPoint endpoint = new IPEndPoint(IPAddress.Any, listenPortNumber);
            //listenClient = new UdpClient(endpoint);

            //listenClient.Client.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.PacketInformation, true);
            //listenClient.Client.BeginReceiveMessageFrom(asyncBuffer, 0, 2000, asyncSocketFlags, ref asyncRemoteEndPoint, new AsyncCallback(ReceiveCallback), null);

            //create a time that fires ScanNow() periodically
            var scanTimer = new Timer(ScoutHelper.DefaultDeviceDiscoveryPeriodSec * 1000);
            scanTimer.Enabled = true;
            scanTimer.Elapsed += new ElapsedEventHandler(ScanNow);

            logger.Log("ValveScout initialized");
        }
Exemplo n.º 25
0
        public override void Start()
        {
            //Using "Sensor:" to indicate clearly in the log where this line came from.
            logger.Log("Sensor:Started: {0} ", ToString());
           

            SensorDBService sensorService = new SensorDBService(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>();
             

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

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

            //#########test to see if insert (to db) operation works###############
            for (int i = 1; i < 10;i++ )
                WriteToDB("_test_", i);
            //#####################################################################
 
        }
Exemplo n.º 26
0
        /// <summary>
        /// Tries to start a connection with the "ThinkGearConnector" app.
        /// </summary>
        public override void Start()
        {
            //Try to connect to "ThinkGearConnector"
            try { client = new TcpClient("127.0.0.1", 13854); }
            catch { throw new Exception("You must install the \"ThinkGearConnector\" [http://developer.neurosky.com/docs/doku.php?id=thinkgear_connector_tgc]"); }

            logger.Log("Started: {0}", ToString());
            
            string mindWaveDevice = moduleInfo.Args()[0];

            //Instantiate the port
            VPortInfo portInfo = GetPortInfoFromPlatform(mindWaveDevice);
            mindWavePort = InitPort(portInfo);
            //Initialize the list of roles we are going to export and bind to the role
            List<VRole> listRole = new List<VRole>() { RoleMindWave.Instance };
            BindRoles(mindWavePort, listRole);
            //Register the port after the binding is complete
            RegisterPortWithPlatform(mindWavePort);

            workThread = new SafeThread(delegate() { Work(); } , "DriverMindWave work thread" , logger);
            workThread.Start();

            imageServer = new WebFileServer(moduleInfo.BinaryDir(), moduleInfo.BaseURL(), logger);
        }
Exemplo n.º 27
0
        public override void Start()
        {
            worker1 = null;
            worker2 = null;
            _mjpeg = null;
            fileToRead = Constants.AddInRoot + "\\AddIns\\" + moduleInfo.BinaryName() + "\\logo-green.jpg";

            try
            {
                string[] words = moduleInfo.Args();

                cameraId = words[0];
                cameraUser = words[1];
                cameraPwd = words[2];
            }
            catch (Exception e)
            {
                logger.Log("{0}: Improper arguments: {1}. Exiting module", this.ToString(), e.ToString());
                return;
            }

            //get the IP address
            cameraIp = GetCameraIp(cameraId);

            if (cameraIp == null)
                return;

            //check the username and password
            cameraCredential = new NetworkCredential(cameraUser, cameraPwd);

            try
            {
                HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(CameraUrl);
                webRequest.Credentials = cameraCredential;
                HttpWebResponse webResponse = (HttpWebResponse)webRequest.GetResponse();

                if (webResponse.StatusCode == HttpStatusCode.Unauthorized)
                {
                    logger.Log("{0} credentials ({1}/{2}) are not correct", this.ToString(), cameraUser, cameraPwd);
                    return;
                }

                logger.Log("Started: {0} with response code {1}", ToString(), webResponse.StatusCode.ToString());
                webResponse.Close();
            }
            catch (Exception e)
            {
                logger.Log("{0}: couldn't talk to the camera. are the arguments correct?\n exception details: {1}", this.ToString(), e.ToString());

                //don't return. maybe the camera will come online later
                //return;
            }

            //add the camera service port
            VPortInfo pInfo = GetPortInfoFromPlatform("foscam-" + cameraId);

            //List<VRole> roles = new List<VRole>() {RoleCamera.Instance, RolePTCamera.Instance};
            List<VRole> roles = new List<VRole>() { RolePTCamera.Instance };

            cameraPort = InitPort(pInfo);
            BindRoles(cameraPort, roles, OnOperationInvoke);

            RegisterPortWithPlatform(cameraPort);

            switch (videoFetchMode)
            {
                case VideoFetchMode.SelfParse:
                    worker1 = new SafeThread(delegate()
                    {
                        GetVideoSelfParse();
                    }, "GetVideoSelfParse", logger);
                    worker1.Start();
                    break;
                case VideoFetchMode.FromFile:
                    worker2 = new SafeThread(delegate()
                    {
                        GetVideoFromFile();
                    }, "GetVideoFromFile", logger);
                    worker2.Start();
                    break;
                case VideoFetchMode.MjpegDecoder:
                    GetVideoMjpegDecoder();
                    break;
                default:
                    logger.Log("Unknown video fetching mode");
                    break;
            }

            imageServer = new WebFileServer(moduleInfo.BinaryDir(), moduleInfo.BaseURL(), logger);
        }
Exemplo n.º 28
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();

        }
Exemplo n.º 29
0
        public override void Start()
        {
            if (moduleInfo.Args().Length == 0 || moduleInfo.Args()[0].Equals(""))
            {
                ListAvailableCameras();
                return;
            }

            string cameraStr = moduleInfo.Args()[0];

            foreach (Camera camera in CameraService.AvailableCameras)
            {
                //if (camera.ToString().ToLower().Contains(cameraStr))
                //{
                //    _frameSource = new CameraFrameSource(camera);
                //    break;
                //}

                if (cameraStr.ToLower().Contains(camera.ToString().ToLower()))
                {
                    _frameSource = new CameraFrameSource(camera);
                    break;
                }
            }

            if (_frameSource == null)
            {
                logger.Log("Camera matching {0} not found", cameraStr);
                ListAvailableCameras();
                return;
            }

            logger.Log("Will use camera {0}", _frameSource.Camera.ToString());

            //add the camera service port
            VPortInfo pInfo = GetPortInfoFromPlatform("webcam - " + cameraStr);

            List<VRole> roles = new List<VRole>() {RoleCamera.Instance};

            cameraPort = InitPort(pInfo);
            BindRoles(cameraPort, roles, OnOperationInvoke);

            RegisterPortWithPlatform(cameraPort);
            worker = new SafeThread(delegate()
            {
                GetVideo();
            }, "DriverWebCam-GetVideo", logger);
            worker.Start();

            imageServer = new WebFileServer(moduleInfo.BinaryDir(), moduleInfo.BaseURL(), logger);
        }
Exemplo n.º 30
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()));
            }

            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);
        }