public SubscriptionTester() { cmdMan = new CommandManager(); cmdMan.Started += new CommandManagerStatusChangedEventHandler(cmdMan_Started); cmdMan.Stopped += new CommandManagerStatusChangedEventHandler(cmdMan_Stopped); cmdMan.SharedVariablesLoaded += new SharedVariablesLoadedEventHandler(cmdMan_SharedVariablesLoaded); cnnMan = new ConnectionManager(2020, cmdMan); cnnMan.DataReceived += new ConnectionManagerDataReceivedEH(cnnMan_DataReceived); cnnMan.ClientConnected += new System.Net.Sockets.TcpClientConnectedEventHandler(cnnMan_ClientConnected); cnnMan.Started += new ConnectionManagerStatusChangedEventHandler(cnnMan_Started); cnnMan.Stopped += new ConnectionManagerStatusChangedEventHandler(cnnMan_Stopped); svSpeech = new RecognizedSpeechSharedVariable("recognizedSpeech"); svInteger = new IntSharedVariable("svInteger"); svInteger.ValueChanged += new SharedVariableSubscriptionReportEventHadler <int>(svInteger_ValueChanged); svDoubles = new DoubleArraySharedVariable("svDoubles"); svDoubles.ValueChanged += new SharedVariableSubscriptionReportEventHadler <double[]>(svDoubles_ValueChanged); svBytes = new ByteArraySharedVariable("svBytes"); svBytes.ValueChanged += new SharedVariableSubscriptionReportEventHadler <byte[]>(svBytes_ValueChanged); svMatrix = new MatrixSharedVariable("svMatrix"); svMatrix.ValueChanged += new SharedVariableSubscriptionReportEventHadler <Robotics.Mathematics.Matrix>(svMatrix_ValueChanged); svVector = new VectorSharedVariable("svVector"); svVector.ValueChanged += new SharedVariableSubscriptionReportEventHadler <Robotics.Mathematics.Vector>(svVector_ValueChanged); svString = new StringSharedVariable("svString"); svString.WriteNotification += new SharedVariableSubscriptionReportEventHadler <string>(svString_WriteNotification); svRecognized = new StringSharedVariable("recognized"); svRecognized.WriteNotification += new SharedVariableSubscriptionReportEventHadler <string>(svString_WriteNotification); }
private void SuscribeToSharedVars() { if (!this.isSuscribedToGestureVar) { try { if (!this.cmdMan.SharedVariables.Contains(this.gestureSharedVariable.Name)) this.cmdMan.SharedVariables.Add(this.gestureSharedVariable); else this.gestureSharedVariable = (StringSharedVariable)this.cmdMan.SharedVariables[this.gestureSharedVariable.Name]; this.gestureSharedVariable.Subscribe(SharedVariableReportType.SendContent, SharedVariableSubscriptionType.WriteOthers); this.gestureSharedVariable.WriteNotification += new SharedVariableSubscriptionReportEventHadler<string>(gestureSharedVariable_WriteNotification); TextBoxStreamWriter.DefaultLog.WriteLine("HAL9000.-> Suscribed to gesture variable"); this.status.IsSuscribedToGestureVar = true; this.isSuscribedToGestureVar = true; } catch { TextBoxStreamWriter.DefaultLog.WriteLine("HAL9000.-> Can't suscribe to gesture variable"); } } if (!this.isSuscribedToLocationVar) { try { if (!this.cmdMan.SharedVariables.Contains(this.currentLocationSharedVar.Name)) this.cmdMan.SharedVariables.Add(this.currentLocationSharedVar); else this.currentLocationSharedVar = (StringSharedVariable)this.cmdMan.SharedVariables[this.currentLocationSharedVar.Name]; this.currentLocationSharedVar.Subscribe(SharedVariableReportType.SendContent, SharedVariableSubscriptionType.WriteOthers); this.currentLocationSharedVar.WriteNotification += new SharedVariableSubscriptionReportEventHadler<string>(currentLocationSharedVar_WriteNotification); TextBoxStreamWriter.DefaultLog.WriteLine("HAL9000.-> Suscribed to location variable"); this.status.IsSuscribedToLocationVar = true; this.isSuscribedToLocationVar = true; } catch { TextBoxStreamWriter.DefaultLog.WriteLine("HAL9000.-> Can't suscribe to location variable"); } } if (!this.isSuscribedToRegionVar) { try { if (!this.cmdMan.SharedVariables.Contains(this.currentRegionSharedVar.Name)) this.cmdMan.SharedVariables.Add(this.currentRegionSharedVar); else this.currentRegionSharedVar = (StringSharedVariable)this.cmdMan.SharedVariables[this.currentRegionSharedVar.Name]; this.currentRegionSharedVar.Subscribe(SharedVariableReportType.SendContent, SharedVariableSubscriptionType.WriteOthers); this.currentRegionSharedVar.WriteNotification += new SharedVariableSubscriptionReportEventHadler<string>(currentRegionSharedVar_WriteNotification); TextBoxStreamWriter.DefaultLog.WriteLine("HAL9000.-> Suscribed to region variable"); this.status.IsSuscribedToRegionVar = true; this.isSuscribedToRegionVar = true; } catch { TextBoxStreamWriter.DefaultLog.WriteLine("HAL9000.-> Can't suscribe to region variable"); } } if (!this.isSuscribedToRoomVar) { try { if (!this.cmdMan.SharedVariables.Contains(this.currentRoomSharedVar.Name)) this.cmdMan.SharedVariables.Add(this.currentRoomSharedVar); else this.currentRoomSharedVar = (StringSharedVariable)this.cmdMan.SharedVariables[this.currentRoomSharedVar.Name]; this.currentRoomSharedVar.Subscribe(SharedVariableReportType.SendContent, SharedVariableSubscriptionType.WriteOthers); this.currentRoomSharedVar.WriteNotification += new SharedVariableSubscriptionReportEventHadler<string>(currentRoomSharedVar_WriteNotification); TextBoxStreamWriter.DefaultLog.WriteLine("HAL9000.-> Suscribed to room variable"); this.status.IsSuscribedToRoomVar = true; this.isSuscribedToRoomVar = true; } catch { TextBoxStreamWriter.DefaultLog.WriteLine("HAL9000.-> Can't suscribe to room variable"); } } if (!this.isSuscribedToRecoSpeechs) { try { if (!this.cmdMan.SharedVariables.Contains(this.recogSpeechsSharedVar.Name)) this.cmdMan.SharedVariables.Add(this.recogSpeechsSharedVar); else this.recogSpeechsSharedVar = (RecognizedSpeechSharedVariable)this.cmdMan.SharedVariables[this.recogSpeechsSharedVar.Name]; this.recogSpeechsSharedVar.Subscribe(SharedVariableReportType.SendContent, SharedVariableSubscriptionType.WriteOthers); this.recogSpeechsSharedVar.WriteNotification += new SharedVariableSubscriptionReportEventHadler<Robotics.HAL.Sensors.RecognizedSpeech>(recogSpeechsSharedVar_WriteNotification); TextBoxStreamWriter.DefaultLog.WriteLine("HAL9000.-> Suscribed to reco speech variable"); this.status.IsSuscribedToRecoSpeechVar = true; this.isSuscribedToRecoSpeechs = true; } catch { TextBoxStreamWriter.DefaultLog.WriteLine("HAL9000.-> Can't suscribe to reco speech variable"); } } if (!this.isSuscribedToSkeletons) { try { if (!this.cmdMan.SharedVariables.Contains(this.skeletonsSharedVariable.Name)) this.cmdMan.SharedVariables.Add(this.skeletonsSharedVariable); else this.skeletonsSharedVariable = (StringSharedVariable)this.cmdMan.SharedVariables[this.skeletonsSharedVariable.Name]; this.skeletonsSharedVariable.Subscribe(SharedVariableReportType.SendContent, SharedVariableSubscriptionType.WriteOthers); this.skeletonsSharedVariable.WriteNotification += new SharedVariableSubscriptionReportEventHadler<string>(skeletonsSharedVar_WriteNotification); TextBoxStreamWriter.DefaultLog.WriteLine("HAL9000.-> Suscribed to skeletons."); this.status.IsSuscribedToRoomVar = true; this.isSuscribedToSkeletons = true; } catch { TextBoxStreamWriter.DefaultLog.WriteLine("HAL9000.-> Can't suscribe to skeletons variable"); } } if (!this.isSuscribedToNearesObjForLoc) { try { if (!this.cmdMan.SharedVariables.Contains(this.nearestObjForLocDirection.Name)) this.cmdMan.SharedVariables.Add(this.nearestObjForLocDirection); else this.nearestObjForLocDirection = (DoubleSharedVariable)this.cmdMan.SharedVariables[this.nearestObjForLocDirection.Name]; this.nearestObjForLocDirection.Subscribe(SharedVariableReportType.SendContent, SharedVariableSubscriptionType.WriteOthers); this.nearestObjForLocDirection.WriteNotification += new SharedVariableSubscriptionReportEventHadler<double>(nearestObjForLocDirection_WriteNotification); TextBoxStreamWriter.DefaultLog.WriteLine("HAL9000.-> Suscribed to " + this.nearestObjForLocDirection.Name + " shared var"); this.status.IsSuscribedToNearObjForLoc = true; this.isSuscribedToNearesObjForLoc = true; } catch { TextBoxStreamWriter.DefaultLog.WriteLine("HAL9000.-> Can't suscribe to " + this.nearestObjForLocDirection.Name + " shared var"); } } if (!this.isSuscribedToInGoodRegion) { try { if (!this.cmdMan.SharedVariables.Contains(this.svInGoorRegionForLoc.Name)) this.cmdMan.SharedVariables.Add(this.svInGoorRegionForLoc); else this.svInGoorRegionForLoc = (IntSharedVariable)this.cmdMan.SharedVariables[this.svInGoorRegionForLoc.Name]; this.svInGoorRegionForLoc.Subscribe(SharedVariableReportType.SendContent, SharedVariableSubscriptionType.WriteOthers); this.svInGoorRegionForLoc.WriteNotification += new SharedVariableSubscriptionReportEventHadler<int>(svInGoorRegionForLoc_WriteNotification); TextBoxStreamWriter.DefaultLog.WriteLine("HAL9000.-> Suscribed to " + this.svInGoorRegionForLoc.Name + " shared var"); this.status.IsSuscribedToInGoodRegion = true; this.isSuscribedToInGoodRegion = true; } catch { TextBoxStreamWriter.DefaultLog.WriteLine("HA9000.-> Can't suscribe to " + this.svInGoorRegionForLoc.Name + " shared var"); } } if (!this.isSuscribedToCellphone) { try { if (!this.cmdMan.SharedVariables.Contains(this.cell_phoneSharedVariable.Name)) this.cmdMan.SharedVariables.Add(this.cell_phoneSharedVariable); else this.cell_phoneSharedVariable = (StringSharedVariable)this.cmdMan.SharedVariables[this.cell_phoneSharedVariable.Name]; this.cell_phoneSharedVariable.Subscribe(SharedVariableReportType.SendContent, SharedVariableSubscriptionType.WriteOthers); this.cell_phoneSharedVariable.WriteNotification += new SharedVariableSubscriptionReportEventHadler<string>(cellphoneSharedVar_WriteNotification); TextBoxStreamWriter.DefaultLog.WriteLine("HAL9000.-> Suscribed to Cellphone."); this.status.IsSuscribedToRoomVar = true; this.isSuscribedToCellphone = true; } catch { TextBoxStreamWriter.DefaultLog.WriteLine("HAL9000.-> Can't suscribe to cellphone variable"); } } if (!this.isSuscribedToFall) { try { if (!this.cmdMan.SharedVariables.Contains(this.fallSharedVariable.Name)) this.cmdMan.SharedVariables.Add(this.fallSharedVariable); else this.fallSharedVariable = (StringSharedVariable)this.cmdMan.SharedVariables[this.fallSharedVariable.Name]; this.fallSharedVariable.Subscribe(SharedVariableReportType.SendContent, SharedVariableSubscriptionType.WriteOthers); this.fallSharedVariable.WriteNotification += new SharedVariableSubscriptionReportEventHadler<string>(fallSharedVariable_WriteNotification); TextBoxStreamWriter.DefaultLog.WriteLine("HAL9000.-> Suscribed to Fall variable."); this.isSuscribedToFall = true; } catch { TextBoxStreamWriter.DefaultLog.WriteLine("HAL9000.-> Can't suscribe to fall variable"); } } if (!this.isSuscribedToHomeSensors) { try { if (!this.cmdMan.SharedVariables.Contains(this.sensorsSharedVariable.Name)) this.cmdMan.SharedVariables.Add(this.sensorsSharedVariable); else this.sensorsSharedVariable = (StringSharedVariable)this.cmdMan.SharedVariables[this.sensorsSharedVariable.Name]; this.sensorsSharedVariable.Subscribe(SharedVariableReportType.SendContent, SharedVariableSubscriptionType.WriteOthers); this.sensorsSharedVariable.WriteNotification+=new SharedVariableSubscriptionReportEventHadler<string>(sensorsSharedVariable_WriteNotification); TextBoxStreamWriter.DefaultLog.WriteLine("HAL9000 -> Subscibed to Home Sensors variable."); this.isSuscribedToHomeSensors = true; } catch { TextBoxStreamWriter.DefaultLog.WriteLine("HAL9000 -> Can't subscribe to Home Sensors variable"); } } }
public HAL9000Brain() { this.isAware = false; this.currentRoom = "unknown"; this.currentRegion = "unknown"; this.currentLocation = "unknown"; this.knownPersons = new SortedList<string, Person>(); this.knownRooms = new SortedList<string, string>(); this.knownRegions = new SortedList<string, string>(); this.knownLocations = new SortedList<string, string>(); this.knownObjects = new SortedList<string, PhysicalObject>(); this.languageProcessor = new NaturalLanguageProcessor(this); this.actionsToPerform = new List<SentenceImperative>(); this.recognizedSentences = new Queue<string>(); this.lastRecoGestures = new Queue<Gesture>(); this.lastPersonFallDetected = new Queue<string>(); this.sensorLectures = new Queue<string>(); this.validRoomsFile = "ValidRooms.txt"; this.validNamesFile = "ValidNames.txt"; this.knownObjectsFile = "KnownObjects.txt"; this.world = new World(); this.foundHumans = new List<string>(); this.currentRoomSharedVar = new StringSharedVariable("robotRoom"); this.currentRegionSharedVar = new StringSharedVariable("robotRegion"); this.currentLocationSharedVar = new StringSharedVariable("robotLocation"); this.gestureSharedVariable = new StringSharedVariable("gesture"); this.recogSpeechsSharedVar = new RecognizedSpeechSharedVariable("recognizedSpeech"); this.skeletonsSharedVariable = new StringSharedVariable("hf_skeletons"); this.nearestObjForLocDirection = new DoubleSharedVariable("mp_objforloc"); this.svInGoorRegionForLoc = new IntSharedVariable("mp_ingoodregion"); this.cell_phoneSharedVariable = new StringSharedVariable("cell_phone"); this.fallSharedVariable = new StringSharedVariable("positionhumanfall"); this.sensorsSharedVariable = new StringSharedVariable("home_sensors"); this.isSuscribedToGestureVar = false; this.isSuscribedToLocationVar = false; this.isSuscribedToRegionVar = false; this.isSuscribedToRoomVar = false; this.isSuscribedToRecoSpeechs = false; this.isSuscribedToSkeletons = false; this.isSuscribedToNearesObjForLoc = false; this.isSuscribedToInGoodRegion = false; this.isSuscribedToCellphone = false; this.isSuscribedToFall = false; this.isSuscribedToHomeSensors = false; this.status = new HAL9000Status(); this.status.BrainWaveType = BrainWaveType.Alpha; this.cmdMan = new HAL9000CmdMan(this.status); this.cnnMan = new ConnectionManager("ACT-PLN", 2025, this.cmdMan); this.cnnMan.ClientConnected += new System.Net.Sockets.TcpClientConnectedEventHandler(cnnMan_ClientConnected); this.cnnMan.ClientDisconnected += new System.Net.Sockets.TcpClientDisconnectedEventHandler(cnnMan_ClientDisconnected); this.cnnMan.DataReceived += new ConnectionManagerDataReceivedEH(cnnMan_DataReceived); this.cmdMan.SharedVariablesLoaded += new SharedVariablesLoadedEventHandler(cmdMan_SharedVariablesLoaded); this.SetupCommandExecuters(); this.cnnMan.Start(); this.cmdMan.Start(); }
/// <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)); }
public void Run() { int svCount; cmdMan.Start(); Response rsp; IAsyncResult result = cmdMan.BeginSendCommand(new Command("stop", String.Empty), 100); cmdMan.EndSendCommand(result, out rsp); while (cnnMan.ConnectedClientsCount < 1) { Thread.Sleep(100); } e.WaitOne(); Console.WriteLine("Loading shared variables from blackboard"); svCount = cmdMan.SharedVariables.LoadFromBlackboard(); cmdMan.Ready = true; Console.WriteLine("Loaded " + svCount.ToString() + " shared variables."); if (svCount > 0) { Console.WriteLine("Enumerating:"); foreach (SharedVariable shv in cmdMan.SharedVariables) { Console.WriteLine("\t" + shv.ToString()); } } Console.WriteLine(); if (!cmdMan.SharedVariables.Contains(svSpeech)) { cmdMan.SharedVariables.Add(svSpeech); } else { svSpeech = (RecognizedSpeechSharedVariable)cmdMan.SharedVariables["recognizedSpeech"]; } if (!cmdMan.SharedVariables.Contains(svInteger)) { cmdMan.SharedVariables.Add(svInteger); } else { svInteger = (IntSharedVariable)cmdMan.SharedVariables["svInteger"]; } if (!cmdMan.SharedVariables.Contains(svDoubles)) { cmdMan.SharedVariables.Add(svDoubles); } else { svDoubles = (DoubleArraySharedVariable)cmdMan.SharedVariables["svDoubles"]; } if (!cmdMan.SharedVariables.Contains(svBytes)) { cmdMan.SharedVariables.Add(svBytes); } else { svBytes = (ByteArraySharedVariable)cmdMan.SharedVariables["svBytes"]; } if (!cmdMan.SharedVariables.Contains(svMatrix)) { cmdMan.SharedVariables.Add(svMatrix); } else { svMatrix = (MatrixSharedVariable)cmdMan.SharedVariables["svMatrix"]; } if (!cmdMan.SharedVariables.Contains(svVector)) { cmdMan.SharedVariables.Add(svVector); } else { svVector = (VectorSharedVariable)cmdMan.SharedVariables["svVector"]; } if (!cmdMan.SharedVariables.Contains(svString)) { cmdMan.SharedVariables.Add(svString); } else { svString = (StringSharedVariable)cmdMan.SharedVariables["svString"]; } if (!cmdMan.SharedVariables.Contains(svRecognized)) { cmdMan.SharedVariables.Add(svRecognized); } else { svRecognized = (StringSharedVariable)cmdMan.SharedVariables["recognized"]; } Console.Write("Subscribing..."); try { svSpeech.Subscribe(SharedVariableReportType.SendContent, SharedVariableSubscriptionType.WriteAny); svSpeech.WriteNotification += new SharedVariableSubscriptionReportEventHadler <Robotics.HAL.Sensors.RecognizedSpeech>(svSpeech_WriteNotification); svInteger.Subscribe(SharedVariableReportType.SendContent, SharedVariableSubscriptionType.WriteAny); svDoubles.Subscribe(SharedVariableReportType.SendContent, SharedVariableSubscriptionType.WriteAny); svDoubles.WriteNotification += new SharedVariableSubscriptionReportEventHadler <double[]>(svDoubles_WriteNotification); svMatrix.Subscribe(SharedVariableReportType.SendContent, SharedVariableSubscriptionType.WriteAny); svVector.Subscribe(SharedVariableReportType.SendContent, SharedVariableSubscriptionType.WriteAny); svString.Subscribe(SharedVariableReportType.SendContent, SharedVariableSubscriptionType.WriteAny); svRecognized.Subscribe(SharedVariableReportType.SendContent, SharedVariableSubscriptionType.WriteAny); svBytes.Subscribe(SharedVariableReportType.SendContent, SharedVariableSubscriptionType.WriteAny); svBytes.WriteNotification += new SharedVariableSubscriptionReportEventHadler <byte[]>(svBytes_WriteNotification); } catch (Exception ex) { Console.WriteLine(ex.Message); } Console.Write("\b\b\b"); Console.WriteLine(); Console.WriteLine("Done!"); if (cmdMan.SharedVariables.Contains("svBytes")) { byte[] data; Random rnd = new Random(); for (int i = 0; i < 10; ++i) { data = new byte[rnd.Next(1, 21)]; for (int j = 0; j < data.Length; ++j) { data[j] = (byte)rnd.Next(1, 220); } svBytes.TryWrite(data); Thread.Sleep(100); } } /* * if (cmdMan.SharedVariables.Contains("svDoubles")) * { * double[] data; * Random rnd = new Random(); * * for (int i = 0; i < 10; ++i) * { * data = new double[rnd.Next(1, 21)]; * for (int j = 0; j < data.Length; ++j) * data[j] = rnd.Next(1, 1000); * svDoubles.TryWrite(data); * Thread.Sleep(100); * } * } */ for (int i = 0; i < 500; ++i) { svSpeech.TryWrite(new Robotics.HAL.Sensors.RecognizedSpeech( new Robotics.HAL.Sensors.RecognizedSpeechAlternate[] { new Robotics.HAL.Sensors.RecognizedSpeechAlternate(i.ToString(), 1), new Robotics.HAL.Sensors.RecognizedSpeechAlternate("Hello", 0) } )); //Console.ReadLine(); } System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch(); /* * sw.Start(); * System.Text.StringBuilder sb = new System.Text.StringBuilder(65536); * for (int i = 0; i < 65536; ++i) * { * sb.Append((char)('a' + i % 25)); * } * string longStr = sb.ToString(); * sw.Stop(); * sw.Reset(); * //svString.TryWrite(longStr); * sw.Start(); * for (int i = 0; i < 1000; ++i ) * svString.TryWrite(longStr, 0); * sw.Stop(); * Console.WriteLine("Written 1000 times a 64k string > " + sw.ElapsedMilliseconds.ToString() + "ms elapsed."); * Console.ReadLine(); */ //Thread.Sleep(1000); svInteger.TryWrite(1); svDoubles.TryWrite(new double[] { 0, 0 }); svMatrix.Write(Robotics.Mathematics.Matrix.Identity(2)); svVector.Write(Robotics.Mathematics.Vector.Zero(4)); svString.TryWrite("Realmente dijo \"Hola mundo\"?"); Console.ReadLine(); Console.Clear(); //while (true) // Thread.Sleep(10); if (cmdMan.SharedVariables.Contains("var1")) { VarSharedVariable var1 = (VarSharedVariable)cmdMan.SharedVariables["var1"]; var1.WriteNotification += new SharedVariableSubscriptionReportEventHadler <string>(var1_WriteNotification); var1.Subscribe(SharedVariableReportType.SendContent, SharedVariableSubscriptionType.WriteAny); for (int i = 0; i < 10; ++i) { var1.Write(i.ToString()); Thread.Sleep(100); } } }