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: 15 additions & 3 deletions Container.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
import ConnectDialog
import DiagramConstantsDialog
import SpreadSheet
import pluginmanager
#from PluginManager import PluginManager
import ZipManager
import DropTarget
import PlotGUI
Expand Down Expand Up @@ -2068,9 +2068,16 @@ def OnStartWizard(self, event):

return gmwiz

def OnRefreshModel(self, event):
def OnRefreshModels(self, event):
""" New model menu has been pressed. Wizard is instanciate.
"""

diagram = self.GetDiagram()
for block in diagram.GetFlatBlockShapeList():
block.status_label = ""
color = CodeBlock.FILL if isinstance(block, CodeBlock) else ContainerBlock.FILL
block.fill = color

self.UpdateShapes([self])

def OnNewModel(self, event):
Expand Down Expand Up @@ -2789,7 +2796,7 @@ def UpdateShapes(self, L=None):
for m in [a for a in L if self.isSelected(a)]:
self.deselect(m)
self.select(m)

self.Refresh()

### selection sur le canvas les ONodes car c'est le seul moyen d'y accéder pour effectuer l'appartenance avec les modèles
Expand Down Expand Up @@ -3372,6 +3379,11 @@ def draw(self, dc):
### Draw label
dc.DrawText(self.label, mx, my)

if hasattr(self,'status_label'):
dc.DrawText(self.status_label, mx, my+20)
else:
self.status_label = ""

#def OnResize(self):
#Shape.OnResize(self)

Expand Down
10 changes: 5 additions & 5 deletions DEVSKernel/PyDEVS/simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from .DEVS import CoupledDEVS
#from Patterns.Strategy import SimStrategy1

import pluginmanager
from PluginManager import PluginManager

### avec ce flag, on gere a totalité des messages sur les ports une seul fois dans delta_ext.
WITHOUT_DELTA_EXT_FOR_ALL_PORT = True
Expand Down Expand Up @@ -72,8 +72,8 @@ def send(self, d, msg):
AS = AtomicSolver()
r = AS.receive(d, msg)

pluginmanager.trigger_event("SIM_BLINK", model=d, msg=msg)
pluginmanager.trigger_event("SIM_TEST", model=d, msg=msg)
PluginManager.trigger_event("SIM_BLINK", model=d, msg=msg)
PluginManager.trigger_event("SIM_TEST", model=d, msg=msg)

return r

Expand Down Expand Up @@ -149,7 +149,7 @@ def receive(aDEVS, msg):
aDEVS.elapsed = 0

# The SIM_VERBOSE event occurs
pluginmanager.trigger_event("SIM_VERBOSE", model=aDEVS, msg=0)
PluginManager.trigger_event("SIM_VERBOSE", model=aDEVS, msg=0)

# Return the DEVS' output to the parent coupled-DEVS (rather than
# sending $(y,\,t)$ message).
Expand All @@ -176,7 +176,7 @@ def receive(aDEVS, msg):
aDEVS.elapsed = 0

# The SIM_VERBOSE event occurs
pluginmanager.trigger_event("SIM_VERBOSE", model=aDEVS, msg=1)
PluginManager.trigger_event("SIM_VERBOSE", model=aDEVS, msg=1)

