def trace(trace_file, type, model):
    type_map = {1: "INTERNAL", 2: "EXTERNAL", 3: "CONFLUENT"}
    type = type_map[type]
    if trace_file is not None:
        trace_file.write("%s TRANSITION in <%s> @ %s\n" % (type, model.getModelFullName(), model.timeLast[0]))
        trace_file.write("  NEW STATE <%s>\n" % (model.state))
        if type != "EXTERNAL":
            trace_file.write("  OUTPUTFNC returned %s\n" % model.my_output)
        elif type != "INTERNAL":
            trace_file.write("  inputs were %s\n" % model.my_input)
        trace_file.write("  time_next: %s (ta: %s)\n" % (model.time_next[0], model.time_next[0] - model.timeLast[0]))