...
 
Commits (3)
......@@ -162,10 +162,10 @@ cdef class S7CPU(object):
cdef runCycle(self)
cdef __runOB(self, OB block)
cdef run_BE(self)
cdef void run_BE(self)
cdef openDB(self, int32_t dbNumber, _Bool openDI)
cdef run_AUF(self, AwlOperator dbOper)
cdef run_TDB(self)
cdef void run_TDB(self)
cdef Accu getAccu(self, uint32_t index)
cdef Addressregister getAR(self, uint32_t index)
......
......@@ -1261,23 +1261,28 @@ class S7CPU(object): #+cdef
blockOper = blockOper.resolve(True)
#@cy if blockOper.operType == AwlOperatorTypes.BLKREF_FC:
#@cy return self.__call_RAW_FC(blockOper, dbOper, parameters)
#@cy elif blockOper.operType == AwlOperatorTypes.BLKREF_FB:
#@cy return self.__call_RAW_FB(blockOper, dbOper, parameters)
#@cy elif blockOper.operType == AwlOperatorTypes.BLKREF_SFC:
#@cy return self.__call_RAW_SFC(blockOper, dbOper, parameters)
#@cy elif blockOper.operType == AwlOperatorTypes.BLKREF_SFB:
#@cy return self.__call_RAW_SFB(blockOper, dbOper, parameters)
#@cy else:
#@cy raise AwlSimError("Invalid CALL operand")
try:
# Call the call helper and pass the resolved operands.
# The call to the call helper might raise a KeyError,
# if the block does not exist.
callHelper = self.__rawCallHelpers[blockOper.operType] #@nocy
try: #@nocy
#@cy if blockOper.operType == AwlOperatorTypes.BLKREF_FC:
#@cy return self.__call_RAW_FC(blockOper, dbOper, parameters)
#@cy elif blockOper.operType == AwlOperatorTypes.BLKREF_FB:
#@cy return self.__call_RAW_FB(blockOper, dbOper, parameters)
#@cy elif blockOper.operType == AwlOperatorTypes.BLKREF_SFC:
#@cy return self.__call_RAW_SFC(blockOper, dbOper, parameters)
#@cy elif blockOper.operType == AwlOperatorTypes.BLKREF_SFB:
#@cy return self.__call_RAW_SFB(blockOper, dbOper, parameters)
#@cy else:
#@cy raise AwlSimError("Invalid CALL operand")
callHelper = self.__rawCallHelpers[blockOper.operType] #@nocy
return callHelper(self, blockOper, dbOper, parameters) #@nocy
except KeyError as e: #@nocy
raise AwlSimError("Code block %d not found in indirect call" %( #@nocy
blockOper.offset.byteOffset)) #@nocy
except KeyError as e:
raise AwlSimError("Code block %d not found in indirect call" % (
blockOper.offset.byteOffset))
def __call_MULTI_FB(self, blockOper, dbOper, parameters): #@nocy
#@cy cdef CallStackElem __call_MULTI_FB(self, AwlOperator blockOper, AwlOperator dbOper, tuple parameters):
......@@ -1374,10 +1379,13 @@ class S7CPU(object): #+cdef
newCse.prevCse = self.callStackTop
self.callStackTop, self.callStackDepth = newCse, callStackDepth + 1
def run_BE(self): #+cdef
def run_BE(self): #@nocy
#@cy cdef void run_BE(self):
#@cy cdef S7StatusWord s
#@cy cdef CallStackElem cse
# This method is declared void and thus must not raise an exception.
s = self.statusWord
s.OS, s.OR, s.STA, s.NER = 0, 0, 1, 0
# Jump beyond end of block
......@@ -1419,8 +1427,10 @@ class S7CPU(object): #+cdef
self.openDB(dbOper.offset.byteOffset, openDI)
def run_TDB(self): #+cdef
# Swap global and instance DB
def run_TDB(self): #@nocy
#@cy cdef void run_TDB(self):
# Swap global and instance DB.
# This method is declared void and thus must not raise an exception.
self.diRegister, self.dbRegister = self.dbRegister, self.diRegister
def getAccu(self, index): #@nocy
......@@ -2227,9 +2237,8 @@ class S7CPU(object): #+cdef
if dbNumber < 0:
db = self.dbRegister
else:
try:
db = self.dbs[dbNumber]
except KeyError:
db = self.dbs.get(dbNumber)
if db is None:
raise AwlSimError("Store to DB %d, but DB "
"does not exist" % dbNumber)
db.store(operator, memObj, None)
......