# $(i,\,t)$ message --- sets origin of time at {\tt t}:
elif msg[0] == 0:
Expand Down
3 changes: 2 additions & 1 deletion Domain/Generator/RandomGenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ def __init__(self, minValue=0, maxValue=10, minStep=1, maxStep=1, start=0):
"""
DomainBehavior.__init__(self)

self.state = {'sigma':start}
self.initPhase('START',start)

self.minValue = minValue
self.maxValue = maxValue
self.minStep = minStep
Expand Down
2 changes: 2 additions & 0 deletions DomainInterface/DomainBehavior.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ def __init__(self, name=""):

BaseDEVS.AtomicDEVS.__init__(self, name=name)

self.state = {'status':'NOT_DEFINED', 'sigma':0.0}

### if BaseDEVS AtomicDEVS class has the peek method, we have the PyDEVS simulator kernel
### else its the PyPDEVS simulator kernel and we adapt the peek and poke method for compatibility aspects
if hasattr(BaseDEVS.AtomicDEVS, 'peek'):
Expand Down
10 changes: 5 additions & 5 deletions Menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@

import Container
import ZipManager
import pluginmanager

from PluginManager import PluginManager
from ExperimentGenerator import ExperimentGenerator

_ = wx.GetTranslation
Expand Down Expand Up @@ -835,7 +835,7 @@ def __init__(self, parent):

### binding
parent.Bind(wx.EVT_MENU, parent.OnNewModel, id=ID_NEW_SHAPE)
parent.Bind(wx.EVT_MENU, parent.OnRefreshModel, id=ID_REFRESH_SHAPE)
parent.Bind(wx.EVT_MENU, parent.OnRefreshModels, id=ID_REFRESH_SHAPE)
parent.Bind(wx.EVT_MENU, parent.OnPaste, id=ID_PASTE_SHAPE)
parent.Bind(wx.EVT_MENU, parent.diagram.OnAddConstants, id=ID_ADD_CONSTANTS)
parent.Bind(wx.EVT_MENU, parent.parent.PrintPreview, id=ID_PREVIEW_PRINT)
Expand Down Expand Up @@ -1010,7 +1010,7 @@ def __init__(self, shape, event):
Export_SubMenu1.Enable(False)

### if Wcomp general plugin is enabled, sub menu appear in contextual menu of amd (right clic)
pluginmanager.trigger_event("ADD_WCOMP_EXPORT_MENU", parent=self, model=shape, submenu= export_subMenu)
PluginManager.trigger_event("ADD_WCOMP_EXPORT_MENU", parent=self, model=shape, submenu= export_subMenu)

elif isinstance(shape, Container.ContainerBlock):
self.AppendSeparator()
Expand All @@ -1035,10 +1035,10 @@ def __init__(self, shape, event):
self.__canvas.Bind(wx.EVT_MENU, shape.OnPluginsManager, id=ID_PLUGINS_SHAPE)

### if Wcomp general plug-in is enabled, sub menu appear in contextual menu of amd (right clic)
pluginmanager.trigger_event("ADD_WCOMP_STRATEGY_MENU", parent=self, model=shape)
PluginManager.trigger_event("ADD_WCOMP_STRATEGY_MENU", parent=self, model=shape)

### if state trajectory general plug-in is enabled, sub menu appear in contextual menu (right clic)
pluginmanager.trigger_event("ADD_STATE_TRAJECTORY_MENU", parent=self, model=shape)
PluginManager.trigger_event("ADD_STATE_TRAJECTORY_MENU", parent=self, model=shape)

self.AppendSeparator()
Properties_menu = AppendItem(properties)
Expand Down
27 changes: 17 additions & 10 deletions Patterns/Singleton.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# -*- coding: utf-8 -*-

## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ##
# Singleton.py ---
# Observer.py ---
# --------------------------------
# Copyright (c) 2020
# L. CAPOCCHI (capocchi@univ-corse.fr)
# SPE Lab - SISU Group - University of Corsica
# --------------------------------
# Version 2.0 last modified: 03/15/20
# Version 2.0 last modified: 05/14/20
## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ##
#
# GENERAL NOTES AND REMARKS:
Expand All @@ -20,12 +20,19 @@
#
## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ##

class Singleton(type):
def __init__(cls, name, bases, dict):
super(Singleton, cls).__init__(name, bases, dict)
cls.instance = None
def Singleton(myClass):
""" Signleton used as Decorator
"""
instances={}
def getInstance(*args, **kwargs):
if myClass not in instances:
instances[myClass] = myClass(*args, **kwargs)
return instances[myClass]
return getInstance

def __call__(cls,*args,**kw):
if cls.instance is None:
cls.instance = super(Singleton, cls).__call__(*args, **kw)
return cls.instance
if __name__ == '__main__':
@Singleton
class SingletonTest(object):
pass

SingletonTest()
18 changes: 9 additions & 9 deletions Patterns/Strategy.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import threading
import inspect

from pluginmanager import trigger_event
from PluginManager import PluginManager #trigger_event
from Utilities import getOutDir

import builtins
Expand Down Expand Up @@ -172,7 +172,7 @@ def simulate(self, T = 100000000):

else:
# The SIM_VERBOSE event occurs
trigger_event("SIM_VERBOSE", clock = clock)
PluginManager.trigger_event("SIM_VERBOSE", clock = clock)

send(master, (1, {}, clock))

Expand Down Expand Up @@ -375,9 +375,9 @@ def execExtTransition(m):
m.elapsed = 0.0

# The SIM_VERBOSE event occurs
trigger_event("SIM_VERBOSE", model=m, msg=1)
trigger_event("SIM_BLINK", model=m, msg=[{}])
trigger_event("SIM_TEST", model=m, msg=[{}])
PluginManager.trigger_event("SIM_VERBOSE", model=m, msg=1)
PluginManager.trigger_event("SIM_BLINK", model=m, msg=[{}])
PluginManager.trigger_event("SIM_TEST", model=m, msg=[{}])

return m

Expand All @@ -401,9 +401,9 @@ def execIntTransition(m):
m.elapsed = 0.0

# The SIM_VERBOSE event occurs
trigger_event("SIM_VERBOSE", model=m, msg=0)
trigger_event("SIM_BLINK", model=m, msg=[1])
trigger_event("SIM_TEST", model=m, msg=[1])
PluginManager.trigger_event("SIM_VERBOSE", model=m, msg=0)
PluginManager.trigger_event("SIM_BLINK", model=m, msg=[1])
PluginManager.trigger_event("SIM_TEST", model=m, msg=[1])

class Clock(object):
def __init__(self, time):
Expand Down Expand Up @@ -476,7 +476,7 @@ def simulate(self, T = 100000000):
else:

### The SIM_VERBOSE event occurs
trigger_event("SIM_VERBOSE", self.master, None, clock = self.ts.Get())
PluginManager.trigger_event("SIM_VERBOSE", self.master, None, clock = self.ts.Get())

### tree-like data structure ordered by devsimpy priority
priority_scheduler = [a for a in formated_priority_list if self.ts.Get() == a[1].myTimeAdvance]
Expand Down
16 changes: 8 additions & 8 deletions PluginsGUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
from wx.lib.mixins.listctrl import CheckListCtrlMixin, ListCtrlAutoWidthMixin

from Decorators import BuzyCursorNotification
from pluginmanager import enable_plugin, disable_plugin, load_plugins
from PluginManager import PluginManager
from Utilities import FormatSizeFile, getPYFileListFromInit

import ZipManager
Expand Down Expand Up @@ -305,7 +305,7 @@ def Importing(self, root, basename):
"""

