Commit 1caa8675 authored by Michael Büsch's avatar Michael Büsch

core: Defer source translation until all sources are uploaded.

Signed-off-by: Michael Büsch's avatarMichael Buesch <m@bues.ch>
parent be6199f9
This diff is collapsed.
......@@ -116,36 +116,36 @@ class AwlSim(object):
except AwlSimError as e:
self.__handleSimException(e)
def load(self, parseTree):
def load(self, parseTree, rebuild = False):
if self.__profileLevel >= 2:
self.__profileStart()
try:
self.cpu.load(parseTree)
self.cpu.load(parseTree, rebuild)
except AwlSimError as e:
self.__handleSimException(e)
if self.__profileLevel >= 2:
self.__profileStop()
def loadSymbolTable(self, symTab):
def loadSymbolTable(self, symTab, rebuild = False):
if self.__profileLevel >= 2:
self.__profileStart()
try:
self.cpu.loadSymbolTable(symTab)
self.cpu.loadSymbolTable(symTab, rebuild)
except AwlSimError as e:
self.__handleSimException(e)
if self.__profileLevel >= 2:
self.__profileStop()
def loadLibraryBlock(self, libSelection):
def loadLibraryBlock(self, libSelection, rebuild = False):
if self.__profileLevel >= 2:
self.__profileStart()
try:
self.cpu.loadLibraryBlock(libSelection)
self.cpu.loadLibraryBlock(libSelection, rebuild)
except AwlSimError as e:
self.__handleSimException(e)
......
......@@ -2,7 +2,7 @@
#
# AWL simulator - PLC core server
#
# Copyright 2013-2014 Michael Buesch <m@bues.ch>
# Copyright 2013-2015 Michael Buesch <m@bues.ch>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......@@ -197,6 +197,7 @@ class AwlSimServer(object):
def __init__(self):
self.__startupDone = False
self.__state = -1
self.__needOB10x = True
self.setRunState(self._STATE_INIT)
self.__nextStats = 0
......@@ -269,10 +270,13 @@ class AwlSimServer(object):
if runstate == self._STATE_INIT:
# We just entered initialization state.
printVerbose("Putting CPU into INIT state.")
self.__needOB10x = True
elif runstate == self.STATE_RUN:
# We just entered RUN state.
printVerbose("CPU startup (OB 10x).")
self.__sim.startup()
if self.__needOB10x:
printVerbose("CPU startup (OB 10x).")
self.__sim.startup()
self.__needOB10x = False
printVerbose("Putting CPU into RUN state.")
elif runstate == self.STATE_STOP:
# We just entered STOP state.
......@@ -280,6 +284,7 @@ class AwlSimServer(object):
elif runstate == self.STATE_MAINTENANCE:
# We just entered MAINTENANCE state.
printVerbose("Putting CPU into MAINTENANCE state.")
self.__needOB10x = True
self.__state = runstate
# Make a shortcut variable for RUN
......@@ -404,12 +409,18 @@ class AwlSimServer(object):
self.loadedHwModules = []
# List of loaded AwlLibEntrySelection()s
self.loadedLibSelections = []
# Schedule a CPU restart/rebuild.
self.__needOB10x = True
def loadAwlSource(self, awlSource):
parser = AwlParser()
parser.parseSource(awlSource)
self.setRunState(self.STATE_STOP)
self.__sim.load(parser.getParseTree())
needRebuild = False
if self.__state == self.STATE_RUN or\
(self.__state == self.STATE_STOP and\
not self.__needOB10x):
needRebuild = True
self.__sim.load(parser.getParseTree(), needRebuild)
self.loadedAwlSources.append(awlSource)
def loadSymTabSource(self, symTabSource):
......@@ -502,6 +513,8 @@ class AwlSimServer(object):
)
client.transceiver.send(reply)
#TODO add a call that can remove sources from the CPU.
def __rx_LOAD_CODE(self, client, msg):
printDebug("Received message: LOAD_CODE")
status = AwlSimMessage_REPLY.STAT_OK
......
[AWLSIM_PROJECT]
file_version=0
create_date=2015-04-26 11:50:46.884405
modify_date=2015-04-27 19:49:38.946304
[CPU]
awl_0=Ly8gQnVnOiBUaGUgREIgc291cmNlIGlzIGluIHRoZSBoaWVyYXJjaHkgX2JlZm9yZV8NCi8vICAgICAgdGhlIEZCIHNvdXJjZS4gSG93ZXZlciwgdGhlIERCIGRlY2xhcmF0aW9uDQovLyAgICAgIHJlZmVyZW5jZXMgdGhlIEZCIChpdCBpcyBhbiBpbnN0YW5jZSBEQikuDQovLyAgICAgIFRoaXMgY2F1c2VkIGVycm9ycyBpbiB0cmFuc2xhdGlvbiBvZiB0aGUgREJzLg0KLy8gRml4OiBEZWZlcnJlZCB0cmFuc2xhdGlvbi4NCg0KT1JHQU5JWkFUSU9OX0JMT0NLIE9CIDENCkJFR0lODQoJQ0FMTAkidGVzdF9mYiIsIERCIDENCglDQUxMCUZCIDIsIERCIDINCg0KDQoJQ0FMTCBTRkMgNDYgLy8gU1RPUCBDUFUNCkVORF9PUkdBTklaQVRJT05fQkxPQ0sNCg==
awl_name_0=T0Ix
awl_1=REFUQV9CTE9DSyBEQiAxDQoJInRlc3RfZmIiDQpCRUdJTg0KRU5EX0RBVEFfQkxPQ0sNCg0KREFUQV9CTE9DSyBEQiAyDQoJRkIgMg0KQkVHSU4NCkVORF9EQVRBX0JMT0NLDQo=
awl_name_1=REI=
awl_2=RlVOQ1RJT05fQkxPQ0sgInRlc3RfZmIiDQoJVkFSDQoJCXYgOiBCT09MOw0KCUVORF9WQVINCkJFR0lODQoJQkUNCkVORF9GVU5DVElPTl9CTE9DSw0KDQpGVU5DVElPTl9CTE9DSyBGQiAyDQoJVkFSDQoJCXYgOiBCT09MOw0KCUVORF9WQVINCkJFR0lODQoJQkUNCkVORF9GVU5DVElPTl9CTE9DSw0K
awl_name_2=RkI=
mnemonics=0
nr_accus=2
clock_memory_byte=-1
ob_startinfo_enable=0
ext_insns_enable=0
[SYMBOLS]
sym_tab_0=MTI2LHRlc3RfZmIgICAgICAgICAgICAgICAgIEZCIDEgICAgICAgIEZCIDEgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIA0K
sym_tab_name_0=U3ltYm9sIHRhYmxl
[LIBS]
[CORE_LINK]
spawn_local=1
spawn_local_port_range=4183:8278
spawn_local_interpreters=JERFRkFVTFQ=
connect_host=bG9jYWxob3N0
connect_port=4151
connect_timeout_ms=3000
[HWMODS]
[GUI]
editor_autoindent=1
editor_paste_autoindent=1
editor_validation=1
editor_font=
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment