protected override void DoCommandAction()
        {
            Tile.TimeAttributes att = FPGA.FPGA.Instance.GetTimeAttribute(OldName);

            bool[] presentAtts = Tile.GetPresentTimeAttributes();
            if (presentAtts == null || !presentAtts[(int)att])
            {
                Console.WriteLine("The provided time attibute " + OldName + " was not found in the model.");
                return;
            }

            FPGA.FPGA.Instance.SetTimeModelAttributeName(att, NewName);
            Console.WriteLine("Successfully renamed " + OldName + " to " + NewName);
        }
            /// <summary>
            /// Validates the parameter SortByAttribute
            /// </summary>
            /// <param name="attribute"></param>
            private void ValidateSortByAttribute(string attribute)
            {
                // If there is any input
                if (!string.IsNullOrEmpty(attribute))
                {
                    try
                    {
                        Tile.TimeAttributes att = FPGA.FPGA.Instance.GetTimeAttribute(attribute);

                        // Ensure that the attribute is in the model
                        if (Tile.GetPresentTimeAttributes()[(int)att])
                        {
                            SortingAttribute = att;
                        }
                    }
                    catch (Exception)
                    {
                    }
                }
                // If no input - exit
                else
                {
                    msg_sortingAttribute = "none";
                    return;
                }

                // Input was not parsed successfully
                if (SortingAttribute == null)
                {
                    msg_sortingAttribute = "none - Supplied sorting attribute was not found in the model.";
                    return;
                }

                // Check if sorting attribute is included in PrintLatency
                if (PrintLatency == null || (SortingAttribute is Tile.TimeAttributes ta && !PrintLatency.Contains(ta)))
                {
                    msg_sortingAttribute = "none - Supplied sorting attribute was not enabled in PrintLatency.";
                }
            }
Exemplo n.º 3
0
 public void SetTimeModelAttributeName(Tile.TimeAttributes attribute, string newName)
 {
     GetTimeModelAttributesNames[(int)attribute] = newName;
 }
Exemplo n.º 4
0
 public string GetTimeModelAttributeName(Tile.TimeAttributes attribute)
 {
     return(GetTimeModelAttributesNames[(int)attribute]);
 }
            /// <summary>
            /// Validates the parameter PrintLatency
            /// </summary>
            /// <param name="printLatency"></param>
            private void ValidatePrintLatency(List <string> printLatency)
            {
                // If there is any input
                if (printLatency.Where(l => !"".Equals(l)).Count() > 0)
                {
                    // Input list length can't be bigger than the amount of present attributes
                    if (PresentAttributesCount < printLatency.Count)
                    {
                        msg_printLatency =
                            "none - Printing latency requested for " + printLatency.Count +
                            " entries, but the model contains data for " + PresentAttributesCount +
                            " attributes.";
                        return;
                    }
                }
                // If no input - exit
                else
                {
                    msg_printLatency = "none";
                    return;
                }

                // There is input, prepare for parsing
                PrintLatency = new List <Tile.TimeAttributes>();
                bool parsed = false;

                // Try parsing in boolean format first
                if (PresentAttributesCount == printLatency.Count)
                {
                    for (int i = 0; i < printLatency.Count; i++)
                    {
                        parsed = true;
                        if (bool.TryParse(printLatency[i], out bool b))
                        {
                            if (b)
                            {
                                PrintLatency.Add(FPGA.FPGA.Instance.GetTimeAttribute(PresentAttributesNames[i]));
                            }
                        }
                        else
                        {
                            PrintLatency.Clear();
                            parsed = false;
                            break;
                        }
                    }
                }

                // If that didn't work try the string format
                if (!parsed)
                {
                    try
                    {
                        for (int i = 0; i < printLatency.Count; i++)
                        {
                            Tile.TimeAttributes attribute = FPGA.FPGA.Instance.GetTimeAttribute(printLatency[i]);
                            // If the user inputted the same attribute twice, we accept the input but we don't repeat the attribute
                            if (!PrintLatency.Contains(attribute))
                            {
                                PrintLatency.Add(attribute);
                            }
                        }
                        parsed = true;
                    }
                    catch (Exception)
                    {
                        // Invalid attribute name supplied by the user, abort the printing
                        PrintLatency = null;
                    }
                }

                if (!parsed)
                {
                    msg_printLatency = "none - Failed to parse the PrintLatency input.";
                }
            }