コード例 #1
0
        /// <summary>
        /// Search the inputs or outputs of the parent model of the input given to return the input indexes in the Input array it is contained
        /// </summary>
        /// <param name="input">Input to find the indexes</param>
        /// <param name="arrayToSearchIn">Array of the DeMIMOI to search in (Inputs or Outputs array)</param>
        /// <returns>The indexes found (both to -1 if it does not succeed)</returns>
        private static int[] GetInputOutputIndexes(DeMIMOI_InputOutput input, DeMIMOI_InputOutputType arrayToSearchIn)
        {
            // Initialize the indexes found to -1 (default if not found)
            int[] indexesFound = new int[2];
            indexesFound[0] = -1;
            indexesFound[1] = -1;

            // Create a reference that points the array we should search in
            List<List<DeMIMOI_InputOutput>> demimoi_io_array;
            if (arrayToSearchIn == DeMIMOI_InputOutputType.INPUT)
            {
                demimoi_io_array = input.Parent.Inputs;
            }
            else
            {
                demimoi_io_array = input.Parent.Outputs;
            }

            // Search the selected array to find the input_output in
            for (int i = 0; i < demimoi_io_array.Count; i++)
            {
                for (int j = 0; j < demimoi_io_array[i].Count; j++)
                {
                    // If we find it
                    if (demimoi_io_array[i][j] == input)
                    {
                        // Get the index and leave the whole loop
                        indexesFound[0] = i;
                        indexesFound[1] = j;
                        break;
                    }
                }
                // If we found the indexes, leave the loop
                if (indexesFound[0] != -1)
                {
                    break;
                }
            }

            return indexesFound;
        }
コード例 #2
0
        /// <summary>
        /// Constructs a new DeMIMOI_InputOutput object by specifying its type and its parent DeMIMOI object
        /// </summary>
        /// <param name="parent">DeMIMOI object in which it is used and included</param>
        /// <param name="type">Input/Output type</param>
        public DeMIMOI_InputOutput(DeMIMOI parent, DeMIMOI_InputOutputType type)
        {
            Initialize();

            // Set the specified type
            Type = type;
            // Set the parent DeMIMOI object
            Parent = parent;
        }
コード例 #3
0
ファイル: DeMIMOI.cs プロジェクト: remyzerems/DeMIMOI
        protected virtual string GenerateLinkGraphVizCode(List<List<DeMIMOI_InputOutput>> input_output, DeMIMOI_InputOutputType argument_type, bool show_labels)
        {
            string code = "";

            // For each input/output
            for (int i = 0; i < input_output.Count; i++)
            {
                // For each delay of the i-th input/output
                for (int j = 0; j < input_output[i].Count; j++)
                {
                    if (input_output[i][j].ConnectedTo != null)
                    {
                        if (input_output[i][j].Type == DeMIMOI_InputOutputType.INPUT)
                        {
                            DeMIMOI ConnectedParent = input_output[i][j].ConnectedTo.Parent;
                            int connected_index = -1;
                            int delay_offset = -1;
                            for (int k = 0; k < ConnectedParent.Outputs.Count; k++)
                            {
                                for (int l = 0; l < ConnectedParent.Outputs[k].Count; l++)
                                {
                                    if (ConnectedParent.Outputs[k][l].ID == input_output[i][j].ConnectedTo.ID)
                                    {
                                        connected_index = k;
                                        delay_offset = l;
                                    }
                                }
                            }
                            code += input_output[i][j].ConnectedTo.Parent.GetType().Name.Replace("`", "_") + "_" + input_output[i][j].ConnectedTo.Parent.ID + ":o" + connected_index + "_" + delay_offset + ":e -> " + GetType().Name.Replace("`", "_") + "_" + ID + (argument_type == DeMIMOI_InputOutputType.INPUT ? ":i" : ":o") + i + "_" + j + (argument_type == DeMIMOI_InputOutputType.INPUT ? ":w" : ":e");
                            if (show_labels == true)
                            {
                                if (delay_offset > 0)
                                {
                                    code += " [ label=\"t - " + delay_offset + "\" ]";
                                }
                                else
                                {
                                    code += " [ label=\"t\" ]";
                                }
                            }
                            code += ";\n";
                        }
                    }
                }
            }

            return code;
        }
コード例 #4
0
        /// <summary>
        /// Constructs a new DeMIMOI_InputOutput object by specifying its type
        /// </summary>
        /// <param name="type">Input/Output type</param>
        public DeMIMOI_InputOutput(DeMIMOI_InputOutputType type)
        {
            Initialize();

            // Set the specified type
            Type = type;
        }
コード例 #5
0
ファイル: DeMIMOI.cs プロジェクト: remyzerems/DeMIMOI
 protected virtual string GenerateLinkGraphVizCode(List<List<DeMIMOI_InputOutput>> input_output, DeMIMOI_InputOutputType argument_type)
 {
     return GenerateLinkGraphVizCode(input_output, argument_type, true);
 }