Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions Domain/Collector/MessagesCollector.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
47 changes: 30 additions & 17 deletions Domain/Collector/To_Disk.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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:
Expand All @@ -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
Expand Down
5 changes: 4 additions & 1 deletion devsimpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down