# check the loaded module during the start of plug-ins
module = load_plugins(basename)
module = PluginManager.load_plugins(basename)

### if module is exception (or tuple)
if not inspect.ismodule(module):
Expand All @@ -322,7 +322,7 @@ def Importing(self, root, basename):
if basename in self.active_plugins_list:
self.CheckItem(index)
else:
disable_plugin(basename)
PluginManager.disable_plugin(basename)
else:
self.SetItemImage(index, 2)

Expand Down Expand Up @@ -378,9 +378,9 @@ def OnApply(self, event):

if self.IsChecked(i):
pluginsList.append(name)
enable_plugin(name)
PluginManager.enable_plugin(name)
else:
disable_plugin(name)
PluginManager.disable_plugin(name)

### config file writing
self.mainW.cfg.Write('active_plugins', str(pluginsList))
Expand All @@ -404,18 +404,18 @@ def __init__(self, *args, **kwargs):

### if pluginsList (2 param in constructor) is in constructor, we can populate
try:
pluginsList = args[1]
PluginManager.pluginsList = args[1]
except IndexError:
#sys.stdout.write(_('D'ont forget to call Populate method!\n'))
pass
else:
try:
### Populate Check List dynamicaly
pool = ThreadPoolExecutor(3)
future = pool.submit(self.Populate, (pluginsList))
future = pool.submit(self.Populate, (PluginManager.pluginsList))
future.done()
except:
self.Populate(pluginsList)
self.Populate(PluginManager.pluginsList)

