using System; #if AVOID_GENERICS using System.Collections; using List_ReceiverPin = System.Collections.ArrayList; using List_SenderPin = System.Collections.ArrayList; using IEnumerable_SenderPin = System.Collections.IEnumerable; using IEnumerable_ReceiverPin = System.Collections.IEnumerable; using ConstantValueSource_bool = ZenStudio.Gui.ConstantValueSource; using List_IDynamicLink = System.Collections.ArrayList; using IEnumerable_IDynamicLink = System.Collections.IEnumerable; using IEnumerable_IAttachedPropertyBag = System.Collections.IEnumerable; #else using System.Collections.Generic; using System.Linq; using List_ReceiverPin = System.Collections.Generic.List; using List_SenderPin = System.Collections.Generic.List; using IEnumerable_SenderPin = System.Collections.Generic.IEnumerable; using IEnumerable_ReceiverPin = System.Collections.Generic.IEnumerable; using ConstantValueSource_bool = ZenStudio.Gui.ConstantValueSource; using List_IDynamicLink = System.Collections.Generic.List; using IEnumerable_IDynamicLink = System.Collections.Generic.IEnumerable; using IEnumerable_IAttachedPropertyBag = System.Collections.Generic.IEnumerable; #endif using System.Text; using ZenStudio.Sensors; using System.Threading; namespace ZenStudio.Gui.Panda.Sensors { class DebugTestSensor : IDebugTestSensor { string value; string Value { get { return value; } set { this.value = value; UpdatePins(); } } Thread bthread; public DebugTestSensor() { output = new SenderPin(this, "Value"); Value = "???"; bthread = new Thread(() => { Random r = new Random(); while (true) { Thread.Sleep(1000); Value = r.Next().ToString(); } }); bthread.Start(); } SenderPin output; private void UpdatePins() { output.UpdateValue(Value); } public IEnumerable_SenderPin Outputs { #if AVOID_YIELD get { return new SenderPin[] { output }; } // here we can yield one coz its const #else get { yield return output; } // here we can yield one coz its const #endif } public IEnumerable_ReceiverPin Inputs { #if AVOID_YIELD get { return new ReceiverPin[] { }; } #else get { yield break; } #endif } public void ValueReceived(ReceiverPin input, object value) { throw new InvalidOperationException("Const cannot receive!"); } public ReceiverPin GetInput(string name) { throw new NotImplementedException(); } public SenderPin GetOutput(string name) { if (name != "Value") { throw new KeyNotFoundException(); } else { return output; } } } }