diff --git a/Domain/Collector/MessagesCollector.py b/Domain/Collector/MessagesCollector.py index 976c6e84..46a33f62 100644 --- a/Domain/Collector/MessagesCollector.py +++ b/Domain/Collector/MessagesCollector.py @@ -51,21 +51,19 @@ def extTransition(self, *args): """ for port in self.IPorts: - msg = self.peek(port, *args) - np = self.getPortId(port) - ### adapted with PyPDEVS -# if hasattr(self, 'peek'): -# msg = self.peek(port) -# np = port.myID -# else: -# inputs = args[0] -# msg = inputs.get(port) -# np=port.port_id + if hasattr(self, 'peek'): + msg = self.peek(port) + np = port.myID + else: + inputs = args[0] + msg = inputs.get(port) + np=port.port_id if msg: ### filename fn = "%s%d%s"%(self.fileName, np, self.ext) + with open(fn,'a') as f: f.write("%s\n"%(str(msg))) del msg diff --git a/Domain/Collector/To_Disk.py b/Domain/Collector/To_Disk.py index 538cdac1..b29c87d5 100644 --- a/Domain/Collector/To_Disk.py +++ b/Domain/Collector/To_Disk.py @@ -24,7 +24,7 @@ class To_Disk(QuickScope): """ ### - def __init__(self, fileName = os.path.join(os.getcwd(),"result%d"%random.randint(1,100)), eventAxis = False, comma = " ", ext = '.dat'): + def __init__(self, fileName = os.path.join(os.getcwd(),"result%d"%random.randint(1,100)), eventAxis = False, comma = " ", ext = '.dat', col = 0): """ Constructor. @param fileName : Name of output fileName @@ -39,6 +39,7 @@ def __init__(self, fileName = os.path.join(os.getcwd(),"result%d"%random.randint self.fileName = fileName self.comma = comma self.ext = ext + self.col = col #decimal precision getcontext().prec = 6 @@ -69,14 +70,12 @@ def extTransition(self, *args): # self.pos = self.pos[0:n] for np in range(n): - msg = self.peek(self.IPorts[np], *args) - -# ### adapted with PyPDEVS -# if hasattr(self, 'peek'): -# msg = self.peek(self.IPorts[np]) -# else: -# inputs = args[0] -# msg = inputs.get(self.IPorts[np]) + ### adapted with PyPDEVS + if hasattr(self, 'peek'): + msg = self.peek(self.IPorts[np]) + else: + inputs = args[0] + msg = inputs.get(self.IPorts[np]) ### filename fn = "%s%d%s"%(self.fileName, np, self.ext) @@ -100,17 +99,16 @@ def extTransition(self, *args): if fn not in self.last_time_value: self.last_time_value.update({fn:1}) - t = Decimal(str(float(self.getMsgTime(msg)))) - -# ### adapted with PyPDEVS -# if hasattr(self, 'peek'): -# t = Decimal(str(float(msg.time))) -# else: -# t = Decimal(str(float(msg[-1][0]))) + ### adapted with PyPDEVS + if hasattr(self, 'peek'): + t = Decimal(str(float(msg.time))) + else: + t = Decimal(str(float(msg[-1][0]))) ### adapted with PyPDEVS - val = self.getMsgValue(msg) + val = msg.value[self.col] if hasattr(self, 'peek') else msg[0][self.col] + if isinstance(val, int) or isinstance(val, float): v = Decimal(str(float(val))) else: @@ -123,6 +121,21 @@ def extTransition(self, *args): self.buffer[fn] = v + ### run only with python 2.6 + #with open(fn, 'a') as f: + + # if t == self.last_time_value[fn]: + # if self.pos[np] == -1: + # self.pos[np] = 0 + # f.seek(self.pos[np], os.SEEK_SET) + # f.truncate(self.pos[np]) + + # else: + # self.pos[np] = f.tell() + # self.last_time_value[fn] = t + + # f.write("%s%s%s\n"%(t,self.comma,v)) + del msg self.state["sigma"] = 0 diff --git a/devsimpy.py b/devsimpy.py index 52328351..ddeb8b6c 100644 --- a/devsimpy.py +++ b/devsimpy.py @@ -171,6 +171,9 @@ # Sets the homepath variable to the directory where your application is located (sys.argv[0]). builtins.__dict__.update(builtin_dict) +### Deprecation warnings with Python 3.8 +wx._core.WindowIDRef.__index__ = wx._core.WindowIDRef.__int__ + ### import Container much faster loading than from Container import ... for os windows only import Container import Menu @@ -220,7 +223,7 @@ def DefineScreenSize(percentscreen = None, size = None): elif percentscreen: x1, x2, l, h = wx.Display().GetClientArea() l, h = percentscreen * l, percentscreen * h - return l, h + return round(l), round(h) # ------------------------------------------------------------------- class MainApplication(wx.Frame):