Example #1
0
import M3Objects
import M3Types
import RTSTypes
import M3Predefined
import TimerInt as Timer
import M3TypeLib
import M3ProcLib
import CapsuleMap
from Statistics import M3incStat
M3TL=M3TypeLib.internaliseTypes(r'm3lib/ConjParentCapMod')
class ConjParent(RTSTypes.M3CapsuleRuntimeType):
 def __init__(self,level,runtimeName):
  self.runtimeName = runtimeName
  self.__level = level
  RTSTypes.M3CapsuleRuntimeType.__init__(self,level)
  self.c1=CapsuleMap.createCapsule(self.__level+1,'ConjC1',self.runtimeName+'.'+'c1')
  self.c2=CapsuleMap.createCapsule(self.__level+1,'ConjC2',self.runtimeName+'.'+'c2')
  self.__init_capsule_connect()
  self.__init_capsule_begin_end()
  self.__init_param_converters()
 def __init_capsule_connect(self):
  self.c2.connect(self,'p1.a','p1.a',self.c1,self.__level)
  self.c1.connect(self,'p1.b','p1.b',self.c2,self.__level)
 def __init_capsule_begin_end(self): pass # capsule BEGIN .. END
 def __init_param_converters(self):
  self.M3param_converters = {}
  self.M3port_converters = {}
def runcap():
 import Simulator
 Simulator.run(createCapsule(1,'top'))
def createCapsule(level,hName):
Example #2
0
import M3Objects
import M3Types
import M3Predefined
import M3TypeLib
import M3ProcLib

M3TL = M3TypeLib.internaliseTypes(r'm3lib/InputTypesInt')
Color = M3TL[14].finalTipe
Vector = M3TL[15].finalTipe
MyRecType = M3TL[16].finalTipe
Example #3
0
import M3Objects
import M3Types
import RTSTypes
import M3Predefined
import TimerInt as Timer
import M3TypeLib
import M3ProcLib
import CapsuleMap
from Statistics import M3incStat
M3TL = M3TypeLib.internaliseTypes(r'm3lib/C2CapMod')


class C2(RTSTypes.M3CapsuleRuntimeType):
    def c2act(self, ):
        M3incStat('RECEIVE', 'c2act')
        M3incStat('SEND', 'p2.messageFromC2')
        self.sendAfter(
            self,
            self.__level,
            'p2.messageFromC2',
            0,
        )

    def __init__(self, level, runtimeName):
        self.runtimeName = runtimeName
        self.__level = level
        RTSTypes.M3CapsuleRuntimeType.__init__(self, level)
        self.__init_capsule_connect()
        self.__init_capsule_begin_end()
        self.__init_param_converters()
Example #4
0
import M3Objects
import M3Types
import RTSTypes
import M3Predefined
import BankTypesInt as BankTypes
import BankTypesInt as BankTypes
import M3TypeLib
import M3ProcLib
import CapsuleMap
from Statistics import M3incStat
M3TL=M3TypeLib.internaliseTypes(r'm3lib/BankInterestCapMod')
class BankInterest(RTSTypes.M3CapsuleRuntimeType):
 def __init__(self,level,runtimeName):
  self.runtimeName = runtimeName
  self.__level = level
  RTSTypes.M3CapsuleRuntimeType.__init__(self,level)
  self.atm=CapsuleMap.createCapsule(self.__level+1,'ATM',self.runtimeName+'.'+'atm')
  self.account=CapsuleMap.createCapsule(self.__level+1,'Account',self.runtimeName+'.'+'account')
  self.interest=CapsuleMap.createCapsule(self.__level+1,'Interest',self.runtimeName+'.'+'interest')
  self.__init_capsule_connect()
  self.__init_capsule_begin_end()
  self.__init_param_converters()
 def __init_capsule_connect(self):
  self.connect(self,'counter.deposit','movement.deposit',self.account,self.__level)
  self.connect(self,'wall.inputPIN','keyboard.inputPIN',self.atm,self.__level)
  self.connect(self,'wall.inputSum','keyboard.inputSum',self.atm,self.__level)
  self.connect(self,'wall.insertCard','cardSlot.insertCard',self.atm,self.__level)
  self.atm.connect(self,'cardSlot.returnCard','wall.returnCard',self,self.__level)
  self.atm.connect(self,'cashSlot.emitCash','wall.emitCash',self,self.__level)
  self.connect(self,'admin.setInterestRate','admin.setInterestRate',self.interest,self.__level)
  self.interest.connect(self,'mail.statement','mail.statement',self,self.__level)
Example #5
0
import M3Objects
import M3Types
import M3Predefined
import M3TypeLib
import M3ProcLib
M3TL = M3TypeLib.internaliseTypes(r'm3lib/TrafficMod')
vk = M3TL[28].finalTipe
MetricWeight = M3Types.M3IntegerBase.makeScaledType([(u'tonne', 1000000),
                                                     (u'kg', 1000), (u'g', 1)])
vehicle = M3TL[30].finalTipe
myCar = vehicle.construct(vk.withVal('car'),
                          doors=M3Types.M3IntegerBase.createObject(3),
                          topSpeed=M3Types.M3IntegerBase.createObject(210))
myTruck = vehicle.construct(vk.withVal('truck'),
                            weight=M3Types.M3IntegerBase.createObject(5 *
                                                                      1000000))
myBike = vehicle.construct(vk.withVal('motorcycle'),
                           topSpeed=M3Types.M3IntegerBase.createObject(200))
Example #6
0
import M3Objects
import M3Types
import M3Predefined
import M3TypeLib
import M3ProcLib
M3TL = M3TypeLib.internaliseTypes(r'm3lib/BankTypesInt')
Card = M3TL[7].finalTipe
Example #7
0
import M3Objects
import M3Types
import RTSTypes
import M3Predefined
import M3TypeLib
import M3ProcLib
import CapsuleMap
from Statistics import M3incStat
M3TL = M3TypeLib.internaliseTypes(r'm3lib/AccountCapMod')


