StateMachine::StateMachine(
    const dictionary &dict,
    const fvMesh &mesh
):
    driver_(
        CommonValueExpressionDriver::New(
            dict,
            mesh
        )
    ),
    mesh_(mesh),
    names_(
        dict.lookup("states")
    ),
    machineName_(
        dict.lookup("machineName")
    ),
    initialState_(
        stateCode(
            word(dict.lookup("initialState"))
        )
    ),
    state_(initialState_),
    lastStateChange_(
        mesh.time().value()
    ),
    stepsSinceChange_(0),
    changedTo_(
        names_.size(),
        0
    )
{
    driver_->createWriterAndRead(
        "StateMachine_"+machineName_+"_"+dict.name().name()
    );

    List<dictionary> data(
        dict.lookup("transitions")
    );
    transitions_.resize(data.size());
    forAll(data,i) {
        transitions_.set(
            i,
            new StateTransition(
                *this,
                dictionary(
                    dict,
                    data[i]
                )
            )
        );
    }
Exemplo n.º 2
0
// isStateCode: returns true if code matches the State/Province Code field
bool Record::isStateCode(const int code) const
{
   return stateCode() == code;
}