Beispiel #1
0
        it("XX should handle StateMachine derived from ProgramStateMachine",function() {

            var programStateMachine = addressSpace.findObjectType("ProgramStateMachineType");

            var psm = programStateMachine.instantiate({ browseName: "MyStateMachine#2" });

            var psmw = new UAStateMachine(psm);

            psmw.getStates().map(getBrowseName).should.eql(['Ready', 'Running', 'Suspended', 'Halted']);


        });
Beispiel #2
0
        it("XX should handle StateMachine derived from ProgramStateMachine",function() {

            var myProgramStateMachine = addressSpace.addObjectType({
                browseName: "MyProgramStateMachine",
                subtypeOf: "ProgramStateMachineType"
            });

            var psm = myProgramStateMachine.instantiate({ browseName: "MyStateMachine#2" });
            var psmw = new UAStateMachine(psm);

            psmw.getStates().map(getBrowseName).should.eql(['Ready', 'Running', 'Suspended', 'Halted']);

            psmw.getTransitions().map(getBrowseName).should.eql([
                "HaltedToReady",
                "ReadyToRunning",
                "RunningToHalted",
                "RunningToReady",
                "RunningToSuspended",
                "SuspendedToRunning",
                "SuspendedToHalted",
                "SuspendedToReady",
                "ReadyToHalted"
            ]);
        });
Beispiel #3
0
exports.makeBoiler = function (addressSpace, options) {

    //xx assert( addressSpace instanceof AddressSpace);
    assert(options);
    var boilerType = addressSpace.findObjectType("BoilerType");

    if (!boilerType) {
        boilerType = exports.createBoilerType(addressSpace);
    }
    // now instantiate boiler
    var boiler1 = boilerType.instantiate({
        browseName: options.browseName,
        organizedBy: addressSpace.rootFolder.objects
    });


    var boilerStateMachine = new UAStateMachine(boiler1.simulation);

    var haltedState = boilerStateMachine.getStateByName("Halted");
    assert(haltedState.browseName.toString() === "Halted");

    var readyState = boilerStateMachine.getStateByName("Ready");
    assert(readyState.browseName.toString() === "Ready");

    var runningState = boilerStateMachine.getStateByName("Running");
    assert(runningState.browseName.toString() === "Running");


    // when state is "Halted" , the Halt method is not executable
    boilerStateMachine.setState(haltedState);
    boilerStateMachine.currentStateNode.browseName.toString().should.eql("Halted");

    boilerStateMachine.node.halt.getExecutableFlag().should.eql(false);

    // when state is "Reset" , the Halt method is  executable
    boilerStateMachine.setState(readyState);
    boilerStateMachine.node.halt.getExecutableFlag().should.eql(true);

    return boiler1;
};
        it("should handle a FiniteStateMachine Type defined in a nodeset.xml file",function(){
            var exclusiveLimitStateMachineType = addressSpace.findObjectType("ExclusiveLimitStateMachineType");
            exclusiveLimitStateMachineType.browseName.toString().should.eql("ExclusiveLimitStateMachineType");

            // instantiate a state machine

            var myStateMachine = exclusiveLimitStateMachineType.instantiate({
                browseName: "MyStateMachine"
            });
            console.log(myStateMachine.toString());


            var stateMachine = new UAStateMachine(myStateMachine);

            // get the states
            var a = stateMachine.getStates().map(function(e) {

                var stateNumber = e.stateNumber.readValue().value.value;
                return e.browseName.toString() + ( (stateNumber !== null )? (" ( " + stateNumber + " )") : "" );
            });
            console.log("states      : ",a.join(" "));

            // get the transitions
            var t = stateMachine.getTransitions().map(function(e) {
                var transitionNumber = e.transitionNumber.readValue().value.value;
                return e.browseName.toString() + ( (transitionNumber !== null )? (" ( " + transitionNumber + " )") : "" );

            });
            console.log("transitions : ",t.join(" "));


            // set state and raise event
            stateMachine.setState(stateMachine.initialState);

            console.log(stateMachine.node.currentState.readValue().toString());
            stateMachine.node.currentState.readValue().statusCode.should.eql(StatusCodes.BadStateNotActive);

            stateMachine.setState(stateMachine.getStates()[0]);
            stateMachine.setState(stateMachine.getStates()[1]);
            stateMachine.setState(stateMachine.getStates()[2]);
            stateMachine.setState(stateMachine.getStates()[3]);


            var lowlowState = stateMachine.getStateByName("LowLow");
            lowlowState.browseName.toString().should.eql("LowLow");

            var lowState = stateMachine.getStateByName("Low");
            lowState.browseName.toString().should.eql("Low");

            var lowToLowLowTransition = stateMachine.findTransitionNode(lowState,lowlowState);

            lowToLowLowTransition.browseName.toString().should.eql("LowToLowLow");

        });
Beispiel #5
0
 method.bindMethod(function (inputArguments, context, callback) {
     var stateMachineW = new UAStateMachine(this.parent);
     console.log("Hello World ! I will " + methodName + " the process");
     stateMachineW.setState(toState);
     callback();
 });
Beispiel #6
0
function MygetExecutableFlag(toState) {
    assert(_.isString(toState));
    assert(this instanceof UAMethod);
    var stateMachineW = new UAStateMachine(this.parent);
    return stateMachineW.isValidTransition(toState);
}