/// <summary> /// Add a receiver on this data stream /// </summary> /// <param name="r">A data receiver that should receive data on this stream</param> public void AddReceiver(DataReceiver r) { if (!receivers.Contains(r)) { receivers.Add(r); } }
/// <summary> /// Constructor /// </summary> public TestConfiguration() { internalReceiver = new DataReceiver(); ParameterControlTemplate = new ParameterControlTemplate(); instructionEntries = new List <InstructionEntry>(); instructionEntryQueue = new Queue <InstructionEntry>(); // Possible copy all instructions into instructionEntries if loaded from DB }
private void ReceiveSensorList(object _sensor_list, string attribute, string label) { Debug.Log("Receive sensor list " + attribute); JObject sensor_list = (JObject)_sensor_list; ThreadHelper.UI_Invoke(this, null, UISensorCheckboxList, (data) => { autoObservableValues = new ObservableNumericValueCollection(); foreach (var elem in (JObject)data["sensor_list"]) { if (!sensor_information.ContainsKey(elem.Key)) { //string sensor_name = label + ": " + elem.Key; string sensor_name = elem.Key; sensor_information.Add(sensor_name, elem.Value.ToString()); UISensorCheckboxList.Items.Add(sensor_name); if (DataReceiver.Observe) { AddParameterControlRow(new ObservedDataRow { name = elem.Key, value = "" } ); IObservableNumericValue o = autoObservableValues.AddWithType(elem.Key, elem.Value.ToString()); o.OnUpdate(ObservedValueChanged); } } } if (autoObservableValues.Count > 0) { autoParamControlTemplate.SetCollection(autoObservableValues); DataReceiver.SetObservableNumericValues(autoObservableValues); } }, new Hashtable { { "form", this }, { "panel", null }, { "control", UISensorCheckboxList }, { "sensor_list", sensor_list } }); }
public SatStatMainForm() { InitializeComponent(); instruction_list = new JObject(); PopulateRecentConnect(); parameterControlTemplates = ParameterControlTemplate.GetListFromDb(); autoParamControlTemplate = new ParameterControlTemplate { Name = "Auto generated parameter control template" }; Program.serial = new SerialHandler(); Program.streamSimulator = new StreamSimulator(); Program.socketHandler = new SocketHandler(); Program.serial.OnConnected(OnStreamConnected); Program.streamSimulator.OnConnected(OnStreamConnected); Program.socketHandler.OnConnected(OnStreamConnected); Program.serial.OnDisconnected(OnStreamDisconnected); Program.streamSimulator.OnDisconnected(OnStreamDisconnected); Program.socketHandler.OnDisconnected(OnStreamDisconnected); activeStreams = new Dictionary <string, DataStream>(); activeStreams.Add("serial", Program.serial); activeStreams.Add("streamSimulator", Program.streamSimulator); activeStreams.Add("socketHandler", Program.socketHandler); dataReceiver = new DataReceiver { Observe = true }; dataReceiver.OnPayloadReceived(ReceivePayload); dataReceiver.OnObservedvalueChanged(ObservedValueChanged); sensorListReceiver = new DataReceiver(); sensorListReceiver.OnPayloadReceived(ReceiveSensorList); sensorListReceiver.Subscribe(Program.serial, "available_data", "JObject"); instructionListReceiver = new DataReceiver(); instructionListReceiver.OnPayloadReceived(ReceiveInstructionList); instructionListReceiver.Subscribe(Program.serial, "available_instructions", "JObject"); startTime = DateTime.Now; xAxis = new DateTimeAxis { Key = "xAxis", Position = AxisPosition.Bottom, Title = "Time", Minimum = DateTimeAxis.ToDouble(startTime), Maximum = DateTimeAxis.ToDouble(DateTime.Now.AddMinutes(1)), MinorIntervalType = DateTimeIntervalType.Minutes }; yAxis = new LinearAxis { Key = "yAxis", Position = AxisPosition.Left, Title = "Value", MinimumRange = 10 }; plotModel = new PlotModel { Title = "Live data view" }; plotModel.Axes.Add(xAxis); plotModel.Axes.Add(yAxis); oxPlot.Model = plotModel; DiscoverComDevices(); }
/// <summary> /// A DataSubscription needs a receiver to receive data trough this subscription, to define the attribute that contains the relevant data that the receiver wants to receive, and to define what datatype this data is represented as so it can be correctly cast on delivery /// </summary> /// <param name="r">The object that should receive the data</param> /// <param name="attr">The attribute to subscribe to</param> /// <param name="type">The datatype of the data delivered on the subscription</param> public DataSubscription(DataReceiver r, string attr, string type) { receiver = r; attribute = attr; data_type = type; }