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() { 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); }
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()); }
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 void Init(string baseUrl, string baseDir, ScoutViewOfPlatform platform, VLogger logger) { this.baseUrl = baseUrl; this.platform = platform; this.logger = logger; scoutService = new GadgeteerScoutService(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("GadgeteerScout initialized"); }
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); }
/// <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>(); }
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() { 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 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); }
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()); 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); }
/// <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); }
public void Init(string baseUrl, string baseDir, ScoutViewOfPlatform platform, VLogger logger) { this.baseUrl = baseUrl; this.platform = platform; this.logger = logger; scoutService = new DummyScoutService(baseUrl + "/webapp", this, platform, logger); appServer = new WebFileServer(baseDir, baseUrl, logger); logger.Log("DummyScout initialized"); }
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"); }
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 void Init(string baseUrl, string baseDir, ScoutViewOfPlatform platform, VLogger logger) { this.baseUrl = baseUrl; this.platform = platform; this.logger = logger; dmConfig = new DigitalMediaConfiguration(baseDir, platform, logger); scoutService = new DigitalMediaScoutService(baseUrl + "/webapp", this, platform, logger); appServer = new WebFileServer(baseDir, baseUrl, logger); logger.Log("DigitalMediaScout initialized"); }
public CoordinatorMonitor(Coordinator coordinator) { this.coordinator = coordinator; context = GlobalHost.ConnectionManager.GetHubContext <MonitorHub>(); connections = new ClientConnectionHandler(context); coordinator.DispatcherConnections.EndpointAdded += OnDispatcherAdded; coordinator.DispatcherConnections.EndpointRemoved += OnDispatcherRemoved; coordinator.AgentConnections.EndpointAdded += OnAgentAdded; coordinator.AgentConnections.EndpointRemoved += OnAgentRemoved; var hostUrl = Permissions.GetHostUrl(Constants.Ports.CoordinatorWebHost); webFileServer = new WebFileServer(hostUrl, Path.Combine(Environment.CurrentDirectory, @"Content\Coordinator")); }
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); }
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); }
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(); }
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 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() { 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()); 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() { 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(); }
////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); }
public override void Start() { 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; } 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("axiscamera-" + cameraId); List <VRole> roles = CameraRoles(cameraId); cameraPort = InitPort(pInfo); BindRoles(cameraPort, roles, OnOperationInvoke); RegisterPortWithPlatform(cameraPort); worker = new SafeThread(delegate() { GetVideo(); }, "", logger); worker.Start(); imageServer = new WebFileServer(moduleInfo.BinaryDir(), moduleInfo.BaseURL(), logger); }