public ConfigurationGroupLight ConvertToLight() { ConfigurationGroupLight configurationGroupLight = new ConfigurationGroupLight() { Configurations = this.Configurations.Cast <MgaFCO>().Select(x => GMELightObject.GetGMELightFromMgaObject(x)).ToArray(), IsDirty = this.IsDirty, Owner = this.Owner == null ? null : GMELightObject.GetGMELightFromMgaObject(this.Owner) }; return(configurationGroupLight); }
/// <summary> /// Inserts the configurations in alphabetical order and respects the ordering if the name has numbers. /// </summary> /// <param name="config">Configuration to insert to configuration list.</param> private void AddExportedCAItemQuadratic(GMELightObject config) { int i = 0; for (; i < this.lbExportedCAs.Items.Count; i++) { if (StrCmpLogicalW(((GMELightObject)this.lbExportedCAs.Items[i]).Name, config.Name) != -1) { break; } } this.lbExportedCAs.Items.Insert(i, config); }
public static GMELightObject GetGMELightFromMgaObject(IMgaObject subject) { GMELightObject gmeLightObject = new GMELightObject(); gmeLightObject.AbsPath = subject.AbsPath; gmeLightObject.GMEId = subject.ID; // TODO: figure out how to show to the user configurations when they have no uniqie names. gmeLightObject.Name = subject.Name; // TODO: set tool tip to ParentName/ObjectName // TODO: would be nice to use a regexp or something like that gmeLightObject.ToolTip = ShortenAbsPath(subject.AbsPath); gmeLightObject.Type = subject.MetaBase.Name; return(gmeLightObject); }
/// <summary> /// Inserts the configurations in alphabetical order and respects the ordering if the name has numbers. /// </summary> /// <param name="config">Configuration to insert to configuration list.</param> private void AddExportedCAItem(GMELightObject config) { int i = 0; for (; i < this.lbExportedCAs.Items.Count; i++) { if (StrCmpLogicalW(((GMELightObject)this.lbExportedCAs.Items[i]).Name, config.Name) != -1) { break; } } this.lbExportedCAs.Items.Insert(i, config); }
public static GMELightObject GetGMELightFromMgaObject(IMgaObject subject) { GMELightObject gmeLightObject = new GMELightObject(); gmeLightObject.AbsPath = subject.AbsPath; gmeLightObject.GMEId = subject.ID; // TODO: figure out how to show to the user configurations when they have no uniqie names. //// dashboard shows last 4 digit of the guid //var guidStr = new Guid(subject.GetGuidDisp()).ToString(); //string guidPortion = guidStr.Substring(guidStr.Length - 4); //gmeLightObject.Name = string.Format("[#{0}] {1}", guidPortion , subject.Name); gmeLightObject.Name = subject.Name; // TODO: set tool tip to ParentName/ObjectName // TODO: would be nice to use a regexp or something like that gmeLightObject.ToolTip = ShortenAbsPath(subject.AbsPath); gmeLightObject.Type = subject.MetaBase.Name; return gmeLightObject; }
private void Process(MgaFCO currentobj) { if (currentobj == null) { this.Logger.WriteError("Context is invalid. This component can be executed only if a valid context is open in the main editor (e.g.: Test Bench, Component Assembly)."); return; } MgaGateway.PerformInTransaction(() => { this.Logger.WriteInfo("Processing {0} [{1}] model", currentobj.Name, currentobj.MetaBase.Name); }); using (var masterInterpreter = new CyPhyMasterInterpreterAPI(currentobj.Project, this.Logger)) { masterInterpreter.IsInteractive = this.InteractiveMode; this.Logger.WriteDebug("Interactive mode: {0}", masterInterpreter.IsInteractive); Rules.ContextCheckerResult[] contextCheckerResults = null; // check context var checkerSuccess = false; try { checkerSuccess = masterInterpreter.TryCheckContext(currentobj as MgaModel, out contextCheckerResults); } catch (ArgumentOutOfRangeException ex) { this.Logger.WriteDebug(ex.ToString()); this.Logger.WriteError(ex.Message); return; } List <Rules.ContextCheckerResult> sortedResults = contextCheckerResults.ToList(); // sort results Passed, Failed, then alphabetically based on message. sortedResults.Sort((x, y) => { return(x.Success == y.Success ? x.Message.CompareTo(y.Message) : y.Success.CompareTo(x.Success)); }); // Print Checker results MgaGateway.PerformInTransaction(() => { foreach (var result in sortedResults) { if (result.Success) { this.Logger.WriteCheckPassed(" <i><a href=\"mga:{0}\">{1}</a></i> {2}", result.Subject.ID, result.Subject.Name, result.Message); } else { this.Logger.WriteCheckFailed(" <i><a href=\"mga:{0}\">{1}</a></i> {2}", result.Subject.ID, result.Subject.Name, result.Message); } } }); bool controlWasHeld = false; int VK_CONTROL = 0x11; // if user held the control ignore the checker results ... for debugging purposes ONLY! if ((bool)((GetKeyState(VK_CONTROL) & 0x8000) == 0x8000)) { controlWasHeld = true; } if (this.InteractiveMode == false) { controlWasHeld = false; } if (sortedResults.Any(x => x.Success == false)) { this.Logger.WriteError("Context is invalid see messages above. Please fix the problems."); if (controlWasHeld == false) { return; } else { this.Logger.WriteWarning("Bypassing checker results. This mode is strictly for debugging purposes."); } } if (checkerSuccess == false) { return; } // context is valid // show GUI for the user ConfigurationSelection selection = null; try { selection = masterInterpreter.ShowConfigurationSelectionForm(currentobj as MgaModel, enableDebugging: controlWasHeld); if (selection.SelectedConfigurations == null) { // user selected "Run in parallel" return; } MgaGateway.PerformInTransaction(() => { this.Logger.WriteDebug("MasterExe command: CyPhyMasterExe.exe \"{0}\" \"{1}\" \"{2}\"", currentobj.Project.ProjectConnStr, GMELightObject.ShortenAbsPath(currentobj.AbsPath), String.Join("\" \"", selection.SelectedConfigurations.Cast <IMgaFCO>().Select(f => GMELightObject.ShortenAbsPath(f.AbsPath)).ToArray())); }); } catch (ExecutionCanceledByUserException ex) { this.Logger.WriteWarning("Operation was canceled by user. {0}", ex.Message); return; } MasterInterpreterResult[] miResults = null; // Get a progress dialog using (var progressDialog = new ProgressDialog(masterInterpreter)) { masterInterpreter.MultipleConfigurationProgress += progressDialog.MultipleConfigurationProgressHandler; masterInterpreter.SingleConfigurationProgress += progressDialog.SingleConfigurationProgressHandler; if (masterInterpreter.IsInteractive) { progressDialog.ShowWithDisabledMainWindow(); } try { miResults = masterInterpreter.RunInTransactionWithConfig(selection); } catch (AnalysisModelInterpreterConfigurationFailedException ex) { this.Logger.WriteWarning("Operation was canceled by user. {0}", ex.Message); } catch (ExecutionCanceledByUserException ex) { this.Logger.WriteWarning("Operation was canceled by user. {0}", ex.Message); } } masterInterpreter.WriteSummary(miResults); } }