public GraphVarAddErrorsType AddTagVariable(string varName, GraphVarType varType) { GraphVarAddErrorsType result = GraphVarAddErrorsType.none; if (varName == FSMGUtility.StringTag_Undefined) { return(GraphVarAddErrorsType.invalidName); } if (variables.ContainsKey(varName) == true) { result = GraphVarAddErrorsType.graph_already_exists; } else { variables.Add(varName, varType); } return(result); }
/// <summary> /// Sincroniza as variaveis e trajetos do componente com as variaveis do gráfico de estados /// </summary> public void SyncVariablesAndTargets() { SyncTargets(); if (graph == null) { return; } TagVarList graphVariables = null; TagVarList myTagVariables = GetVariablesAsTag(); _graph.GetTagVariables(out graphVariables); //Remove variaveis que estejam somente no componente mas que nao estejam no grafico foreach (string variable in myTagVariables.Keys) { if (graphVariables.ContainsKey(variable) == false) { RemoveVariable(variable, myTagVariables[variable]); } } myTagVariables.Clear(); myTagVariables = null; //Adiciona variaveis marcadas no grafico que não existam no FSM foreach (string variable in graphVariables.Keys) { GraphVarType varType = graphVariables[variable]; switch (varType) { case GraphVarType.Boolean: if (boolVars.ContainsKey(variable) == false) { boolVars.Add(variable, new BoolVar()); } break; case GraphVarType.Double: if (doubleVars.ContainsKey(variable) == false) { doubleVars.Add(variable, new DoubleVar()); } break; case GraphVarType.Float: if (floatVars.ContainsKey(variable) == false) { floatVars.Add(variable, new FloatVar()); } break; case GraphVarType.Integer: if (intVars.ContainsKey(variable) == false) { intVars.Add(variable, new IntVar()); } break; } } graphVariables.Clear(); graphVariables = null; }