private static void WriteVariables(Module module) { string op = SMVKeys.VAR + "\n"; //define custom variables //status variable for all types op += TVariables.VariableDefinition(module.Status); op += TVariables.VariableDefinition(module.Turn); //if module has arb, seq or max strategies if (module.HasArbitraryStrategy || module.HasSequenceStrategy || module.HasMaxStrategy) { op += TVariables.VariableDefinition(module.Count); } if (module.HasConnection) { foreach (var connection in module.Connections) { op += TVariables.VariableDefinition(connection); } } //execution strategy variables, e.g. choice foreach (var strategy in module.ExecutionStrategies) { foreach (var variable in strategy.CustomVars) { op += TVariables.VariableDefinition(variable); } } // model variables //sort variables, then print module.Variables = SMVUtil.sortVariable(module.Variables); foreach (var variable in module.Variables) { op += "\t" + TVariables.VariableDefinition(variable); } Writer.WriteLine(op); }
private static void WriteMain(SMVModel nuSMV) { TUtil.AddDashedComment("MAIN"); string op = SMVKeys.MODULE + " " + SMVKeys.MAIN + "\n"; op += SMVKeys.VAR + "\n"; //write synch,and PStep vars at first. op += TVariables.VariableDefinition(nuSMV.MainModule.Synch); op += TVariables.VariableDefinition(nuSMV.MainModule.PStep); //write instances foreach (var module in nuSMV.Modules) { //parent instance op += TVariables.Instances(module.Instance); //if exists, then child instances if (module.HasDivisionRule) { foreach (var childInstance in module.ChildInstances) { op += TVariables.Instances(childInstance); } } } op += SMVKeys.ASSIGN + "\n"; //write init of synch and PStep vars op += TVariables.InitVariable(nuSMV.MainModule.Synch); op += TVariables.InitVariable(nuSMV.MainModule.PStep); //write next of synch and PStep vars op += TVariables.VariableNext(nuSMV.MainModule.Synch); op += TVariables.VariableNext(nuSMV.MainModule.PStep); Writer.WriteLine(op); }