private static Variable _findVariable(string connectionPoint, IEnumerable <Variable> allVariables, IEnumerable <FBInstance> instances) { string[] nameSplit = Smv.SplitConnectionVariableName(connectionPoint); FBInstance fbInst = instances.FirstOrDefault(inst => inst.Name == nameSplit[0]); Variable foundVar = allVariables.FirstOrDefault(v => v.FBType == fbInst.InstanceType && v.Name == nameSplit[1]); return(foundVar); }
public void PutFBInstance(FBInstance instance) { Instances.Add(instance); }
public void PutFBInstance(FBInstance instance) { Instances.Add(instance); }
public string GenerateMain() { string mainModule = ""; FBType topLevelFbType = _storage.Types.FirstOrDefault(fbType => fbType.IsRoot); if (topLevelFbType == null) { throw new ArgumentNullException("Can't find root FB type"); } List <FBInstance> instanceList = new List <FBInstance>(); List <Connection> connections = new List <Connection>(); List <InstanceParameter> instanceParameters = new List <InstanceParameter>(); FBInstance instance = new FBInstance(topLevelFbType.Name + "_inst", topLevelFbType.Name, "Top-level FB instance", "main"); instanceList.Add(instance); mainModule += String.Format(Smv.ModuleDef, "main", ""); mainModule += CompositeFbSmv.FbInstances(instanceList, _storage.Events, _storage.Variables, connections, _settings) + "\n"; mainModule += CompositeFbSmv.InternalBuffersDeclaration(instanceList, connections, _storage.Events, _storage.Variables) + "\n"; if (_settings.GenerateDummyProperty) { mainModule += String.Format(Smv.VarDeclarationBlock, "false_var", Smv.DataTypes.BoolType); } mainModule += Smv.Assign; if (_settings.GenerateDummyProperty) { mainModule += String.Format(Smv.VarInitializationBlock, "false_var", Smv.False); mainModule += String.Format(Smv.NextVarAssignment, "false_var", Smv.False); } mainModule += CompositeFbSmv.InternalBuffersInitialization(instanceList, connections, _storage.Events, _storage.Variables, instanceParameters, true) + "\n"; mainModule += String.Format(Smv.VarInitializationBlock, instance.Name + "_" + Smv.Alpha, Smv.True); mainModule += String.Format(Smv.VarInitializationBlock, instance.Name + "_" + Smv.Beta, Smv.False); //Main module next blocks //********************** foreach (Variable variable in _storage.Variables.Where(v => v.FBType == topLevelFbType.Name && v.Direction == Direction.Input && !v.IsConstant)) { string smvVariable = instance.Name + "_" + variable.Name; if (variable.ArraySize == 0) { mainModule += String.Format(Smv.NextVarAssignment, smvVariable, smvVariable); } else { for (int i = 0; i < variable.ArraySize; i++) { mainModule += String.Format(Smv.NextVarAssignment, smvVariable + Smv.ArrayIndex(i), smvVariable + Smv.ArrayIndex(i)); } } } foreach (Event ev in _storage.Events.Where(ev => ev.FBType == topLevelFbType.Name)) { string smvVariable = instance.Name + "_" + ev.Name; string nextRule = ""; if (ev.Direction == Direction.Output) { nextRule = instance.Name + "." + "event_" + ev.Name + "_set : " + Smv.True + ";\n"; } else { nextRule = instance.Name + "." + "event_" + ev.Name + "_reset : " + Smv.False + ";\n"; } mainModule += String.Format(Smv.NextCaseBlock, smvVariable, nextRule); } string alphaRule = "\t" + instance.Name + "_" + Smv.Beta + " : " + Smv.True + ";\n" + "\t" + instance.Name + ".alpha_reset : " + Smv.False + ";\n"; string betaRule = "\t" + instance.Name + "_" + Smv.Beta + " : " + Smv.False + ";\n" + "\t" + instance.Name + ".beta_set : " + Smv.True + ";\n"; mainModule += String.Format(Smv.NextCaseBlock, instance.Name + "_" + Smv.Alpha, alphaRule); mainModule += String.Format(Smv.NextCaseBlock, instance.Name + "_" + Smv.Beta, betaRule); //********************** //mainModule += FbSmvCommon.ModuleFooter(_settings) + "\n"; if (_settings.GenerateDummyProperty) { mainModule += "\nLTLSPEC F false_var=TRUE"; } return(mainModule); }