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
2 changes: 1 addition & 1 deletion Container.py
Original file line number Diff line number Diff line change
Expand Up @@ -2972,7 +2972,7 @@ def OnTestEditor(self, event):
#model_path = os.path.dirname(self.python_path)

# TODO: Testable :: OnTestEditor => Fix Editor importation
from . import Editor
import Editor

#mainW = wx.GetApp().GetTopWindow()
### Editor instanciation and configuration---------------------
Expand Down
17 changes: 10 additions & 7 deletions Domain/Generator/RandomGenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,11 @@ def __init__(self, minValue=0, maxValue=10, minStep=1, maxStep=1, start=0, choic
@param minStep: minimum step
@param maxStep: maximum step
@param start: time start
@param choice: list of items
@param choice: list of items

"""
DomainBehavior.__init__(self)

self.initPhase('START',start)

self.minValue = minValue
self.maxValue = maxValue
self.minStep = minStep
Expand All @@ -37,14 +35,19 @@ def __init__(self, minValue=0, maxValue=10, minStep=1, maxStep=1, start=0, choic

self.msg = Message(None, None)

self.initPhase('START',float(start))

def outputFnc(self):
""" lambda DEVS function
"""
numberMessage = random.randint(1, len(self.OPorts)) # Number message to send
portsToSend = random.sample(self.OPorts, numberMessage) # The port with number message

for port in portsToSend:
value = random.randint(self.minValue, self.maxValue) if self.choice else random.choice(self.choice)
if self.choice:
value = random.choice(self.choice)
else:
value = random.randint(self.minValue, self.maxValue)
self.msg.value = [value, 0.0, 0.0]
self.msg.time = self.timeNext
### adapted with PyPDEVS
Expand All @@ -55,7 +58,7 @@ def intTransition(self):
"""
self.state['sigma'] = random.randint(self.minStep, self.maxStep)
### adapted with PyPDEVS
return self.state
return self.getState()

def __str__(self):
""" str function
Expand All @@ -65,4 +68,4 @@ def __str__(self):
def timeAdvance(self):
""" Time advance function
"""
return self.state['sigma']
return self.getSigma()
22 changes: 16 additions & 6 deletions Editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -2320,14 +2320,24 @@ def ConfigureGUI(self):
env_gen_def = wx.MenuItem(insert, wx.NewIdRef(), _('Environment methods generation'), _('Generate minimal methods for environment'))
# env_spec_def = wx.MenuItem(insert, wx.NewIdRef(), _('Specific environment methods generation'), _('Generate minimal methods for specific environment'))

insert.AppendItem(feature)
insert.AppendItem(steps)
insert.AppendItem(env_header)
insert.AppendItem(env_gen_def)
# insert.AppendItem(env_spec_def)
if wx.VERSION_STRING < '4.0':
insert.AppendItem(feature)
insert.AppendItem(steps)
insert.AppendItem(env_header)
insert.AppendItem(env_gen_def)
# insert.AppendItem(env_spec_def)
else:
insert.Append(feature)
insert.Append(steps)
insert.Append(env_header)
insert.Append(env_gen_def)
# insert.Append(env_spec_def)

menu = self.GetMenuBar().GetMenu(1)
menu.PrependMenu(wx.NewIdRef(), _("Insert"), insert)
if wx.VERSION_STRING < '4.0':
menu.PrependMenu(wx.NewIdRef(), _("Insert"), insert)
else:
menu.Prepend(wx.NewIdRef(), _("Insert"), insert)
### ----------------------------------------------------------------

### Bind all new event----------------------------------------------
Expand Down
8 changes: 4 additions & 4 deletions ZipManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,15 +164,15 @@ def Update(self, replace_files:[str]=[])->None:
#sys.stdout.write("%s unknown\n"%(fn))

### try to rewrite not replaced files from original zip
if not zout.testzip():
try:
info_list = zin.infolist()
for item in info_list:
s = os.path.basename(item.filename)
if s not in map(os.path.basename, replace_files) and info_list.index(item) not in exclude_file:
buffer = zin.read(item.filename)
zout.writestr(item, buffer)
sys.stdout.write("%s rewrite\n"%(item.filename))
else:
except Exception as e:
sys.stdout.write("%s not updated\n"%(self.fn))

### close all files
Expand Down Expand Up @@ -268,8 +268,8 @@ def HasPlugin(fn:str)->bool:
def HasTests(fn:str)->bool:
""" TODO: comment
"""
module_name = getPythonModelFileName(fn)
name = os.path.basename(module_name.split('.'))[0]
#module_name = getPythonModelFileName(fn)
#name = os.path.basename(module_name.split('.'))[0]
zf = zipfile.ZipFile(fn, 'r')
nl = zf.namelist()
zf.close()
Expand Down