self.is_populate = True

Expand Down
20 changes: 10 additions & 10 deletions SimulationGUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
'PyPDEVS':os.path.join(os.pardir,'DEVSKernel','PyPDEVS', 'old')}

from Utilities import IsAllDigits, playSound, printOnStatusBar, NotificationMessage
from pluginmanager import trigger_event, is_enable
from PluginManager import PluginManager #trigger_event, is_enable
from Patterns.Strategy import *
from Decorators import BuzyCursorNotification, hotshotit

Expand Down Expand Up @@ -404,7 +404,7 @@ def ChangeButtonLabel(self, btn, new_label):
"""

### if activity plug-in is enabled
if is_enable('start_activity_tracking'):
if PluginManager.is_enable('start_activity_tracking'):
self._btn4.SetLabel("Activity")

###
Expand All @@ -417,10 +417,10 @@ def OnViewLog(self, event):
""" When View button is clicked
"""
# The simulation verbose event occurs
trigger_event('START_SIM_VERBOSE', parent=self)
PluginManager.trigger_event('START_SIM_VERBOSE', parent=self)

# The activity tracking event occurs
trigger_event('VIEW_ACTIVITY_REPORT', parent=self, master=self.current_master)
PluginManager.trigger_event('VIEW_ACTIVITY_REPORT', parent=self, master=self.current_master)

###
def OnOk(self, event):
Expand Down Expand Up @@ -464,20 +464,20 @@ def OnOk(self, event):

if (self.thread is None) or (not self.timer.IsRunning()):

trigger_event("START_BLINK", parent=self, master=self.current_master)
trigger_event("START_TEST", parent=self, master=self.current_master)
PluginManager.trigger_event("START_BLINK", parent=self, master=self.current_master)
PluginManager.trigger_event("START_TEST", parent=self, master=self.current_master)

### The START_ACTIVITY_TRACKING event occurs
trigger_event("START_ACTIVITY_TRACKING", parent=self, master=self.current_master)
PluginManager.trigger_event("START_ACTIVITY_TRACKING", parent=self, master=self.current_master)

### The START_ACTIVITY_TRACKING event occurs
trigger_event("START_STATE_TRAJECTORY", parent=self, master=self.current_master)
PluginManager.trigger_event("START_STATE_TRAJECTORY", parent=self, master=self.current_master)

### The START_CONCURRENT_SIMULATION event occurs
trigger_event("START_CONCURRENT_SIMULATION", parent=self, master=self.current_master)
PluginManager.trigger_event("START_CONCURRENT_SIMULATION", parent=self, master=self.current_master)

### future call is required because the simulator is flattened during the execution of the strategy 3
wx.FutureCall(1, trigger_event, 'START_DIAGRAM', parent=self, master=self.current_master)
wx.FutureCall(1, PluginManager.trigger_event, 'START_DIAGRAM', parent=self, master=self.current_master)

### clear all log file
for fn in [f for f in os.listdir(gettempdir()) if f.endswith('.devsimpy.log')]:
Expand Down
4 changes: 2 additions & 2 deletions ZipManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import gettext
_ = gettext.gettext

from pluginmanager import trigger_event
from PluginManager import PluginManager #trigger_event
from traceback import format_exception
from Utilities import listf, path_to_module

Expand Down Expand Up @@ -308,7 +308,7 @@ def GetModule(self, rcp: bool=False)->types.ModuleType:
# if necessary, recompile (for update after editing code source of model)
#if rcp: recompile(module_name)

trigger_event("IMPORT_STRATEGIES", fn=self.fn)
PluginManager.trigger_event("IMPORT_STRATEGIES", fn=self.fn)

return self.ImportModule() if self.fullname not in sys.modules else sys.modules[self.fullname]

Expand Down
Loading