Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
dream
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
dream
Commits
44f69248
Commit
44f69248
authored
Sep 08, 2014
by
Georgios Dagkakis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
methods passed to ManPyObject
parent
a7b17789
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
81 additions
and
78 deletions
+81
-78
dream/simulation/CoreObject.py
dream/simulation/CoreObject.py
+2
-77
dream/simulation/ManPyObject.py
dream/simulation/ManPyObject.py
+79
-1
No files found.
dream/simulation/CoreObject.py
View file @
44f69248
...
...
@@ -429,15 +429,6 @@ class CoreObject(ManPyObject):
# receivers.append(object)
# return receivers
#===========================================================================
# check if the any of the operators are skilled (having a list of skills regarding the objects)
#===========================================================================
@
staticmethod
def
checkForDedicatedOperators
():
from
Globals
import
G
# XXX this can also be global
# flag used to inform if the operators assigned to the station are skilled (skillsList)
return
any
(
operator
.
skillsList
for
operator
in
G
.
OperatorsList
)
# =======================================================================
# signal the successor that the object can dispose an entity
...
...
@@ -492,43 +483,6 @@ class CoreObject(ManPyObject):
receiver
=
object
# set the receiver as the longest waiting possible receiver
return
receiver
#===========================================================================
# method used to request allocation from the Router
#===========================================================================
@
staticmethod
def
requestAllocation
():
# TODO: signal the Router, skilled operators must be assigned to operatorPools
from
Globals
import
G
G
.
Router
.
allocation
=
True
G
.
Router
.
waitEndProcess
=
False
if
not
G
.
Router
.
invoked
:
G
.
Router
.
invoked
=
True
G
.
Router
.
isCalled
.
succeed
(
G
.
env
.
now
)
#===========================================================================
# signalRouter method
#===========================================================================
@
staticmethod
def
signalRouter
(
receiver
=
None
):
# if an operator is not assigned to the receiver then do not signal the receiver but the Router
try
:
# XXX in the case of dedicatedOperator assignedOperators must be always True in order to avoid invoking the Router
if
not
receiver
.
assignedOperator
or
\
(
receiver
.
isPreemptive
and
len
(
receiver
.
Res
.
users
)
>
0
):
if
receiver
.
isLoadRequested
():
try
:
from
Globals
import
G
if
not
G
.
Router
.
invoked
:
# self.printTrace(self.id, signal='router')
G
.
Router
.
invoked
=
True
G
.
Router
.
isCalled
.
succeed
(
G
.
env
.
now
)
return
True
except
:
return
False
else
:
return
False
except
:
return
False
#===========================================================================
# sort the entities of the queue for the receiver
...
...
@@ -678,35 +632,6 @@ class CoreObject(ManPyObject):
G
.
traceSheet
=
G
.
traceFile
.
add_sheet
(
'sheet '
+
str
(
G
.
sheetIndex
),
cell_overwrite_ok
=
True
)
@
staticmethod
def
printTrace
(
entity
=
''
,
**
kw
):
assert
len
(
kw
)
==
1
,
'only one phrase per printTrace supported for the moment'
from
Globals
import
G
import
Globals
time
=
G
.
env
.
now
charLimit
=
60
remainingChar
=
charLimit
-
len
(
entity
)
-
len
(
str
(
time
))
if
(
G
.
console
==
'Yes'
):
print
time
,
entity
,
for
key
in
kw
:
if
key
not
in
Globals
.
getSupportedPrintKwrds
():
raise
ValueError
(
"Unsupported phrase %s for %s"
%
(
key
,
entity
))
element
=
Globals
.
getPhrase
()[
key
]
phrase
=
element
[
'phrase'
]
prefix
=
element
.
get
(
'prefix'
,
None
)
suffix
=
element
.
get
(
'suffix'
,
None
)
arg
=
kw
[
key
]
if
prefix
:
print
prefix
*
remainingChar
,
phrase
,
arg
elif
suffix
:
remainingChar
-=
len
(
phrase
)
+
len
(
arg
)
suffix
*=
remainingChar
if
key
==
'enter'
:
suffix
=
suffix
+
'>'
print
phrase
,
arg
,
suffix
else
:
print
phrase
,
arg
# =======================================================================
# outputs data to "output.xls"
# =======================================================================
...
...
dream/simulation/ManPyObject.py
View file @
44f69248
...
...
@@ -35,3 +35,81 @@ class ManPyObject(object):
def
__init__
(
self
,
id
,
name
,
**
kw
):
self
.
id
=
id
self
.
name
=
name
#===========================================================================
# method used to request allocation from the Router
#===========================================================================
@
staticmethod
def
requestAllocation
():
# TODO: signal the Router, skilled operators must be assigned to operatorPools
from
Globals
import
G
G
.
Router
.
allocation
=
True
G
.
Router
.
waitEndProcess
=
False
if
not
G
.
Router
.
invoked
:
G
.
Router
.
invoked
=
True
G
.
Router
.
isCalled
.
succeed
(
G
.
env
.
now
)
#===========================================================================
# signalRouter method
#===========================================================================
@
staticmethod
def
signalRouter
(
receiver
=
None
):
# if an operator is not assigned to the receiver then do not signal the receiver but the Router
try
:
# XXX in the case of dedicatedOperator assignedOperators must be always True in order to avoid invoking the Router
if
not
receiver
.
assignedOperator
or
\
(
receiver
.
isPreemptive
and
len
(
receiver
.
Res
.
users
)
>
0
):
if
receiver
.
isLoadRequested
():
try
:
from
Globals
import
G
if
not
G
.
Router
.
invoked
:
# self.printTrace(self.id, signal='router')
G
.
Router
.
invoked
=
True
G
.
Router
.
isCalled
.
succeed
(
G
.
env
.
now
)
return
True
except
:
return
False
else
:
return
False
except
:
return
False
#===========================================================================
# check if the any of the operators are skilled (having a list of skills regarding the objects)
#===========================================================================
@
staticmethod
def
checkForDedicatedOperators
():
from
Globals
import
G
# XXX this can also be global
# flag used to inform if the operators assigned to the station are skilled (skillsList)
return
any
(
operator
.
skillsList
for
operator
in
G
.
OperatorsList
)
@
staticmethod
def
printTrace
(
entity
=
''
,
**
kw
):
assert
len
(
kw
)
==
1
,
'only one phrase per printTrace supported for the moment'
from
Globals
import
G
import
Globals
time
=
G
.
env
.
now
charLimit
=
60
remainingChar
=
charLimit
-
len
(
entity
)
-
len
(
str
(
time
))
if
(
G
.
console
==
'Yes'
):
print
time
,
entity
,
for
key
in
kw
:
if
key
not
in
Globals
.
getSupportedPrintKwrds
():
raise
ValueError
(
"Unsupported phrase %s for %s"
%
(
key
,
entity
))
element
=
Globals
.
getPhrase
()[
key
]
phrase
=
element
[
'phrase'
]
prefix
=
element
.
get
(
'prefix'
,
None
)
suffix
=
element
.
get
(
'suffix'
,
None
)
arg
=
kw
[
key
]
if
prefix
:
print
prefix
*
remainingChar
,
phrase
,
arg
elif
suffix
:
remainingChar
-=
len
(
phrase
)
+
len
(
arg
)
suffix
*=
remainingChar
if
key
==
'enter'
:
suffix
=
suffix
+
'>'
print
phrase
,
arg
,
suffix
else
:
print
phrase
,
arg
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment