Gasp-o-matic design using pseudo code
 
  • The requirements specification is the same
  • No UML- language design diagrams are drawn or used expect state- transition diagrams
  • Architecture design is the same as to number of processors
  • Operating system used is the same used in rtos course
  • Only real change is that a message is not an integer but a data structure
  • This solution is not carefully checked, but gives a general idea
  • I prefer my own simple dynamic memory allocation for messages and alarms, it
    is not presented here. Simply, at pseudo code level it means calls as  ptr=get_block();before creation of a new alarm and a communication message. (Deleting same way free_block(ptr).)
    This pseudo code design is an example of so called functional design.
    There are pros and cons with it. Because eventually, whatever the design method is, all code is sequential, implementation is simple based on these pseudo codes. We can't show clearly capsulation of data and operations to objects, however, we have capsulated something in processes.

    Tasks are divided to processes using just common sense.
    Clearly monitoring processor runs monitor task and alarm task (because monitoring finds alarming situation), control processor runs control task and receiving new parameters task for control, and user interface processor runs user input (knobs) process and display handling process (updating numeric displays and display memory for alarm window). All processors run communication in and out processes to implement a protocol.

    Concurrence design produces the following set of processes (this is almost identical to original example):

    Processor 1
    processes: monitor, alarm, communication out, communication in

    Processor 2
    Processes: control, receive parameters, communication out, communication in

    Processor 3
    processes: user input, display, communication_out, communication_in



    Processor 1

    Monitor process

    loop for ever {
            message=receive( monitor_box,monitor_interval);  /* We are polling sensors, interrupting sensors are also possible- then solution is even simpler */
            loop  (for sensor in set O2- sensor, CO2- sensor, Pressure- sensor) {

    }
     

    Alarm process

    Every alarm type has it's state transition structure.
    State transition structure is input to run_sate_machine( );

    structure is :

    CURRENT_STATE
    TIME_TO_NEXT_TIMEOUT

    TABLE:
    STATE1:EVENT1:ACTION1( ):NEXT_STATE1:
    STATE2:EVENT2;ACTION2( ):NEXT_STATE2:
    STATE3:EVENT3:ACTION3( ):NEXT_STATE3:
    ...............

    One special case is, that the action must be to start a timer in a time which is sooner than the current setting.
     

    loop for ever {

     

    message=receive(alarm_box,timeout);
    If ( message is not timeout message)
           timeout=calaculate_new_value( ); /* The same box is used for timeout and other messages, if message is not timeout, we must start timer again, later, with correct value "the rest of time"  */

    case message_type  /* We act on different events affectin to alarms */

    }
     
     
     


    Processor 2
    Processes: control, receive parameter change, communication_out, communication_in

    Control process

    Parameters: I:E,tidal_volume,minute_volume,respiration_rate,inspiration_flow_rate

    loop for ever {

    /* We use receive to produce timeout */