class Account(RTSTypes.M3CapsuleRuntimeType):
    def deposit(self, sum):
        M3incStat('RECEIVE', 'deposit')
        newtotal = M3Types.M3IntegerBase.createObject()
        newtotal.assign(self.money.plus(sum))
        self.money.assign(newtotal)

    def withdraw(self, sum):
        M3incStat('RECEIVE', 'withdraw')
        newtotal = M3Types.M3IntegerBase.createObject()
        newtotal.assign(self.money.minus(sum))
        self.money.assign(newtotal)

    def requestBalance(self, ):
        M3incStat('RECEIVE', 'requestBalance')
        M3incStat('SEND', 'information.balance')
        self.sendAfter(self,
                       self.__level,
                       'information.balance',
                       0,
Example #8
0
import M3Objects
import M3Types
import RTSTypes
import M3Predefined
import TimerInt as Timer
import M3TypeLib
import M3ProcLib
import CapsuleMap
from Statistics import M3incStat
M3TL = M3TypeLib.internaliseTypes(r'm3lib/ParTopCapMod')


class ParTop(RTSTypes.M3CapsuleRuntimeType):
    def __init__(self, level, runtimeName):
        self.runtimeName = runtimeName
        self.__level = level
        RTSTypes.M3CapsuleRuntimeType.__init__(self, level)
        self.par1 = CapsuleMap.createCapsule(self.__level + 1, 'SimplePar',
                                             self.runtimeName + '.' + 'par1')
        self.par2 = CapsuleMap.createCapsule(self.__level + 1, 'SimplePar2',
                                             self.runtimeName + '.' + 'par2')
        self.__init_capsule_connect()
        self.__init_capsule_begin_end()
        self.__init_param_converters()

    def __init_capsule_connect(self):
        self.connect(self, 'p1.getBusy', 'p1.getBusy', self.par1, self.__level)
        self.par1.connect(self, 'p1.delegate', 'p1.delegate', self.par2,
                          self.__level)
        self.par2.connect(self, 'p2.done', 'p1.done', self, self.__level)
Example #9
0
import M3Objects
import M3Types
import M3Predefined
import M3TypeLib
import M3ProcLib
M3TL=M3TypeLib.internaliseTypes(r'm3lib/ConjTypesInt')
aInbOut=None
aOutbIn=None
Example #10
0
import M3Objects
import M3Types
import RTSTypes
import M3Predefined
import TimerInt as Timer
import IOInt as IO
import M3TypeLib
import M3ProcLib
import CapsuleMap
from Statistics import M3incStat

M3TL = M3TypeLib.internaliseTypes(r'm3lib/pytimerCapMod')


class pytimer(RTSTypes.M3CapsuleRuntimeType):
    def timeact(self, ):
        M3incStat('RECEIVE', 'timeact')
        IO.Put(M3Types.M3Text.createObject("timeact\n"))
        self.i.assign(self.i.plus(M3Types.M3IntegerBase.createObject(1)))
        M3incStat('SEND', 'p1.foo')
        self.sendAfter(self, self.__level, 'p1.foo', 0, self.i)

    def __init__(self, level, runtimeName):
        self.runtimeName = runtimeName
        self.__level = level
        RTSTypes.M3CapsuleRuntimeType.__init__(self, level)
        self.myTimer = RTSTypes.M3TimerRuntimeType(
            delay=M3Types.M3IntegerBase.createObject(10),
            periodic=True,
            changeable=False).createObject()
        self.i = M3Types.M3IntegerBase.createObject(
Example #11
0
import M3Objects
import M3Types
import RTSTypes
import M3Predefined
import TimerInt as Timer
import M3TypeLib
import M3ProcLib
import CapsuleMap
from Statistics import M3incStat
M3TL = M3TypeLib.internaliseTypes(r'm3lib/SimplePar2CapMod')


class SimplePar2(RTSTypes.M3CapsuleRuntimeType):
    def delegate(self, ):
        M3incStat('RECEIVE', 'delegate')
        M3incStat('SEND', 'p2.done')
        self.sendAfter(
            self,
            self.__level,
            'p2.done',
            M3Types.M3IntegerBase.createObject(3 * 1000000000000).val,
        )
        self.M3LockProcessor(
            max(
                M3Types.M3IntegerBase.createObject(3 * 1000000000000).val,
                M3Types.M3IntegerBase.createObject(6 * 1000000000000).val))

    def __init__(self, level, runtimeName):
        self.runtimeName = runtimeName
        self.__level = level
        RTSTypes.M3CapsuleRuntimeType.__init__(self, level)
Example #12
0
import M3Objects
import M3Types
import RTSTypes
import M3Predefined
import InputTypesInt as InputTypes
import InputTypesInt as InputTypes
import IOInt as IO
import M3TypeLib
import M3ProcLib
import CapsuleMap
from Statistics import M3incStat
M3TL=M3TypeLib.internaliseTypes(r'm3lib/TestInputTypesCapMod')
class TestInputTypes(RTSTypes.M3CapsuleRuntimeType):
 def testInput(self, myRec):
  M3incStat('RECEIVE','testInput')
  IO.Put(M3Predefined.M3IMAGE(myRec))
 def __init__(self,level,runtimeName):
  self.runtimeName = runtimeName
  self.__level = level
  RTSTypes.M3CapsuleRuntimeType.__init__(self,level)
  self.__init_capsule_connect()
  self.__init_capsule_begin_end()
  self.__init_param_converters()
 def __init_capsule_connect(self): pass
 def __init_capsule_begin_end(self): pass # capsule BEGIN .. END
 def __init_param_converters(self):
  self.M3param_converters = {'p1.testInput' : (('myRec', InputTypes.MyRecType),),}
  self.M3port_converters = {'testInput': 'p1.testInput'}
def runcap():
 import Simulator
 Simulator.run(createCapsule(1,'top'))
Example #13
0
import M3Objects
import M3Types
import RTSTypes
import M3Predefined
from BankTypesInt import Card
from BankTypesInt import Card
import TimerInt as Timer
import M3TypeLib
import M3ProcLib
import CapsuleMap
from Statistics import M3incStat
M3TL = M3TypeLib.internaliseTypes(r'm3lib/ATMTimeoutCapMod')


class ATMTimeout(RTSTypes.M3CapsuleRuntimeType):
    def M3startCapsule(self):
        self.M3State = 'empty'
        self.M3TransitionFinishedHook(self.M3State)

    def insertCard(self, card):
        if self.M3State in ['empty']:
            m = getattr(self, 'M3insertCard__' + self.M3State)
            self.M3TransitionCallHook('insertCard', self.M3State)
            m(card)
        else:
            self.M3NoTransitionForMessageInState('insertCard', self.M3State)
        self.M3TransitionFinishedHook(self.M3State)

    def M3insertCard__empty(self, card):
        M3incStat('RECEIVE', 'insertCard')
        self.cardInfo.assign(card)
Example #14
0
import M3Objects
import M3Types
import M3Predefined
import M3TypeLib
import M3ProcLib
M3TL=M3TypeLib.internaliseTypes(r'/home/mark/m3/lib/m3lib/TimerInt')
Time=M3Types.M3IntegerBase.makeScaledType([('year', 31536000000000000000L), ('day', 86400000000000000L), ('hour', 3600000000000000L), ('min', 60000000000000L), ('s', 1000000000000L), ('ms', 1000000000), ('us', 1000000), ('ns', 1000), ('ps', 1)])

def Start(T):
    import TimerMod
    return TimerMod.Start(T)
M3ProcLib.enter('Timer.i3o:95',Start)

def Stop(T):
    import TimerMod
    return TimerMod.Stop(T)
M3ProcLib.enter('Timer.i3o:124',Stop)

def Change(T,newValue):
    import TimerMod
    return TimerMod.Change(T,newValue)
M3ProcLib.enter('Timer.i3o:153',Change)

def GetElapsed():
    import TimerMod
    return TimerMod.GetElapsed()
M3ProcLib.enter('Timer.i3o:193',GetElapsed)
Example #15
0
import M3Objects
import M3Types
import M3Predefined
import M3TypeLib
import M3ProcLib
M3TL = M3TypeLib.internaliseTypes(r'/home/mark/m3/lib/m3lib/RegressInt')


def init(name):
    import RegressMod
    return RegressMod.init(name)


M3ProcLib.enter('Regress.i3o:7', init)


def assertPass(cond):
    import RegressMod
    return RegressMod.assertPass(cond)


M3ProcLib.enter('Regress.i3o:33', assertPass)


def summary():
    import RegressMod
    return RegressMod.summary()


M3ProcLib.enter('Regress.i3o:59', summary)
Example #16
0
import M3Objects
import M3Types
import RTSTypes
import M3Predefined
from BankTypesInt import Card
from BankTypesInt import Card
import M3TypeLib
import M3ProcLib
import CapsuleMap
from Statistics import M3incStat

M3TL = M3TypeLib.internaliseTypes(r'm3lib/ATMSafeCapMod')


class ATMSafe(RTSTypes.M3CapsuleRuntimeType):
    def M3TriggerProc31(self):
        return self.failureCount.equals(M3Types.M3IntegerBase.createObject(3))

    def M3startCapsule(self):
        self.M3State = 'empty'
        self.M3TransitionFinishedHook(self.M3State)

    def insertCard(self, card):
        if self.M3State in ['empty']:
            m = getattr(self, 'M3insertCard__' + self.M3State)
            self.M3TransitionCallHook('insertCard', self.M3State)
            m(card)
        else:
            self.M3NoTransitionForMessageInState('insertCard', self.M3State)
        self.M3TransitionFinishedHook(self.M3State)
Example #17
0
import M3Objects
import M3Types
import RTSTypes
import M3Predefined
import IOInt as IO
import M3TypeLib
import M3ProcLib
import CapsuleMap
from Statistics import M3incStat
M3TL = M3TypeLib.internaliseTypes(r'm3lib/pyactCapMod')


class pyact(RTSTypes.M3CapsuleRuntimeType):
    def act(self, ):
        M3incStat('RECEIVE', 'act')
        IO.Put(M3Types.M3Text.createObject("act called\n"))

    def __init__(self, level, runtimeName):
        self.runtimeName = runtimeName
        self.__level = level
        RTSTypes.M3CapsuleRuntimeType.__init__(self, level)
        self.__init_capsule_connect()
        self.__init_capsule_begin_end()
        self.__init_param_converters()

    def __init_capsule_connect(self):
        pass

    def __init_capsule_begin_end(self):
        pass  # capsule BEGIN .. END