An example of what M/POWER looks like as a programming language saved out in text form. The equivalent of an object method procedure is a generic with a relational constraint expression. 5$ "*** Variables ***" $ "*** Inputs ***" $ define_input F1 currency = 5.00 seconds; simulation = F1 + dt * dF1dt + random(4) - 2; simulation_initial_value = 0; system = false; route = false; unit = false; history_size = default; setting = going_up_fast, currency = infinite,string_print; cp = dF1dt; hi_limit = 100; medium_limit = 50; low_limit = 10; monitoring_status = false, currency = infinite; $ define_input F2 currency = 5.00 seconds; simulation = F2 + dt * dF2dt + random(5) - 2.5; simulation_initial_value = 0; system = false; route = false; unit = false; history_size = default; setting = going_up_fast, currency = infinite,string_print; cp = dF2dt; hi_limit = 120; medium_limit = 95; low_limit = -5; monitoring_status = false, currency = infinite; $ define_input Ri1 currency = 1 seconds; simulation = grandom(10,2.5); system = false; route = false; unit = false; history_size = default; range = hrange(Ri1,1 minute); mean = hmean(Ri1, 1 minute); std = hsdev(Ri1, 1 minute); $ "*** Activities ***" $ define_activity after_startup send(engineer,AST); $ define_activity general sequence( ave of general is apply_to_population(hasmedium,"+") / population(hasmedium), run_ave of general is run_ave of general * 0.5 + ave of general * 0.5, dev of general is apply_to_population(hasmedium,max,overmedium), run_dev of general is run_dev of general * 0.5 + dev of general * 0.5, send(engineer,GENMSG1), if dev of general > 0 then apply_to_population(hasmedium,sequence,this(x,if overmedium(x) >= dev of general then sensor of GENMSG2 is name(x) and send(engineer,GENMSG2))) ); scan = 20 seconds; ave = 0, currency = indefinite; dev = 0, currency = indefinite; run_ave = 0, currency = indefinite; run_dev = 0, currency = indefinite; $ define_activity startup if status of startup is false then status of startup is true and send(engineer,START) and t of AST is t and schedule(2 minutes,after_startup); scan = 10 seconds; status = false, currency = infinite; $ "*** Messages ***" $ define_message AST text = "It has been ",t - t of AST," seconds since startup."; t = no_formula,currency = infinite; $ define_message FSTATS text = obj of FSTATS, " mean = ",decimal(mean of FSTATS, precision = 1), " range = ",decimal(range of FSTATS, precision = 1), " std = ",decimal(std of FSTATS, precision = 1); obj = no_formula,name_print; mean = no_formula; range = no_formula; std = no_formula; $ define_message GENMSG1 text = "ave = ",run_ave of general, " dev = ",run_dev of general; $ define_message GENMSG2 text = sensor of GENMSG2," is the most over its medium"; sensor = no_formula, currency = infinite, name_print; $ define_message HIGH text = arg1 of HIGH," high limit at ",arg2 of HIGH, " last ", arg3 of HIGH; arg1 = no_formula, currency = infinite, name_print; arg2 = no_formula, currency = infinite; arg3 = no_formula, currency = infinite; $ define_message LOW text = arg1 of LOW," low limit at ",arg2 of LOW, " last ", arg3 of LOW; arg1 = no_formula, currency = infinite, name_print; arg2 = no_formula, currency = infinite; arg3 = no_formula, currency = infinite; $ define_message MED text = arg1 of MED," medium limit at ",arg2 of MED, " last ", arg3 of MED; arg1 = no_formula, currency = infinite, name_print; arg2 = no_formula, currency = infinite; arg3 = no_formula, currency = infinite; $ define_message MON text = "Now monitoring status of ", arg1 of MON; arg1 = no_formula, currency = infinite, name_print; $ define_message START text = "initial startup at ",t; $ "*** Destinations ***" $ define_message_destination engineer system = engineer_x; control = ""; $ "*** POWER/LINKS ***" $ define_PowerLink engineer_x PowerBase_interface = mbox; protocol = messages; request_stream = default; response_stream = default; spawn_command = "@MPOWER_COM:MESSAGE_MANAGER_SUB"; spawn_command_arguments = "-k"; win32_spawn_command = "optmsg"; win32_spawn_command_arguments = "."; data_supplier_terminal = false; data_supplier_keyboard = true; optional_data = false; $ define_PowerLink simulator PowerBase_interface = mbox; protocol = simulate; request_stream = default; response_stream = default; spawn_command = "@MPOWER_COM:SIMULATOR_SUB"; spawn_command_arguments = ""; win32_spawn_command = "simulator"; win32_spawn_command_arguments = ""; data_supplier_terminal = false; data_supplier_keyboard = true; optional_data = false; $ "*** Outputs ***" $ define_output dF1dt simulation_initial_value = 1; system = false; route = false; $ define_output dF2dt simulation_initial_value = 1; system = false; route = false; $ "*** Application Setups ***" $ do_not_edit (define_application_setup application_internal (= basename "osc") (= file_data_type binary)) $ define_application_setup compiler default_external_system = simulator; generic_rule_verbose = false; default_history_size = 400; parsing_implied_underbar = false; note_output_files = true; $ define_application_setup cross_reference sort_alphabetic = true; format_in_columns = false; space_between_objects = false; indicate_object_type = false; line_length = 80; $ define_application_setup editing_options keep_up_object_selector = true; show_parse = false; merge_duplicates = ignore; $ define_application_setup general_comments $ define_application_setup hlp_options include_source = true; include_rules = true; include_messages = true; include_sensors = true; include_variables = true; $ define_application_setup run data_supplier_terminal = false; data_supplier_keyboard = true; PowerBase_terminal = false; PowerBase_keyboard = true; PowerBase_command = "@MPOWER_COM:POWERBASE_SUB"; PowerBase_error_messages = warning; mpower_object_limit = 100; mpower_average_object_size = 4000; mpower_str_table_dim = false; mpower_database_buffer_size = false; $ "*** Devices ***" $ "*** Generics ***" $ define_generic fstats constraint = i isa input, i has range, i has mean, i has std; activity = sequence( obj of FSTATS is name(i), range of FSTATS is range of i, mean of FSTATS is mean of i, std of FSTATS is std of i, send(engineer,FSTATS)); scan = 30 seconds; $ define_generic hasmedium constraint = X isa input, X has medium_limit; population = hasmedium; $ define_generic low_checks /* This shows a two-dimensional match */ constraint = x isa input, x has low_limit, y isa output, cp of x = y; activity = if x < low_limit of x and setting of x is not going_up_fast then y is 1 and arg3 of LOW is dt(setting of x) and setting of x is going_up_fast and arg2 of LOW is x and arg1 of LOW is name(x) and send(engineer,LOW); scan = 2 seconds; $ define_generic overmedium form = overmedium(x); translation = if (x > medium_limit of x) then x - medium_limit of x else 0; $ define_generic startup_monitor constraint = x isa input, x has monitoring_status; activity = if monitoring_status of x is false then monitoring_status of x is true and arg1 of MON is name(x) and send(engineer,MON); scan = 1 minute; $ define_generic upper_checks /* This uses the bindings construct to get the same result as the two-dimensional match used in low_checks, but it is more straightforward and a lot more efficient for big applications */ constraint = x isa input , x has hi_limit; bindings = (y = cp of x); activity = if x > hi_limit of x and setting of x is not going_down then y is -1 and arg3 of HIGH is dt(setting of x) and setting of x is going_down and arg2 of HIGH is x and arg1 of HIGH is name(x) and send(engineer,HIGH) else if x > medium_limit of x and setting of x is not going_up_slow and setting of x is not going_down then y is 0.5 and arg3 of MED is dt(setting of x) and setting of x is going_up_slow and arg2 of MED is x and arg1 of MED is name(x) and send(engineer,MED); scan = 2 seconds; $ define_generic words symbols = no,yes,going_down,going_up_slow,going_up_fast; $