blob: 1a24b6c70adfb27502b2048d499aae7815098c14 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# -*- coding: utf-8 -*-
#
# AWL simulator
# Copyright 2012-2013 Michael Buesch <m@bues.ch>
#
# Licensed under the terms of the GNU General Public License version 2.
#
from awlcpu import *
from util import *
VERSION_MAJOR = 0
VERSION_MINOR = 9
class AwlSim(object):
def __init__(self):
self.cpu = S7CPU(self)
def __handleSimException(self, e):
raise AwlSimError("ERROR at AWL line %d: %s\n\n%s" %\
(self.cpu.getCurrentInsn().getLineNr(),
str(e), str(self.cpu)))
def load(self, parseTree):
self.cpu.load(parseTree)
try:
self.cpu.startup()
except AwlSimError as e:
self.__handleSimException(e)
def getCPU(self):
return self.cpu
def runCycle(self):
try:
self.cpu.runCycle()
except AwlSimError as e:
self.__handleSimException(e)
def __repr__(self):
return str(self.cpu)
|