示例#1
0
 def TurnON(self):
     """
     TurnON action from model.
     """
     if self.inRange('TurnON', 'controlInput'):
         r = self.__impl.turnONBehav(argument=self.actdict['TurnON']['controlInput']['tok_list'])
         r['status'] = ['SignalExample', 'TurnON', 'on']
         
         self.clear_tok('TurnON')
         self.parseResult(r)
         
         # Send ON signal to state machine Simple4.
         e = event.Event("OnSignal")
         e.data = r['TurnON.signalValue'][0]
         self._publish(e)
         # Wait for and receive signal from state machine Simple4.
         eventObj = self._receiveOneEvent()
         LOG.info("Got event of signal '%s' with data '%s'" % (eventObj.signal, eventObj.data))
         return True    
     else:
         insuff_pins = self.wrong_tok('TurnON')
         for pin in insuff_pins:
             LOG.debug('Incorrect token number on input %s of action %s:  %s'
                       % (pin, "TurnON", self.actdict['TurnON'][pin]['tok_list']))
         return False
示例#2
0
def sendToCalc(sm, expr):
    for char in expr+"=":
        if char == '+':
            waitState(sm, ["operand[12]"])
            qf.publish(event.Event("B_OP_PLUS"))
            waitState(sm, ["OpEntered", "Error"])
        elif char == '-':
            waitState(sm, ["operand[12]"])
            qf.publish(event.Event("B_OP_MINUS"))
            waitState(sm, ["OpEntered", "Error"])
        elif char == '*':
            waitState(sm, ["operand[12]"])
            qf.publish(event.Event("B_OP_TIMES"))
            waitState(sm, ["OpEntered", "Error"])
        elif char == '/':
            waitState(sm, ["operand[12]"])
            qf.publish(event.Event("B_OP_DIVIDE"))
            waitState(sm, ["OpEntered", "Error"])
        elif char == '.':
            qf.publish(event.Event("B_DOT"))
        elif char == '=':
            waitState(sm, ["operand2"])
            qf.publish(event.Event("B_EQUAL"))
            waitState(sm, ["Result", "Error"])
        elif char >= '0' and char <= '9':
            qf.publish(event.Event("B_%s" % char))
        else:
            print "ERR! Unrecognized character: '%s'" % char
示例#3
0
 def doTallyAgent(self, e):
     """
     Implementation Action method for doTallyAgent()
     """
     self._agentsActive += 1
     print "Active agents:", self._agentsActive
     # announce when agents active
     if self._agentsActive == self.MAX_AGENTS:
         framework.QF.getInstance().publish(event.Event("AllAgentsTallied"))
示例#4
0
 def Action(self):
     """
     Action action from model.
     """
     if self.inRange('Action', 'argument'): 
         r = self.__impl.actionBehav(argument=self.actdict['Action']['argument']['tok_list'])
         r['status'] = ['SignalExample', 'Action', 'on']
         
         self.clear_tok('Action')
         self.parseResult(r)
         self._publish(event.Event("OffSignal"))
         return True    
     else:
         insuff_pins = self.wrong_tok('Action')
         for pin in insuff_pins:
             LOG.debug('Incorrect token number on input %s of action %s:  %s'
                       % (pin, "Action", self.actdict['Action'][pin]['tok_list']))
         return False
 def S1(self):
     """
     State S1
     """
     machine = self.__machine_name
     state_name = "S1"
     if self.tEvt['sType'] == "init":
         return 0
     elif self.tEvt['sType'] == "entry":
         printf("%s %s %s", machine, state_name, "ENTRY")
         self.sendUpdate(state_name, "ENTRY")
         return 0
     elif self.tEvt['sType'] == "exit":
         printf("%s %s %s", machine, state_name, "EXIT")
         self.sendUpdate(state_name, "EXIT")
         return 0
     elif self.tEvt['sType'] == "Ev1":
         printf("%s %s", state_name, self.tEvt['sType'])
         self._publish(event.Event("Ev2"))
         self.stateTran(self.S2)
         return 0
     return self.tEvt['sType']
示例#6
0
"""
# Python imports here
import sys
import logging

# QF imports here
from qf import miros
from qf import active
from qf import event
from qf import time_event
from qf import framework

# Module globals initialized here
LOGGER = logging.getLogger('SequencerLogger')
# Bail event for orthogonal region or submachine
BAIL_EVENT = event.Event("#BAIL#")


def printf(format, *args):
    #sys.stdout.write(format % args)
    LOGGER.info(format % args)


class SequencerActive(active.Active):
    """
    Sequencer state machine active object.
    """
    def __init__(self, impl_object=None, window_name="sequencer", active_obj=None, instance_name=None, is_substate=False):
        """
        Constructor
        """
"""
# Python imports here
import sys
import logging

# QF imports here
from qf import miros
from qf import active
from qf import event
from qf import time_event
from qf import framework

# Module globals initialized here
LOGGER = logging.getLogger('SubState2Logger')
#- bail-region event
BAIL_REGION_EVENT = event.Event("#BAIL#")


def printf(format, *args):
    #sys.stdout.write(format % args)
    LOGGER.info(format % args)


class SubState2Active(active.Active):
    """
    SubState2 state machine active object.
    """
    def __init__(self, impl_object=None, window_name="substate2"):
        """
        Constructor
        """