/// <summary> /// Start a test configuration run on a particular data stream /// </summary> /// <param name="stream">The data stream to run the test configuration on</param> public void Run(DataStream stream) { // Reset the queue position and clear the instruction queue. Also sort the instructions list by // their UI index so that we execute the instructions in the correct order queue_position = -1; List <InstructionEntry> sortedInstructionEntries = instructionEntries.OrderBy(o => o.instruction._ui_index).ToList(); instructionEntryQueue.Clear(); foreach (InstructionEntry entry in sortedInstructionEntries) { instructionEntryQueue.Enqueue(entry); } // Tell the internal receiver to observe the values it is getting // this will display an error for the attribute "instruction_complete" since // this attribute holds a string. Should be fixed in a future update if (ParameterControlTemplate != null) { internalReceiver.Observe = true; loadParameterControlTemplate(ParameterControlTemplate, stream); } internalReceiver.OnPayloadReceived((object payload, string attribute, string label) => { OnPayloadReceive(payload); if (attribute == "instruction_complete" || attribute == "instruction_done") { RunQueuedInstruction(stream); } }); internalReceiver.OnObservedvalueChanged((IObservableNumericValue val) => { OnObservedValueChange(val); }); if (!internalReceiver.HasSubscription("instruction_complete")) { internalReceiver.Subscribe(stream, "instruction_complete", "string"); internalReceiver.Subscribe(stream, "instruction_done", "string"); } // Start instruction queue execution is_running = true; RunQueuedInstruction(stream); }
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(); }