public override void Start() { logger.Log("Started: {0}", ToString()); string deviceName = moduleInfo.Args()[0]; string deviceAddress = moduleInfo.Args()[1]; string deviceClassType = moduleInfo.Args()[2]; string deviceType = moduleInfo.Args()[3]; //try pair with the device. bool pair = tryPairWithDevice(deviceAddress, deviceType); if (!pair) { //think of something } else { logger.Log("Bluetooth Driver: Paired with \"" + deviceName + " - " + deviceAddress + "\""); } //init the port VPortInfo portInfo = GetPortInfoFromPlatform(deviceName); bluetoothPort = InitPort(portInfo); //init the role List<VRole> listRole = new List<VRole>() { RoleBluetooth.Instance }; BindRoles(bluetoothPort, listRole); //register the port RegisterPortWithPlatform(bluetoothPort); workThread = new SafeThread(delegate() { Work(); }, "DriverBluetooth work thread", logger); workThread.Start(); }
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()); 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(); }
private void RotateLog() { logWriter.Close(); string archivingFile = archivingDirectory + "\\" + GetTimeStamp() + "-" + Path.GetFileName(fName); while (File.Exists(archivingFile) || File.Exists(archivingFile + ".zip")) { archivingFile += ".1"; } File.Move(fName, archivingFile); logWriter = new StreamWriter(fName, true); SafeThread worker = new SafeThread(delegate() { //compress the file CompressFile(archivingFile); //if we are syncing, start that on a separate thread if (synchronizer != null) { synchronizer.Sync(); } }, "post-log-rotation-work", this ); 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> /// Sends a message with the specified payoad from the specified control /// to all ports subscribed to this port. /// </summary> /// <param name="srcControl">The control which originated the notification, /// can be optionally null</param> /// <param name="payload">The message payload</param> public void Notify(string roleName, string opName, IList <HomeOS.Hub.Platform.Views.VParamType> retVals) { lock (this.subscribedPorts) { OperationKey roleOpPair = new OperationKey(opName); if (subscribedPorts.ContainsKey(roleOpPair)) { foreach (SubscriptionInfo sub in subscribedPorts[roleOpPair]) { SubscriptionInfo tmpSub = sub; if (this.ValidateCapability(tmpSub.subscriptionCapbility)) { SafeThread call = new SafeThread(delegate() { tmpSub.subscribedPort.AsyncReturn(roleName, opName, retVals, this, tmpSub.notifyCapability); }, this + "." + opName + "." + tmpSub.ToString(), logger); //call.Name = this + "." + opName + "." + sub.ToString(); call.Start(); } else { logger.Log("WARNING: capability check failed in notify"); } } } } }
/// <summary> /// Invoke an operation exported by the port /// </summary> /// <param name="roleName">The name of the role that contains the operation</param> /// <param name="opName">The name of the operation being subscribed to</param> /// <param name="parameters">The list of parameters to call the operation with</param> /// <param name="fromPort">The port from which subscription is being issued (usually the ControlPort of the calling module) </param> /// <param name="reqCap">The capability for the port to which subscription is being issued</param> /// <param name="respCap">The capability that the notifications should use</param> /// <returns>The list of return values</returns> public override IList <HomeOS.Hub.Platform.Views.VParamType> Invoke(string roleName, string opName, IList <HomeOS.Hub.Platform.Views.VParamType> parameters, HomeOS.Hub.Platform.Views.VPort p, HomeOS.Hub.Platform.Views.VCapability reqCap, HomeOS.Hub.Platform.Views.VCapability respCap) { TimeSpan timeout = Constants.nominalTimeout; IList <HomeOS.Hub.Platform.Views.VParamType> retval = null; OperationKey roleOpPair = new OperationKey(opName); if (!operationDelegates.ContainsKey(roleOpPair) || operationDelegates[roleOpPair] == null) { retval = new List <HomeOS.Hub.Platform.Views.VParamType>(); retval.Add(new ParamType(ParamType.SimpleType.error, Constants.OpDoesNotExistName)); } else { SafeThread call = new SafeThread(delegate() { retval = operationDelegates[roleOpPair](roleName, opName, parameters); }, this + "." + opName, logger); //call.Name = this + "." + opName; call.Start(); call.Join(timeout); if (retval == null) { retval = new List <HomeOS.Hub.Platform.Views.VParamType>(); retval.Add(new ParamType(ParamType.SimpleType.error, Constants.OpNullResponse)); } } return(retval); }
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); }
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(); }
protected override void WorkerThread() { logger.Log("Started: {0}", this.ToString()); 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 ///AJB - how do we know it's a couch? VPortInfo pInfo = GetPortInfoFromPlatform("gadgeteer-" + deviceId); RoleCouch roleCouch = RoleCouch.Instance; List<VRole> roles = new List<VRole>(); roles.Add(roleCouch); devicePort = InitPort(pInfo); BindRoles(devicePort, roles, OnOperationInvoke); RegisterPortWithPlatform(devicePort); worker = new SafeThread(delegate() { PollDevice(); }, "DriverGadgeteerMSREmotoCouch-PollDevice", 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); }
public override void Start() { string[] words = moduleInfo.Args(); video_dir = words[0]; //video_filename = words[1]; //add the camera service port VPortInfo pInfo = GetPortInfoFromPlatform("video loading"); List<VRole> roles = new List<VRole>() {RoleCamera.Instance}; cameraPort = InitPort(pInfo); BindRoles(cameraPort, roles, OnOperationInvoke); RegisterPortWithPlatform(cameraPort); worker = new SafeThread(delegate() { GetVideo(); }, "DriverVideoLoading-PollDevice", logger); worker.Start(); }
/// <summary> /// This function will throw an exception if the log is non-rotating and if the container name does meet the following constraints: /// 1. Container names must start with a letter or number, and can contain only letters, numbers, and the dash (-) character. /// 2. Every dash (-) character must be immediately preceded and followed by a letter or number; consecutive dashes are not permitted in container names. /// 3. All letters in a container name must be lowercase. /// 4. Container names must be from 3 through 63 characters long /// </summary> /// <param name="accountName"></param> /// <param name="accountKey"></param> /// <param name="containerName"></param> public void InitSyncing(string accountName, string accountKey, string containerName) { if (!IsRotatingLog) { throw new Exception("Cannot sync a non-rotating log"); } //the code below could throw an exception if containerName does not meet the restrictions var locationInfo = new Bolt.DataStore.LocationInfo(accountName, accountKey, Bolt.DataStore.SynchronizerType.Azure); try { synchronizer = Bolt.DataStore.SyncFactory.Instance.CreateLogSynchronizer(locationInfo, containerName); synchronizer.SetLocalSource(archivingDirectory); //lets sync for starters, in case there are leftover logs from last time SafeThread worker = new SafeThread(delegate() { synchronizer.Sync(); }, "init log syncing", this); worker.Start(); } catch (System.FormatException ex1) { Log("ERROR: Could not start log syncing. The Azure account key may be wrong \n {0}", ex1.ToString()); } catch (System.Runtime.InteropServices.COMException ex2) { Log("ERROR: Could not start log syncing. It appears that the Sync Framework v2.1 x86 version is not installed. Make sure that no other version is present. \n {0}", ex2.ToString()); } catch (Microsoft.WindowsAzure.StorageClient.StorageServerException ex3) { Log("ERROR: Could not start log syncing. The Azure account name may be wrong.\n {0}", ex3.ToString()); } catch (Microsoft.WindowsAzure.StorageClient.StorageClientException ex3) { Log("ERROR: Could not start log syncing. The Azure account key may be wrong.\n {0}", ex3.ToString()); } catch (Exception ex3) { Log("Got unknown exception while starting log syncing.\n {0}", ex3.ToString()); } }
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); }
/// <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 AddService(PortInfo portInfo, string friendlyName, bool highSecurity, string locationStr, string[] apps) { logger.Log("AddService is called on " + friendlyName + " for " + portInfo.ToString() + " loc:" + locationStr + " sec: " + highSecurity + " #apps " + apps.Length.ToString()); portInfo.SetFriendlyName(friendlyName); portInfo.SetSecurity(highSecurity); Location location = config.GetLocation(locationStr); if (location == null) throw new Exception("Unknown location " + locationStr); portInfo.SetLocation(location); location.AddChildPort(portInfo); config.AddConfiguredPort(portInfo); foreach (string app in apps) { if (config.GetModule(app) != null) AllowAppAcccessToDevice(app, friendlyName); else logger.Log("ERROR: Could not give access to device {0} to app {1} because the app does not exist", friendlyName, app); //AccessRule rule = new AccessRule(); //rule.RuleName = portInfo.GetFriendlyName(); //rule.ModuleName = app; //rule.UserGroup = "everyone"; //rule.AccessMode = Common.AccessMode.Allow; //rule.Priority = 0; //rule.DeviceList = new List<string>(); //rule.DeviceList.Add(friendlyName); //rule.TimeList = new List<TimeOfWeek>(); //rule.TimeList.Add(new TimeOfWeek(-1, 0, 2400)); //policyEngine.AddAccessRule(rule); //config.AddAccessRule(rule); } //send port registration message to all modules now that this service has been registered // first, get the port object and the owner module VPort portToRegister = null; VModule ownerModule = null; lock (this) { foreach (VPort port in registeredPorts.Keys) { if (port.GetInfo().Equals(portInfo)) { portToRegister = port; ownerModule = registeredPorts[port]; break; } } } if (portToRegister != null) { SafeThread newThread = new SafeThread(delegate() { BroadcastPortRegistration(portToRegister, ownerModule); }, "AddService:RegisterPort " + portToRegister, logger); newThread.Start(); } }
//if you are removing a device you have, the parameters are (deviceFriendlyName, “false”) //if you are removing a device that does not exist any more, the parameters should be (nodeId, “true”) //if you are removing a device that was accidentally removed from zwave (by removeunaddedzwaveweb), the parameters should be (deviceFriendlyName, "cleanup") public List<string> RemoveZwaveWeb(string deviceFriendlyName, string failedNode) { try { logger.Log("UICalled: RemoveZwaveDeviceWeb: {0} {1}", deviceFriendlyName, failedNode); // get and check the zwave driver VModule driverZwave = platform.GetDriverZwave(); if (driverZwave == null) return new List<string>() { "Is the Zwave driver running?" }; //get the service port and check if the node is indeed zwave var servicePort = config.GetConfiguredPortUsingFriendlyName(deviceFriendlyName); if (servicePort == null) return new List<string>() { "Port not found for " + deviceFriendlyName }; if (!servicePort.ModuleFacingName().Contains("ZwaveNode::")) return new List<string>() { deviceFriendlyName + " doesn't appear to be a zwave node. its modulefacingname is " + servicePort.ModuleFacingName() }; //now get removing switch (failedNode) { case "false": case "False": { string result = null; SafeThread addThread = new SafeThread(delegate() { result = (string)driverZwave.OpaqueCall("RemoveDevice"); }, "zwave node removal", logger); addThread.Start(); addThread.Join(new TimeSpan(0, 0, ZWaveAddRemoveTimeoutSecs)); logger.Log("Result of remove zwave = " + result); if (result == null) { string abortResult = (string)driverZwave.OpaqueCall("AbortRemoveDevice"); logger.Log("Result of AbortAddDevice = " + abortResult); return new List<string>() { "Add operation timed out" }; } } break; case "True": case "true": { int startIndex = servicePort.ModuleFacingName().IndexOf("ZwaveNode::"); string subString = servicePort.ModuleFacingName().Substring(startIndex + "ZwaveNode::".Length); int nodeId; bool success = Int32.TryParse(subString, out nodeId); if (!success) { logger.Log("Could not extract node id from {0}", servicePort.ModuleFacingName()); return new List<string>() { "Could not extract nodeId from " + servicePort.ModuleFacingName() }; } string result = (string)driverZwave.OpaqueCall("RemoveFailedNode", nodeId); logger.Log("result of removefailednode call = " + result); } break; default: return new List<string>() { "Unknown failed node option " + failedNode }; } //now remove the port bool removePortResult = config.RemovePort(servicePort); if (!removePortResult) return new List<string>() { String.Format("Could not remove port {0}", servicePort.ToString()) }; platform.RemoveAccessRulesForDevice(deviceFriendlyName); return new List<string>() { "" }; } catch (Exception e) { logger.Log("Exception in RemoveZwaveWeb: " + e.ToString()); return new List<string>() { "Got exception: " + e.Message }; } }
private void RecAudio(int recLength) { if (!Directory.Exists("..\\KinectAudios\\")) { DirectoryInfo di = Directory.CreateDirectory("..\\KinectAudios\\"); logger.Log("New directory created to store audio files at {0}.", di.FullName); } lastAudioClipName = "..\\KinectAudios\\" + DateTime.Now.ToString("yyyyMMddHHmmss") + "_wav.wav"; worker = new SafeThread(delegate() { AudioRecording(recLength); }, "DriverKinect-RecAudio", logger); worker.Start(); logger.Log("Audio Recording Started."); }
public List<string> AddZwaveWeb(string deviceType) { try { logger.Log("UICalled: AddZwaveWeb {0}", deviceType); VModule driverZwave = platform.GetDriverZwave(); if (driverZwave == null) return new List<string>() { "Is the Zwave driver running?" }; string addResult = null; SafeThread addThread = new SafeThread(delegate() { addResult = (string)driverZwave.OpaqueCall("AddDevice", deviceType); }, "zwave node adding", logger); addThread.Start(); addThread.Join(new TimeSpan(0, 0, ZWaveAddRemoveTimeoutSecs)); logger.Log("Result of add zwave = " + addResult); if (addResult == null) { string abortResult = (string)driverZwave.OpaqueCall("AbortAddDevice"); logger.Log("Result of AbortAddDevice = " + abortResult); return new List<string>() { "Add operation timed out" }; } if (addResult.Contains("ZwaveNode::")) return new List<string>() { "", addResult }; return new List<string>() { addResult }; } catch (Exception e) { logger.Log("Exception in AddZwaveWeb: " + e.ToString()); return new List<string>() { "Got exception: " + e.Message }; } }
public List<string> RemoveUnaddedZwaveWeb() { try { logger.Log("UICalled: RemoveUnaddedZwaveWeb"); VModule driverZwave = platform.GetDriverZwave(); if (driverZwave == null) return new List<string>() { "Is the Zwave driver running?" }; string removeResult = null; SafeThread removeThread = new SafeThread(delegate() { removeResult = (string)driverZwave.OpaqueCall("RemoveDevice"); }, "unadded zwave node remove", logger); removeThread.Start(); removeThread.Join(new TimeSpan(0, 0, ZWaveAddRemoveTimeoutSecs)); logger.Log("Result of unadded zwave remove = " + removeResult); if (removeResult == null) { string abortResult = (string)driverZwave.OpaqueCall("AbortRemoveDevice"); logger.Log("Result of AbortRemoveDevice = " + abortResult); return new List<string>() { "Remove operation timed out" }; } if (removeResult.Contains("ZwaveNode::0")) return new List<string>() { "", removeResult }; //we ended up removing what we shouldn't if (removeResult.Contains("ZwaveNode::")) { var portToRemove = config.GetConfiguredPortUsingModuleFacingName(driverZwave.GetInfo().FriendlyName(), removeResult); if (portToRemove == null) return new List<string>() { "An added node was seemingly removed but its port was not found", removeResult }; //now remove the port bool removePortResult = config.RemovePort(portToRemove); if (!removePortResult) return new List<string>() { String.Format("Could not remove port {0}", portToRemove.ToString()) }; platform.RemoveAccessRulesForDevice(portToRemove.GetFriendlyName()); return new List<string>() { "An added node was removed", removeResult, portToRemove.GetFriendlyName(), removePortResult.ToString() }; } return new List<string>() { removeResult }; } catch (Exception e) { logger.Log("Exception in UnaddedZwaveWeb: " + e.ToString()); return new List<string>() { "Got exception: " + e.Message }; } }
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); }
private void RotateLog() { logWriter.Close(); string archivingFile = archivingDirectory + "\\" + GetTimeStamp() + "-" + Path.GetFileName(fName); while (File.Exists(archivingFile) || File.Exists(archivingFile + ".zip")) archivingFile += ".1"; File.Move(fName, archivingFile); logWriter = new StreamWriter(fName, true); SafeThread worker = new SafeThread(delegate() { //compress the file CompressFile(archivingFile); //if we are syncing, start that on a separate thread if (synchronizer != null) { synchronizer.Sync(); } }, "post-log-rotation-work", this ); worker.Start(); }
/// <summary> /// This function will throw an exception if the log is non-rotating and if the container name does meet the following constraints: /// 1. Container names must start with a letter or number, and can contain only letters, numbers, and the dash (-) character. /// 2. Every dash (-) character must be immediately preceded and followed by a letter or number; consecutive dashes are not permitted in container names. /// 3. All letters in a container name must be lowercase. /// 4. Container names must be from 3 through 63 characters long /// </summary> /// <param name="accountName"></param> /// <param name="accountKey"></param> /// <param name="containerName"></param> public void InitSyncing(string accountName, string accountKey, string containerName) { if (!IsRotatingLog) throw new Exception("Cannot sync a non-rotating log"); //the code below could throw an exception if containerName does not meet the restrictions var locationInfo = new Bolt.DataStore.LocationInfo(accountName, accountKey, Bolt.DataStore.SynchronizerType.Azure); try { synchronizer = Bolt.DataStore.SyncFactory.Instance.CreateLogSynchronizer(locationInfo, containerName); synchronizer.SetLocalSource(archivingDirectory); //lets sync for starters, in case there are leftover logs from last time SafeThread worker = new SafeThread(delegate() { synchronizer.Sync(); }, "init log syncing", this); worker.Start(); } catch (System.FormatException ex1) { Log("ERROR: Could not start log syncing. The Azure account key may be wrong \n {0}", ex1.ToString()); } catch (System.Runtime.InteropServices.COMException ex2) { Log("ERROR: Could not start log syncing. It appears that the Sync Framework v2.1 x86 version is not installed. Make sure that no other version is present. \n {0}", ex2.ToString()); } catch (Microsoft.WindowsAzure.StorageClient.StorageServerException ex3) { Log("ERROR: Could not start log syncing. The Azure account name may be wrong.\n {0}", ex3.ToString()); } catch (Microsoft.WindowsAzure.StorageClient.StorageClientException ex3) { Log("ERROR: Could not start log syncing. The Azure account key may be wrong.\n {0}", ex3.ToString()); } catch (Exception ex3) { Log("Got unknown exception while starting log syncing.\n {0}", ex3.ToString()); } }
private void StopRecording(VPort cameraPort, bool force) { bool stopConditionMet = false; CameraInfo cameraInfo = registeredCameras[cameraPort]; //if ((DateTime.Now - registeredCameras[cameraPort].CurrVideoStartTime).TotalMinutes >= // MAX_VIDEO_CLIP_LEN_IN_MINUTES) if (DateTime.Now >= registeredCameras[cameraPort].CurrVideoEndTime) { stopConditionMet = true; } if ((force || stopConditionMet) && (cameraInfo.VideoWriter != null)) { string cameraName = cameraPort.GetInfo().GetFriendlyName(); VideoWriter VideoWriter = cameraInfo.VideoWriter; SafeThread helper = new SafeThread(delegate() { StopRecordingHelper(VideoWriter, cameraName); }, "stoprecordinghelper-" + cameraName, logger); helper.Start(); cameraInfo.RecordVideo = false; cameraInfo.VideoWriter = null; cameraInfo.CurrVideoStartTime = DateTime.MinValue; cameraInfo.CurrVideoEndTime = DateTime.MinValue; if (stopConditionMet) { logger.Log("Stop recording because the clip time has elapsed for {0}", cameraPort.GetInfo().GetFriendlyName()); } else { logger.Log("Stop recording for {0}", cameraPort.GetInfo().GetFriendlyName()); } } }
/// <summary> /// Send a port deregisterd message to all active modules /// </summary> /// <param name="port"></param> /// <param name="owner"></param> public void BroadcastPortDeregistration(VPort port, VModule owner) { Dictionary<String, SafeThread> listOfThreads = new Dictionary<string, SafeThread>() ; lock (this) { foreach (VModule module in runningModules.Keys) { if (!module.Equals(owner)) { //***< Thread that monitors and timesout the port deregistered thread SafeThread mPortDeregThreadControl = new SafeThread(delegate() { //***< Thread that invokes port deregistered on the module SafeThread mPortDeregThread = new SafeThread(delegate() { InvokePortDeregistered(module, port); }, module + ".PortDeregistered(" + port + ")", logger); //***> mPortDeregThread.Start(); mPortDeregThread.Join(TimeSpan.FromMilliseconds(Settings.MaxPortDeregisteredExecutionTime)); try { if (mPortDeregThread.IsAlive()) mPortDeregThread.Abort(); } catch (Exception) { //The PortDeregistered() calls when aborted (if so) will raise an exception } } , module + ".PortDeregistered(" + port + ") - Control" , logger); //*** listOfThreads[mPortDeregThreadControl.Name()] = mPortDeregThreadControl; //store the list because we want to wait on these later mPortDeregThreadControl.Start(); } } } foreach (SafeThread t in listOfThreads.Values) { t.Join(); } }
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); }
public void ForceShutdown() { logger.Log("Forcing Platform Shutdown", Settings.ConfigDir); SafeThread shutdownThread = new SafeThread(delegate { Shutdown(); }, "shutdown thread", logger); shutdownThread.Start(); //wait for 2 minutes shutdownThread.Join(new TimeSpan(0, 2, 0)); System.Environment.Exit(0); }
public override void Start() { string embedDriverArgs = moduleInfo.Args()[0]; string comPortName = embedDriverArgs; if (!String.IsNullOrEmpty(comPortName)) { if (comPortName.Contains(MBED)) { comPortName = comPortName.Replace(MBED + " - ", ""); } this.portName = comPortName; } connectionChecker = new SafeThread(delegate() { CheckComConnection(); }, "ComPort connection-checker", logger); if (InitializePort() == true) { try { serialPort.Open(); connectionChecker.Start(); while (!connectionChecker.IsAlive()) ; } catch (Exception) { List<COMPortFinder> comportList = COMPortFinder.GetCOMPortsInfo(); foreach (COMPortFinder comPortInfo in comportList) { if (comPortInfo.Description.Contains(MBED)) { this.portName = comPortInfo.Name; break; } } InitializePort(); //serialPort.Open(); } //testPort(); } //.................instantiate the port VPortInfo portInfo = GetPortInfoFromPlatform(embedDriverArgs); mbedPort = InitPort(portInfo); // ..... initialize the list of roles we are going to export and bind to the role List<VRole> listRole = new List<VRole>() { RoleMbedSoftUps.Instance }; BindRoles(mbedPort, listRole); //.................register the port after the binding is complete RegisterPortWithPlatform(mbedPort); }
private void AddInCleanup(VModule moduleStopped) { //cleanup if (Constants.ModuleIsolationLevel == ModuleIsolationModes.AppDomain) { logger.Log("AppDomain cleanup for "+ moduleStopped.GetInfo().AppName()); bool done = false; AddInController aiController = AddInController.GetAddInController(moduleStopped); SafeThread t = new SafeThread(delegate() { while (!done) { try { aiController.Shutdown(); done = true; } catch (CannotUnloadAppDomainException) { logger.Log("AppDomain Unload did not succeed. Retrying."); System.Threading.Thread.Sleep(1000); // keep trying to unload until it gets unloaded } } }, moduleStopped.ToString()+"-UnloadingAppDomain", logger); t.Start(); t.Join(TimeSpan.FromMilliseconds(Settings.MaxFinallyBlockExecutionTime)); if(t.IsAlive()) t.Abort(); } else if (Constants.ModuleIsolationLevel == ModuleIsolationModes.Process) { //TODO: test this AddInController aiController = AddInController.GetAddInController(moduleStopped); aiController.Shutdown(); } else if (Constants.ModuleIsolationLevel == ModuleIsolationModes.NoAddInAppDomain) { // TODO handle cleanup here } else {// Globals.ModuleIsolationLevel == ModuleIsolationModes.None // TODO handle cleanup here } }
void RefreshDbs(object sender, System.Timers.ElapsedEventArgs e) { //refresh Dbs in the background SafeThread refreshThread = new SafeThread(delegate() { logger.Log("Homestore refresh was triggered"); //refresh into this temporary db HomeStoreDb tmpStoreDb = new HomeStoreDb(logger); tmpStoreDb.Populate(); //do a switch now lock (this) { storeDb = tmpStoreDb; } lastRefreshed = DateTime.Now; }, "homestore refresh", logger); refreshThread.Start(); }
public void ConfiguredStart() { guiService.ConfiguredStart(); //initialize the scout helper; needed for scouts that rely on upnp discovery ScoutHelper.Init(logger); //start the configured scouts. starting scouts before modules. foreach (var sInfo in config.GetAllScouts()) { StartScout(sInfo); } //start the heartbeat service (directly writes to cloud) if (Settings.HeartbeatServiceMode != "Off") { InitHeartbeatService(); } //config updater if(this.configLookup==null) { ConfigUpdater configLookup = null; LoadConfig loadNewConfig = this.LoadConfigFromDir; configLookup = new ConfigUpdater(null, logger, Settings.ConfigLookupFrequency, loadNewConfig, this); this.configLookup = configLookup; if (this.configLookup != null) { this.configLookup.setConfig(this.config); } } // start the authentication service { authenticationService = new HomeOS.Hub.Platform.Authentication.AuthenticationService(logger, this); authenticationServiceHost = HomeOS.Hub.Platform.Authentication.AuthenticationService.CreateServiceHost(logger, this, authenticationService); authenticationServiceHost.Open(); } InitHomeService(); if (Settings.RunningMode.Equals("standard")) { InitAutoStartModules(); } else #region developers' running modes { if (Settings.RunningMode.Equals("unittesting")) { // don't start any modules, we just need a module-less platform to initialize the module (app/device) // being unit tested } else if (Settings.RunningMode.Equals("ratul")) { //StartModule(new ModuleInfo("axiscamdriver", "DriverAxisCamera", "DriverAxisCamera", null, false, "192.168.0.198", "root", "homeos")); //StartModule(new ModuleInfo("foscamdriver1", "DriverFoscam", "HomeOS.Hub.Drivers.Foscam", null, false, "192.168.1.125", "admin", "")); StartModule(new ModuleInfo("webcamdriver", "DriverWebCam", "HomeOS.Hub.Drivers.WebCam", null, false, @"Microsoft® LifeCam VX-7000")); StartModule(new ModuleInfo("AppCam", "AppCamera", "HomeOS.Hub.Apps.SmartCam", null, false)); //string para1 = "C:\\Users\\t-chuchu\\Desktop\\homeos\\homeos\\Apps\\AppTracking\\VideoTracking\\para_camera1.txt"; //string para2 = "C:\\Users\\t-chuchu\\Desktop\\homeos\\homeos\\Apps\\AppTracking\\VideoTracking\\para_camera2.txt"; //StartModule(new ModuleInfo("trackingapp", "AppTracking", "AppTracking", null, false, para1, para2)); //StartModule(new ModuleInfo("HomeOS.Hub.Drivers.Gadgeteer.MicrosoftResearch.WindowCamera for HomeOSGadgeteerDevice_WindowCamera_MicrosoftResearch_65355695098562951548", "DriverGadgetCamera", "HomeOS.Hub.Drivers.Gadgeteer.MicrosoftResearch.WindowCamera", null, false, "192.168.0.197")); //StartModule(new ModuleInfo("zwavezensys", "DriverZwaveZensys", "HomeOS.Hub.Drivers.ZwaveZensys_4_55", null, false)); //StartModule(new ModuleInfo("switchapp", "AppSwitch", "HomeOS.Hub.Apps.Switch", null, false)); //StartModule(new ModuleInfo("alerts", "AppAlerts", "HomeOS.Hub.Apps.Alerts", null, false)); //StartModule(new ModuleInfo("foscamdriver1", "DriverFoscam", "HomeOS.Hub.Drivers.Foscam", null, false, "192.168.1.125", "admin", "")); //StartModule(new ModuleInfo("AppDummy1", "AppDummy1", "HomeOS.Hub.Apps.Dummy", null, false, null)); //StartModule(new ModuleInfo("DriverDummy1", "DriverDummy1", "HomeOS.Hub.Drivers.Dummy", null, false, null)); } else if (Settings.RunningMode.Equals("rayman")) { ModuleInfo d = new ModuleInfo("HomeOS.Hub.Drivers.Mic", "HomeOS.Hub.Drivers.Mic", "HomeOS.Hub.Drivers.Mic", null, false,"foo", "8000", "1" ); StartModule(d); /* HomeOS.Hub.Platform.Authentication.AuthenticationService auth = new HomeOS.Hub.Platform.Authentication.AuthenticationService(logger, this); System.ServiceModel.ServiceHost s = HomeOS.Hub.Platform.Authentication.AuthenticationService.CreateServiceHost(logger, this, auth); s.Open(); ModuleInfo app = new ModuleInfo("AppDummy1", "AppDummy1", "HomeOS.Hub.Apps.Dummy", null, false, null); StartModule(app); ModuleInfo app1 = new ModuleInfo("DriverDummy1", "DriverDummy1", "HomeOS.Hub.Drivers.Dummy", null, false, null); StartModule(app1); HomeOS.Hub.Common.TokenHandler.SafeTokenHandler t = new Common.TokenHandler.SafeTokenHandler("randomsalt"); string s1 = t.GenerateToken("helloworlergwergwergwergwergwegrwegewgewrgwergwregwgwgd"); logger.Log("Encryting helloworld: "+s1); t = null; t = new Common.TokenHandler.SafeTokenHandler("randomsalt"); logger.Log("decrypting token: " + t.ProcessToken(s1).Name);*/ // DateTime t = policyEngine.AllowAccess("*","AppDummy1", "jeff"); // logger.Log(">>>>>>>>>>> " + t.ToString()+ " , " + DateTime.Now); // Dont touch my running mode /* AddInToken t = null ; foreach (AddInToken token in allAddinTokens) { if (token.Name.Equals("HomeOS.Hub.Drivers.Dummy") ) { t = token ; } } VModule a = t.Activate<VModule>(AddInSecurityLevel.FullTrust); ModuleInfo info = new ModuleInfo("friendlyName", "moduleName", "moduleName", null, false, null); AddInController aic = AddInController.GetAddInController(a); a.Initialize(this, logger,info, 0); SafeThread moduleThread = new SafeThread(delegate() { a.Start(); },"", logger); moduleThread.Start(); System.Threading.Thread.Sleep(1 * 11 * 1000); aic.Shutdown(); ModuleInfo[] app = new ModuleInfo[100]; int i; for (i = 0; i < 30; i++) { app[i] = new ModuleInfo("AppDummy"+i.ToString(), "AppDummy"+i.ToString(), "HomeOS.Hub.Apps.Dummy", null, false, null); StartModule(app[i]); } ModuleInfo[] driver = new ModuleInfo[3000]; int j; for (j = 0; j <30; j++) { driver[j] = new ModuleInfo("DriverDummy"+j.ToString(), "DriverDummy"+j.ToString(), "HomeOS.Hub.Drivers.Dummy", null, false, null); StartModule(driver[j]); } System.Threading.Thread.Sleep(1 * 20 * 1000); for (j = 29; j >=0; j--) { StopModule(runningModules.First(x => x.Value.Equals(driver[j])).Key.Secret()); } for (i = 29;i >= 1; i--) { StopModule(runningModules.First(x => x.Value.Equals(app[j])).Key.Secret()); } */ } else if (Settings.RunningMode.Equals("chunte")) { //StartModule(new ModuleInfo("webcamdriver", "DriverWebCam", "DriverWebCam", null, false, "logitech")); //StartModule(new ModuleInfo("foscamdriver", "DriverFoscam", "DriverFoscam", null, false, "192.168.0.196", "admin", "whoareyou?")); //StartModule(new ModuleInfo("foscamdriver", "DriverFoscam", "DriverFoscam", null, false, "172.31.42.177", "admin", "")); string video1 = "c:\\img\\cam2_20120821165455_test1.avi"; string video2 = "c:\\img\\DSCN7066_test1.avi"; StartModule(new ModuleInfo("loadvideo1", "DriverVideoLoading", "DriverVideoLoading", null, false, video1)); StartModule(new ModuleInfo("loadvideo2", "DriverVideoLoading", "DriverVideoLoading", null, false, video2)); //StartModule(new ModuleInfo("cameraapp", "AppCamera", "AppCamera", null, false)); string para1 = "C:\\Users\\t-chuchu\\Desktop\\homeos\\homeos\\Apps\\AppTracking\\VideoTracking\\para_camera1.txt"; string para2 = "C:\\Users\\t-chuchu\\Desktop\\homeos\\homeos\\Apps\\AppTracking\\VideoTracking\\para_camera2.txt"; StartModule(new ModuleInfo("trackingapp", "AppTracking", "AppTracking", null, false, para1, para2)); } else if (Settings.RunningMode.Contains("khurshed")) { if (Settings.RunningMode.Equals("khurshed_test_smartcam_foscam")) { StartModule(new ModuleInfo("foscamdriver2", "DriverFoscam", "HomeOS.Hub.Drivers.Foscam", null, false, "157.54.148.65", "admin", "")); StartModule(new ModuleInfo("SmartCamApp", "AppSmartCam", "HomeOS.Hub.Apps.SmartCam", null, false)); } else if (Settings.RunningMode.Equals("khurshed_test_smartcam_foscam_notifications")) { StartModule(new ModuleInfo("foscamdriver2", "DriverFoscam", "DriverFoscam", null, false, "157.54.148.65", "admin", "")); StartModule(new ModuleInfo("SmartCamApp", "AppSmartCam", "AppSmartCam", null, false)); } else if (Settings.RunningMode.Equals("khurshed_test_smartcam_webcam")) { StartModule(new ModuleInfo("webcamdriver", "DriverWebCam", "DriverWebCam", null, false, "Logitech QuickCam Pro 9000")); StartModule(new ModuleInfo("SmartCamApp", "AppSmartCam", "AppSmartCam", null, false)); } else if (Settings.RunningMode.Equals("khurshed_test_smartcam_foscam_webcam")) { StartModule(new ModuleInfo("webcamdriver", "DriverWebCam", "DriverWebCam", null, false, "Logitech QuickCam Pro 9000")); StartModule(new ModuleInfo("foscamdriver2", "DriverFoscam", "DriverFoscam", null, false, "157.54.148.65", "admin", "")); StartModule(new ModuleInfo("SmartCamApp", "AppSmartCam", "AppSmartCam", null, false)); } else if (Settings.RunningMode.Equals("khurshed_test_tracking_foscam")) { string para1 = "C:\\homeos2\\homeos\\Apps\\AppTracking\\VideoTracking\\para_camera1.txt"; string para2 = "C:\\homeos2\\homeos\\Apps\\AppTracking\\VideoTracking\\para_camera2.txt"; StartModule(new ModuleInfo("foscamdriver2", "DriverFoscam", "DriverFoscam", null, false, "157.54.148.65", "admin", "")); StartModule(new ModuleInfo("trackingapp", "AppTracking", "AppTracking", null, false, para1, para2)); } else if (Settings.RunningMode.Equals("khurshed_test_tracking_videoloading")) { string video1 = "c:\\img\\cam2_20120821165455_test1.avi"; string video2 = "c:\\img\\DSCN7066_test1.avi"; StartModule(new ModuleInfo("loadvideo1", "DriverVideoLoading", "DriverVideoLoading", null, false, video1)); StartModule(new ModuleInfo("loadvideo2", "DriverVideoLoading", "DriverVideoLoading", null, false, video2)); string para1 = "C:\\homeos2\\homeos\\Apps\\AppTracking\\VideoTracking\\para_camera1.txt"; string para2 = "C:\\homeos2\\homeos\\Apps\\AppTracking\\VideoTracking\\para_camera2.txt"; StartModule(new ModuleInfo("trackingapp", "AppTracking", "AppTracking", null, false, para1, para2)); } } else if (Settings.RunningMode.Equals("jamie")) { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(new XmlTextReader(@"C:\homeos\LightSettings.xml")); XmlNode xmlData = xmlDoc.SelectSingleNode("data"); string strLightsIP = xmlData.SelectSingleNode("lightsIP").InnerText; string strLightsUser = xmlData.SelectSingleNode("lightsUser").InnerText; string strfoscamIP = xmlData.SelectSingleNode("foscamIP").InnerText; string strfoscamUser = xmlData.SelectSingleNode("foscamUser").InnerText; string strLightCount = xmlData.SelectSingleNode("light_count").InnerText; StartModule(new ModuleInfo("foscamdriver1", "DriverFoscam", "HomeOS.Hub.Drivers.Foscam", null, false, strfoscamIP, strfoscamUser, "")); StartModule(new ModuleInfo("huedriver1", "HueBridge", "HomeOS.Hub.Drivers.HueBridge", null, false, strLightsIP, strLightsUser, strLightCount)); StartModule(new ModuleInfo("LightsHome1", "LightsHome", "HomeOS.Hub.Apps.LightsHome", null, false)); } else if (Settings.RunningMode.Equals("sarah")) { //Sarah to fill in the right device id StartModule(new ModuleInfo("couchdriver", "DriverCouch", "HomeOS.Hub.Drivers.GadgetCouch", null, false, "..")); StartModule(new ModuleInfo("couchapp", "EmotoCouch", "HomeOS.Hub.Apps.EmotoCouch", null, false)); } else if (Settings.RunningMode.Equals("erin")) { //app startup needed since it's not in the install repository StartModule(new ModuleInfo("AppDoorjamb", "AppDoorjamb", "HomeOS.Hub.Apps.Doorjamb", null, false)); } else { throw new Exception("Unknown running mode: " + Settings.RunningMode); } //we ran using a non-standard running mode //make sure that the modules we ran are entered in the config, so that we can keep it consistent //otherwise, a service (port) will get added without its exporting module lock (this) { foreach (ModuleInfo moduleInfo in runningModules.Values) { if (moduleInfo.GetManifest() == null) moduleInfo.SetManifest(new Manifest()); config.AddModuleIfMissing(moduleInfo); } } } #endregion if (String.IsNullOrEmpty(Settings.WifiSsid)) logger.Log("Warning: WiFi credentials are not configured"); if (!Settings.StayOffline) { //start checking for the uniqueness of home id on a separate thread SafeThread uniqueHomeIdCheck = new SafeThread(delegate() { heartbeatService.CanIClaimHomeId(Utils.HardwareId, Settings.HomeId, UniqueHomeIdCheckCompleted); }, "UniqueHomeIdCheck", logger); uniqueHomeIdCheck.Start(); } }