public DeMIMOI_Port Add(DeMIMOI_Port new_input_output_port) { if (new_input_output_port != null) { return Add(new_input_output_port.IODelayCount); } else { return this; } }
public DeMIMOI_Chart(DeMIMOI_Port input_port, Chart chart) : base(input_port, null) { Initialize(input_port, chart); }
/// <summary> /// Initializes outputs arrays /// </summary> /// <param name="output_count">Number of outputs of the system</param> /// <param name="output_delays_count">Number of delayed output steps</param> protected void InitializeOutputs(DeMIMOI_Port output_port) { if (output_port != null) { // Create the outputs image for time t CurrentOutputs = new List<DeMIMOI_InputOutput>(); for (int j = 0; j < output_port.IODelayCount.Length; j++) { CurrentOutputs.Add(new DeMIMOI_InputOutput(this, DeMIMOI_InputOutputType.OUTPUT)); } // Create all the outputs including delayed outputs Outputs = new List<List<DeMIMOI_InputOutput>>(); for (int i = 0; i < output_port.IODelayCount.Length; i++) { // Create the delayed outputs for the current output List<DeMIMOI_InputOutput> outputs_i_n = new List<DeMIMOI_InputOutput>(); for (int j = 0; j < output_port.IODelayCount[i]; j++) { DeMIMOI_InputOutput io = new DeMIMOI_InputOutput(this, DeMIMOI_InputOutputType.OUTPUT); io.Connected += new DeMIMOI_ConnectionEventHandler(DeMIMOI_Connected); io.Disconnected += new DeMIMOI_ConnectionEventHandler(DeMIMOI_Disconnected); outputs_i_n.Add(io); } Outputs.Add(outputs_i_n); } } }
/// <summary> /// Initialize a DeMIMOI Chart /// </summary> /// <param name="input_port">The input port that represents the DeMIMOI Chart inputs (i.e. series to draw)</param> /// <param name="chart">The chart control to use to draw the series in (can be user defined or if null, the internal one will be used)</param> void Initialize(DeMIMOI_Port input_port, Chart chart) { ID = AllocNewId(); Name = GetType().Name + ID; // If no chart has been specified, use the internal definition if (chart == null) { // Initialize the internal Chart control with default values Chart = new Chart(); Chart.Top = 0; Chart.Left = 0; Chart.Width = 256; Chart.Height = 128; } else { // A chart has been specified by the user, so use this one Chart = chart; } // Delete any series that would already be present Chart.Series.Clear(); // Delete any chart area Chart.ChartAreas.Clear(); // Delete any legends Chart.Legends.Clear(); // Hook on double clicks Chart.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(Chart_MouseDoubleClick); // Add as many series that we have inputs for (int i = 0; i < input_port.IODelayCount.Length; i++) { // Create a chart area for each input string chartarea_name = "zone" + i; Chart.ChartAreas.Add(chartarea_name); // Zoom management Chart.ChartAreas[chartarea_name].CursorX.IsUserSelectionEnabled = true; Chart.ChartAreas[chartarea_name].CursorY.IsUserSelectionEnabled = true; Chart.ChartAreas[chartarea_name].AxisX.ScaleView.Zoomable = true; Chart.ChartAreas[chartarea_name].AxisX.ScrollBar.IsPositionedInside = true; Chart.ChartAreas[chartarea_name].AxisY.ScaleView.Zoomable = true; Chart.ChartAreas[chartarea_name].AxisY.ScrollBar.IsPositionedInside = true; // Allow the graph not to start from 0 but to focus on the values to display Chart.ChartAreas[chartarea_name].AxisY.IsStartedFromZero = false; string legends_name = "Legends" + i; Chart.Legends.Add(legends_name); Chart.Legends[legends_name].DockedToChartArea = chartarea_name; // Put the legend text on the bottom of the chart Chart.Legends[legends_name].Docking = Docking.Bottom; // And outside of the chart area, then centered horizontally Chart.Legends[legends_name].IsDockedInsideChartArea = false; Chart.Legends[legends_name].Alignment = System.Drawing.StringAlignment.Center; // For each delayed input, create a series on this zone for (int j = 0; j < input_port.IODelayCount[i]; j++) { string series_name = "Series" + i + "_" + j; Chart.Series.Add(series_name); Chart.Series[series_name].ChartType = SeriesChartType.FastLine; Chart.Series[series_name].ChartArea = chartarea_name; Chart.Series[series_name].ToolTip = "#SERIESNAME (#VALX,#VALY)"; // Assign the legends to the series Chart.Series[series_name].Legend = legends_name; } } // Set the timestep unit to 1 (i.e. the default unit is steps) TimestepUnit = 1.0; // Subscribe to the connection event to be notified when an input of the model is connected Connected += new DeMIMOI_ConnectionEventHandler(DeMIMOI_Chart_Connected); }
/// <summary> /// Creates a new DeMIMOI object /// </summary> /// <param name="input_count">Number of inputs of the system</param> /// <param name="input_delays_count">Number of delayed input steps</param> /// <param name="output_count">Number of outputs of the system</param> /// <param name="output_delays_count">Number of delayed output steps</param> public DeMIMOI(DeMIMOI_Port input_port, DeMIMOI_Port output_port) { Initialize(input_port, output_port); }
/// <summary> /// Initializes a new DeMIMOI object /// </summary> /// <param name="input_count">Number of inputs of the system</param> /// <param name="input_delays_count">Number of delayed input steps</param> /// <param name="output_count">Number of outputs of the system</param> /// <param name="output_delays_count">Number of delayed output steps</param> protected void Initialize(DeMIMOI_Port input_port, DeMIMOI_Port output_port) { // Check the parameters to see if there's no strange values... //CheckParameters(input_count, input_delays_count, output_count, output_delays_count); // Set name and ID ID = AllocNewId(); Name = GetType().Name + "_" + ID; Description = ""; if (Instances == null) { Instances = new List<DeMIMOI>(); } Instances.Add(this); // Initialize inputs and outputs arrays InitializeInputs(input_port); InitializeOutputs(output_port); }
/// <summary> /// Creates the DeMIMOI_Delegate object /// </summary> /// <param name="input_port">Input port that describes the input of the model</param> /// <param name="output_port">Output port that describes the output of the model</param> /// <param name="update_delegate">Delegate function to call when the model has to be updated</param> public DeMIMOI_Delegate(DeMIMOI_Port input_port, DeMIMOI_Port output_port, DeMIMOI_UpdateDelegate update_delegate) : base(input_port, output_port) { Initialize(input_port, output_port, update_delegate); }
static int current_id = 0; // Current ID to allocate to a new DeMIMOINeuralNetwork object #endregion Fields #region Constructors /// <summary> /// Creates a DeMIMOI_Delegate object /// </summary> /// <param name="input_port">Input port that describes the input of the model</param> /// <param name="output_port">Output port that describes the output of the model</param> public DeMIMOI_Delegate(DeMIMOI_Port input_port, DeMIMOI_Port output_port) : base(input_port, output_port) { Initialize(input_port, output_port, null); }
/// <summary> /// Initialize the DeMIMOI_Delegate object /// </summary> /// <param name="input_port">Input port that describes the input of the model</param> /// <param name="output_port">Output port that describes the output of the model</param> /// <param name="update_delegate">Delegate function to call when the model has to be updated</param> private void Initialize(DeMIMOI_Port input_port, DeMIMOI_Port output_port, DeMIMOI_UpdateDelegate update_delegate) { ID = AllocNewId(); Name = GetType().Name + "_" + ID; UpdateDelegate = update_delegate; }