- Main Page
- Namespaces
- Classes
- Files
- Related Pages

# /Users/fpy/titan-1-5-MBARI/Mers/Models/CCA/HardCodedModels.cpp

    00001
    00002 //
    00003 // Copyright (c) 2004           Model-based Embedded and Robotic Systems Group
    00004 // All Rights Reserved          Massachusetts Institute of Technology
    00005 //
    00006 // This software is provided as is. Model-based Embedded and Robotic Systems
    00007 // (MERS) group does not assume any responsibility.
    00008 //
    00009 // Organization:        Model-based Embedded and Robotic Systems Group
    00010 //                                      Massachusetts Institute of Technology
    00011 //
    00013
    00014 #include "HardCodedModels.h"
    00015 #include "CCAValues.h"
    00016
    00018
    00019 using namespace Mers::Models::CCA;
    00020
    00022
    00023 void Mers::Models::CCA::createValveDriverModel(CCAModel & my_model)
    00024 {
    00025         CCAValues               temp_values(true);
    00026         //      const CCAAssignments * temp_assignments_p;
    00027         //      rpCCAutomata::rpResultType result;
    00028         CCAClause               temp_c_clause(CCAClause::CONJUNCTIVE);
    00029         CCAClause               temp_d_clause(CCAClause::DISJUNCTIVE);
    00030         CCASentence     temp_constraint(CCASentence::CNF);
    00031
    00032         // Domain
    00033         temp_values.insert_value(CCAValue("turn on"));
    00034         temp_values.insert_value(CCAValue("turn off"));
    00035         temp_values.insert_value(CCAValue("reset"));
    00036         temp_values.insert_value(CCAValue("close valve"));
    00037         temp_values.insert_value(CCAValue("open valve"));
    00038         my_model.addDomain("Driver-CMD", temp_values);
    00039         temp_values.makeEmpty();
    00040
    00041         // Domain
    00042         temp_values.insert_value(CCAValue("on"));
    00043         temp_values.insert_value(CCAValue("off"));
    00044         temp_values.insert_value(CCAValue("resettable"));
    00045         temp_values.insert_value(CCAValue("failed"));
    00046         my_model.addDomain("Driver", temp_values);
    00047         temp_values.makeEmpty();
    00048
    00049
    00050         // Domain
    00051         temp_values.insert_value(CCAValue("open"));
    00052         temp_values.insert_value(CCAValue("closed"));
    00053         temp_values.insert_value(CCAValue("stuck-open"));
    00054         temp_values.insert_value(CCAValue("stuck-closed"));
    00055         my_model.addDomain("Valve", temp_values);
    00056         temp_values.makeEmpty();
    00057
    00058         temp_values.makeEmpty();
    00059         temp_values.insert_value(CCAValue("flowing"));
    00060         temp_values.insert_value(CCAValue("not-flowing"));
    00061         my_model.addDomain("Flow", temp_values);
    00062
    00063         // Variables
    00064         my_model.insert_variable("Command.CMD1", CCAVariable::Control, "Driver-CMD");
    00065         my_model.insert_variable("Driver.D1", CCAVariable::State, "Driver", 1);
    00066         my_model.insert_variable("Valve.V1", CCAVariable::State, "Valve", 0);
    00067         my_model.insert_variable("Flow.V1", CCAVariable::Dependent, "Flow");
    00068
    00069         // State Constraints
    00070         temp_c_clause.makeEmpty();
    00071         temp_constraint.makeEmpty();
    00072         CCAAssignment   temp_assignment = my_model.get_assignment("Flow.V1", "flowing", CCAAssignment::Positive);
    00073         temp_c_clause.insert_assignment(temp_assignment);
    00074         temp_constraint.insert_clause(temp_c_clause);
    00075         my_model.set_state_constraint("Valve.V1", "open", temp_constraint);
    00076
    00077         my_model.set_state_constraint("Valve.V1", "stuck-open", temp_constraint);
    00078
    00079         temp_c_clause.makeEmpty();
    00080         temp_constraint.makeEmpty();
    00081         temp_assignment = my_model.get_assignment("Flow.V1", "not-flowing", CCAAssignment::Positive);
    00082         temp_c_clause.insert_assignment(temp_assignment);
    00083         temp_constraint.insert_clause(temp_c_clause);
    00084         my_model.set_state_constraint("Valve.V1", "closed", temp_constraint);
    00085
    00086         my_model.set_state_constraint("Valve.V1", "stuck-closed", temp_constraint);
    00087
    00088         // Transitions
    00089         temp_assignment = my_model.get_assignment("Command.CMD1", "turn on", CCAAssignment::Positive);
    00090         temp_c_clause.insert_assignment(temp_assignment);
    00091         my_model.insert_transition("Driver.D1", "off", "on", temp_c_clause, 1);
    00092         temp_c_clause.makeEmpty();
    00093         temp_assignment = my_model.get_assignment("Command.CMD1", "turn off", CCAAssignment::Positive);
    00094         temp_c_clause.insert_assignment(temp_assignment);
    00095         my_model.insert_transition("Driver.D1", "on", "off", temp_c_clause, 1);
    00096         temp_c_clause.makeEmpty();
    00097         temp_assignment = my_model.get_assignment("Command.CMD1", "reset", CCAAssignment::Positive);
    00098         temp_c_clause.insert_assignment(temp_assignment);
    00099         my_model.insert_transition("Driver.D1", "resettable", "on", temp_c_clause, 1);
    00100         temp_c_clause.makeEmpty();
    00101         my_model.insert_transition("Driver.D1", "on", "resettable", temp_c_clause, 1);
    00102         my_model.insert_transition("Driver.D1", "on", "failed", temp_c_clause, 1);
    00103         my_model.insert_transition("Driver.D1", "off", "failed", temp_c_clause, 1);
    00104         my_model.insert_transition("Driver.D1", "resettable", "failed", temp_c_clause, 1);
    00105
    00106         temp_assignment = my_model.get_assignment("Command.CMD1", "close valve", CCAAssignment::Positive);
    00107         temp_c_clause.insert_assignment(temp_assignment);
    00108         temp_assignment = my_model.get_assignment("Driver.D1", "on", CCAAssignment::Positive);
    00109         temp_c_clause.insert_assignment(temp_assignment);
    00110         my_model.insert_transition("Valve.V1", "open", "closed", temp_c_clause, 1);
    00111         temp_c_clause.makeEmpty();
    00112         temp_assignment = my_model.get_assignment("Command.CMD1", "open valve", CCAAssignment::Positive);
    00113         temp_c_clause.insert_assignment(temp_assignment);
    00114         temp_assignment = my_model.get_assignment("Driver.D1", "on", CCAAssignment::Positive);
    00115         temp_c_clause.insert_assignment(temp_assignment);
    00116         my_model.insert_transition("Valve.V1", "closed", "open", temp_c_clause, 1);
    00117         temp_c_clause.makeEmpty();
    00118         my_model.insert_transition("Valve.V1", "open", "stuck-open", temp_c_clause, 1);
    00119         my_model.insert_transition("Valve.V1", "closed", "stuck-closed", temp_c_clause, 1);
    00120
    00121         // Set state type
    00122         my_model.set_state_type("Driver.D1", "on", CCAState::NOMINAL);
    00123         my_model.set_state_type("Driver.D1", "off", CCAState::NOMINAL);
    00124         my_model.set_state_type("Driver.D1", "resettable", CCAState::FAILURE);
    00125         my_model.set_state_type("Driver.D1", "failed", CCAState::FAILURE);
    00126
    00127         my_model.set_state_type("Valve.V1", "open", CCAState::NOMINAL);
    00128         my_model.set_state_type("Valve.V1", "closed", CCAState::NOMINAL);
    00129         my_model.set_state_type("Valve.V1", "stuck-open", CCAState::FAILURE);
    00130         my_model.set_state_type("Valve.V1", "stuck-closed", CCAState::FAILURE);
    00131 }
    00132
    00134
    00135 void Mers::Models::CCA::createSimpleTechsat21Model(CCAModel & my_model)
    00136 {
    00137         CCAValues               temp_values(true);
    00138         //      const assignments * temp_assignments_p;
    00139         //      rpCCAutomata::rpResultType result;
    00140         CCAClause               temp_c_clause(CCAClause::CONJUNCTIVE);
    00141         CCAClause               temp_d_clause(CCAClause::DISJUNCTIVE);
    00142         CCASentence     temp_constraint(CCASentence::CNF);
    00143
    00144         // Domain
    00145         temp_values.makeEmpty();
    00146         temp_values.insert_value(CCAValue("low"));
    00147         temp_values.insert_value(CCAValue("nominal"));
    00148         temp_values.insert_value(CCAValue("high"));
    00149         my_model.addDomain("pressure-value", temp_values);
    00150
    00151         // Domain
    00152         temp_values.makeEmpty();
    00153         temp_values.insert_value(CCAValue("open"));
    00154         temp_values.insert_value(CCAValue("closed"));
    00155         my_model.addDomain("valve-position", temp_values);
    00156
    00157         // Domain
    00158         temp_values.makeEmpty();
    00159         temp_values.insert_value(CCAValue("on"));
    00160         temp_values.insert_value(CCAValue("off"));
    00161         temp_values.insert_value(CCAValue("no-command"));
    00162         my_model.addDomain("power-command", temp_values);
    00163
    00164         // Domain
    00165         temp_values.makeEmpty();
    00166         temp_values.insert_value(CCAValue("open"));
    00167         temp_values.insert_value(CCAValue("close"));
    00168         temp_values.insert_value(CCAValue("no-command"));
    00169         my_model.addDomain("valve-command", temp_values);
    00170
    00171         // Domain
    00172         temp_values.makeEmpty();
    00173         temp_values.insert_value(CCAValue("true"));
    00174         temp_values.insert_value(CCAValue("false"));
    00175         my_model.addDomain("true-false-value", temp_values);
    00176
    00177         // Domain
    00178         temp_values.makeEmpty();
    00179         temp_values.insert_value(CCAValue("unknown"));
    00180         temp_values.insert_value(CCAValue("on"));
    00181         temp_values.insert_value(CCAValue("off"));
    00182         my_model.addDomain("simple-dciu-mode", temp_values);
    00183
    00184         // Domain
    00185         temp_values.makeEmpty();
    00186         temp_values.insert_value(CCAValue("unknown"));
    00187         temp_values.insert_value(CCAValue("stuck-closed"));
    00188         temp_values.insert_value(CCAValue("stuck-open"));
    00189         temp_values.insert_value(CCAValue("open"));
    00190         temp_values.insert_value(CCAValue("closed"));
    00191         my_model.addDomain("latch-valve-mode", temp_values);
    00192
    00193         // Domain
    00194         temp_values.makeEmpty();
    00195         temp_values.insert_value(CCAValue("unknown"));
    00196         temp_values.insert_value(CCAValue("no-power-on"));
    00197         temp_values.insert_value(CCAValue("on"));
    00198         temp_values.insert_value(CCAValue("off"));
    00199         my_model.addDomain("hall-thruster-mode", temp_values);
    00200
    00201         // Domain
    00202         temp_values.makeEmpty();
    00203         temp_values.insert_value(CCAValue("on"));
    00204         temp_values.insert_value(CCAValue("off"));
    00205         my_model.addDomain("power-state", temp_values);
    00206
    00207         // Variables
    00208         //latch2
    00209         my_model.insert_variable("latch2.mode", CCAVariable::State,
    00210                                                                                                          "latch-valve-mode", 0);
    00211         my_model.insert_variable("latch2.pressure-out", CCAVariable::Dependent,
    00212                                                                                                          "pressure-value");
    00213         my_model.insert_variable("latch2.valve-position", CCAVariable::Dependent,
    00214                                                                                                          "valve-position");
    00215         my_model.insert_variable("latch2.pressure-in", CCAVariable::Dependent,
    00216                                                                                                          "pressure-value");
    00217         my_model.insert_variable("latch2.command-in", CCAVariable::Dependent,
    00218                                                                                                          "valve-command");
    00219
    00220         //ts-propulsion
    00221         my_model.insert_variable("ts-propulsion.thrust-out", CCAVariable::Dependent,
    00222                                                                                                          "true-false-value");
    00223         my_model.insert_variable("ts-propulsion.pressure2-out", CCAVariable::Dependent,
    00224                                                                                                          "pressure-value");
    00225         my_model.insert_variable("ts-propulsion.pressure1-out", CCAVariable::Dependent,
    00226                                                                                                          "pressure-value");
    00227         my_model.insert_variable("ts-propulsion.thruster-command-in",
    00228                                                                                                          CCAVariable::Control, "power-command");
    00229         my_model.insert_variable("ts-propulsion.latch2-command-in",
    00230                                                                                                          CCAVariable::Control, "valve-command");
    00231         my_model.insert_variable("ts-propulsion.latch1-command-in",
    00232                                                                                                          CCAVariable::Control, "valve-command");
    00233         my_model.insert_variable("ts-propulsion.dciu-command-in",
    00234                                                                                                          CCAVariable::Control, "power-command");
    00235
    00236         //thruster
    00237         my_model.insert_variable("thruster.mode", CCAVariable::State,
    00238                                                                                                          "hall-thruster-mode", 2);
    00239         my_model.insert_variable("thruster.thrust", CCAVariable::Dependent,
    00240                                                                                                          "true-false-mode");
    00241         my_model.insert_variable("thruster.thruster-state", CCAVariable::Dependent,
    00242                                                                                                          "power-state");
    00243         my_model.insert_variable("thruster.pressure-in", CCAVariable::Dependent,
    00244                                                                                                          "pressure-value");
    00245         my_model.insert_variable("thruster.power-in", CCAVariable::Dependent,
    00246                                                                                                          "true-false-value");
    00247         my_model.insert_variable("thruster.command-in", CCAVariable::Dependent,
    00248                                                                                                          "power-command");
    00249
    00250         //dciu
    00251         my_model.insert_variable("dciu.mode", CCAVariable::State, "simple-dciu-mode", 3);
    00252         my_model.insert_variable("dciu.thruster-command-out", CCAVariable::Dependent,
    00253                                                                                                          "power-command");
    00254         my_model.insert_variable("dciu.l2-command-out", CCAVariable::Dependent,
    00255                                                                                                          "valve-command");
    00256         my_model.insert_variable("dciu.l1-command-out", CCAVariable::Dependent,
    00257                                                                                                          "valve-command");
    00258         my_model.insert_variable("dciu.power-state", CCAVariable::Dependent,
    00259                                                                                                          "power-state");
    00260         my_model.insert_variable("dciu.thruster-command-in", CCAVariable::Dependent,
    00261                                                                                                          "power-command");
    00262         my_model.insert_variable("dciu.l2-command-in", CCAVariable::Dependent,
    00263                                                                                                          "valve-command");
    00264         my_model.insert_variable("dciu.l1-command-in", CCAVariable::Dependent,
    00265                                                                                                          "valve-command");
    00266         my_model.insert_variable("dciu.command-in", CCAVariable::Dependent,
    00267                                                                                                          "power-command");
    00268
    00269         //latch1
    00270         my_model.insert_variable("latch1.mode", CCAVariable::State,
    00271                                                                                                          "latch-valve-mode", 1);
    00272         my_model.insert_variable("latch1.pressure-out", CCAVariable::Dependent,
    00273                                                                                                          "pressure-value");
    00274         my_model.insert_variable("latch1.valve-position", CCAVariable::Dependent,
    00275                                                                                                          "valve-position");
    00276         my_model.insert_variable("latch1.pressure-in", CCAVariable::Dependent,
    00277                                                                                                          "pressure-value");
    00278         my_model.insert_variable("latch1.command-in", CCAVariable::Dependent,
    00279                                                                                                          "valve-command");
    00280
    00281         // Transitions
    00282         temp_c_clause.makeEmpty();
    00283         CCAAssignment   temp_assignment = my_model.get_assignment("ts-propulsion.latch2-command-in",
    00284                                                                                                                                                                                                                                         "open", CCAAssignment::Positive);
    00285         temp_c_clause.insert_assignment(temp_assignment);
    00286         temp_assignment = my_model.get_assignment("dciu.mode", "on", CCAAssignment::Positive);
    00287         temp_c_clause.insert_assignment(temp_assignment);
    00288         my_model.insert_transition("latch2.mode", "closed", "open",
    00289                                                                                                                  temp_c_clause, 1);
    00290
    00291         temp_c_clause.makeEmpty();
    00292         temp_assignment = my_model.get_assignment("ts-propulsion.latch2-command-in",
    00293                                                                                                                                                                                 "close", CCAAssignment::Positive);
    00294         temp_c_clause.insert_assignment(temp_assignment);
    00295         temp_assignment = my_model.get_assignment("dciu.mode", "on", CCAAssignment::Positive);
    00296         temp_c_clause.insert_assignment(temp_assignment);
    00297         my_model.insert_transition("latch2.mode", "open", "closed",
    00298                                                                                                                  temp_c_clause, 1);
    00299
    00300         temp_c_clause.makeEmpty();
    00301         temp_assignment = my_model.get_assignment("ts-propulsion.latch1-command-in",
    00302                                                                                                                                                                                 "open", CCAAssignment::Positive);
    00303         temp_c_clause.insert_assignment(temp_assignment);
    00304         temp_assignment = my_model.get_assignment("dciu.mode", "on", CCAAssignment::Positive);
    00305         temp_c_clause.insert_assignment(temp_assignment);
    00306         my_model.insert_transition("latch1.mode", "closed", "open",
    00307                                                                                                                  temp_c_clause, 1);
    00308
    00309         temp_c_clause.makeEmpty();
    00310         temp_assignment = my_model.get_assignment("ts-propulsion.latch1-command-in",
    00311                                                                                                                                                                                 "close", CCAAssignment::Positive);
    00312         temp_c_clause.insert_assignment(temp_assignment);
    00313         temp_assignment = my_model.get_assignment("dciu.mode", "on", CCAAssignment::Positive);
    00314         temp_c_clause.insert_assignment(temp_assignment);
    00315         my_model.insert_transition("latch1.mode", "open", "closed",
    00316                                                                                                                  temp_c_clause, 1);
    00317
    00318         temp_c_clause.makeEmpty();
    00319         temp_assignment =
    00320                 my_model.get_assignment("ts-propulsion.thruster-command-in", "on", CCAAssignment::Positive);
    00321         temp_c_clause.insert_assignment(temp_assignment);
    00322         temp_assignment = my_model.get_assignment("dciu.mode", "on", CCAAssignment::Positive);
    00323         temp_c_clause.insert_assignment(temp_assignment);
    00324         my_model.insert_transition("thruster.mode", "off", "on", temp_c_clause, 1);
    00325
    00326         temp_c_clause.makeEmpty();
    00327         temp_assignment =
    00328                 my_model.get_assignment("ts-propulsion.thruster-command-in", "off", CCAAssignment::Positive);
    00329         temp_c_clause.insert_assignment(temp_assignment);
    00330         temp_assignment = my_model.get_assignment("dciu.mode", "on", CCAAssignment::Positive);
    00331         temp_c_clause.insert_assignment(temp_assignment);
    00332         my_model.insert_transition("thruster.mode", "on", "off", temp_c_clause, 1);
    00333
    00334         temp_c_clause.makeEmpty();
    00335         temp_assignment = my_model.get_assignment("ts-propulsion.dciu-command-in",
    00336                                                                                                                                                                                 "on", CCAAssignment::Positive);
    00337         temp_c_clause.insert_assignment(temp_assignment);
    00338         my_model.insert_transition("dciu.mode", "off", "on", temp_c_clause, 1);
    00339
    00340         temp_c_clause.makeEmpty();
    00341         temp_assignment = my_model.get_assignment("ts-propulsion.dciu-command-in",
    00342                                                                                                                                                                                 "off", CCAAssignment::Positive);
    00343         temp_c_clause.insert_assignment(temp_assignment);
    00344         my_model.insert_transition("dciu.mode", "on", "off", temp_c_clause, 1);
    00345
    00346         // Set state type
    00347         my_model.set_state_type("latch2.mode", "closed", CCAState::NOMINAL);
    00348         my_model.set_state_type("latch2.mode", "open", CCAState::NOMINAL);
    00349         my_model.set_state_type("latch2.mode", "stuck-closed", CCAState::FAILURE);
    00350         my_model.set_state_type("latch2.mode", "stuck-open", CCAState::FAILURE);
    00351         my_model.set_state_type("latch2.mode", "unknown", CCAState::FAILURE);
    00352
    00353         my_model.set_state_type("latch1.mode", "closed", CCAState::NOMINAL);
    00354         my_model.set_state_type("latch1.mode", "open", CCAState::NOMINAL);
    00355         my_model.set_state_type("latch1.mode", "stuck-closed", CCAState::FAILURE);
    00356         my_model.set_state_type("latch1.mode", "stuck-open", CCAState::FAILURE);
    00357         my_model.set_state_type("latch1.mode", "unknown", CCAState::FAILURE);
    00358
    00359         my_model.set_state_type("thruster.mode", "off", CCAState::NOMINAL);
    00360         my_model.set_state_type("thruster.mode", "on", CCAState::NOMINAL);
    00361         my_model.set_state_type("thruster.mode", "no-power-on", CCAState::FAILURE);
    00362         my_model.set_state_type("thruster.mode", "unknown", CCAState::FAILURE);
    00363
    00364         my_model.set_state_type("dciu.mode", "off", CCAState::NOMINAL);
    00365         my_model.set_state_type("dciu.mode", "on", CCAState::NOMINAL);
    00366         my_model.set_state_type("dciu.mode", "unknown", CCAState::FAILURE);
    00367 }
    00368
    00370