def build_state_diagram(fpath, attribute_builder=None, preprocess=True): ''' Returns a state diagram lexed from the given plantUML model :param fpath: path to state diagram *.puml file :param preprocess: run plantUML preprocessor on diagram :param attribute_builder: attribute builder instance for defining attribute logic :return: StateModel.StateDiagram ''' from PlantUML_Lexer import get_tokens_from_file tkns = get_tokens_from_file(fpath, preprocess=preprocess) builder = StateModelBuilder(attribute_builder=attribute_builder) diagram = builder.parse(tkns) dlog.rootlog.info("New diagram parsed from ", fpath) dlog.rootlog.info("Parsed " + str(len(diagram.state_names.values())) + "states") dlog.rootlog.info("Parsed " + str(len(diagram.get_transitions())) + "transitions") return diagram
if dest == 'END': print "====================Test Complete=================" if dest != 'END': ##State(name = get_dest).activate() ##print "Activating state %r: %r\n" %(dest_name, get_dest.active) self.recur(dest) if __name__ == "__main__": from ModelBuilder import StateModelBuilder import config, os, time from PlantUML_Lexer import get_tokens_from_file connection = OPC_Connect() time.sleep(1) input_path = os.path.join(config.specs_path, 'vpeng', 'Demo_3.0.puml') tkns = get_tokens_from_file(input_path) builder = StateModelBuilder() diagram = builder.parse(tkns) print "===========Test Start==========" exe = Execute(diagram = diagram.flatten_graph, connection = connection) exe.recur(in_state = "[*]")
##State(name = get_source).deactivate() ##print "\nState %r deactivated: %r" %(source_name, not get_source.active) if dest == 'END': print "====================Test Complete=================" if dest != 'END': ##State(name = get_dest).activate() ##print "Activating state %r: %r\n" %(dest_name, get_dest.active) self.recur(dest) if __name__ == "__main__": from ModelBuilder import StateModelBuilder import config, os, time from PlantUML_Lexer import get_tokens_from_file connection = OPC_Connect() time.sleep(1) input_path = os.path.join(config.specs_path, 'vpeng', 'Demo_3.0.puml') tkns = get_tokens_from_file(input_path) builder = StateModelBuilder() diagram = builder.parse(tkns) print "===========Test Start==========" exe = Execute(diagram=diagram.flatten_graph, connection=connection) exe.recur(in_state="[*]")