/// <summary> /// Manages the SharedVariablesLoaded event of the CommandManager /// </summary> private void commandManager_SharedVariablesLoaded(CommandManager cmdMan) { bool written; if (!cmdMan.SharedVariables.Contains("rhKnownHumans")) cmdMan.SharedVariables.Add(svKnownHumans); else svKnownHumans = (KnownHumanFaces)cmdMan.SharedVariables["rhKnownHumans"]; if (!cmdMan.SharedVariables.Contains("rhDetectedHumans")) cmdMan.SharedVariables.Add(svDetectedHumans); else svDetectedHumans = (DetectedHumanFaces)cmdMan.SharedVariables["rhDetectedHumans"]; written = false; for (int i = 0; (i < 3) && !written; ++i) written = svDetectedHumans.TryWrite(null); written = false; for (int i = 0; (i < 3) && !written; ++i) written = svKnownHumans.TryWrite(null); }
/// <summary> /// Registers an existing variable within the list /// </summary> /// <param name="type">The type of the variable to register</param> /// <param name="isArray">Indicates if the variable is an array</param> /// <param name="name">The name of the variable to register</param> /// <param name="data">The data of the variable to register received in the read operation</param> private bool RegisterVar(string type, bool isArray, string name, string data) { SharedVariable variable; variable = null; switch (type) { case "double": if (isArray) { variable = new DoubleArraySharedVariable(this.owner, name, false); } else { variable = new DoubleSharedVariable(this.owner, name, false); } break; case "HumanFace": if (!isArray) { variable = new DetectedHumanFaces(this.owner, name, false); } break; case "int": if (isArray) { variable = new IntArraySharedVariable(this.owner, name, false); } else { variable = new IntSharedVariable(this.owner, name, false); } break; case "LaserReadingArray": if (!isArray) { variable = new LaserReadingArrayShV(this.owner, name, false); } break; case "long": if (isArray) { variable = new LongArraySharedVariable(this.owner, name, false); } else { variable = new LongSharedVariable(this.owner, name, false); } break; case "Matrix": if (!isArray) { variable = new MatrixSharedVariable(this.owner, name, false); } break; case "RecognizedSpeech": if (!isArray) { variable = new RecognizedSpeechSharedVariable(this.owner, name, false); } break; case "var": variable = new VarSharedVariable(this.owner, name, false); isArray = false; break; case "Vector": if (!isArray) { variable = new VectorSharedVariable(this.owner, name, false); } break; case "string": if (!isArray) { variable = new StringSharedVariable(this.owner, name, false); } break; } if (variable == null) { return(false); } rwLock.AcquireWriterLock(-1); if (!variables.ContainsKey(name)) { variables.Add(name, variable); } else { rwLock.ReleaseWriterLock(); return(false); } rwLock.ReleaseWriterLock(); Exception ex; variable.UpdateInfo(500, out ex); variable.Initialized = true; return(variable.Update(type, isArray, -1, name, data, out ex)); }
private void SetupSharedVariables() { svDetectedHumans = new DetectedHumanFaces("rhDetectedHumans"); svKnownHumans = new KnownHumanFaces("rhKnownHumans"); commandManager.SharedVariablesLoaded += new SharedVariablesLoadedEventHandler(commandManager_SharedVariablesLoaded); }