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
accfa6d6
Commit
accfa6d6
authored
Jul 14, 2014
by
Ioannis Papagiannopoulos
Committed by
Georgios Dagkakis
Sep 01, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cherry-pick from readWIPseperatelly. OperatorPreemtive removed, no more needed
parent
01c103d8
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
129 deletions
+16
-129
dream/simulation/LineGenerationJSON.py
dream/simulation/LineGenerationJSON.py
+15
-15
dream/simulation/OperatorPreemptive.py
dream/simulation/OperatorPreemptive.py
+0
-113
dream/simulation/imports.py
dream/simulation/imports.py
+1
-1
No files found.
dream/simulation/LineGenerationJSON.py
View file @
accfa6d6
...
...
@@ -67,7 +67,7 @@ from BatchScrapMachine import BatchScrapMachine
from
LineClearance
import
LineClearance
from
EventGenerator
import
EventGenerator
from
Operator
import
Operator
from
OperatorPreemptive
import
OperatorPreemptive
#
from OperatorPreemptive import OperatorPreemptive
from
OperatorManagedJob
import
OperatorManagedJob
from
OperatorPool
import
OperatorPool
from
OperatedPoolBroker
import
Broker
...
...
@@ -164,7 +164,7 @@ def createObjects():
G
.
LineClearanceList
=
[]
G
.
EventGeneratorList
=
[]
G
.
OperatorsList
=
[]
G
.
OperatorPreemptivesList
=
[]
#
G.OperatorPreemptivesList = []
G
.
OperatorManagedJobsList
=
[]
G
.
OperatorPoolsList
=
[]
G
.
BrokersList
=
[]
...
...
@@ -217,19 +217,19 @@ def createObjects():
# calling the getSuccesorList() method on the operator
G
.
OperatorsList
.
append
(
O
)
# add the operator to the RepairmanList
G
.
ModelResourceList
.
append
(
O
)
elif
resourceClass
==
'Dream.OperatorPreemptive'
:
id
=
element
.
get
(
'id'
,
'not found'
)
# get the id of the element / default 'not_found'
name
=
element
.
get
(
'name'
,
'not found'
)
# get the name of the element / default 'not_found'
capacity
=
int
(
element
.
get
(
'capacity'
)
or
1
)
# get the capacity of the el. / defautl '1'
schedulingRule
=
element
.
get
(
'schedulingRule'
,
'FIFO'
)
# get the scheduling rule of the el. (how to choose which
# station to serve first) / default 'FIFO' i.e. the one that
# called first
O
=
OperatorPreemptive
(
element_id
,
name
,
capacity
,
schedulingRule
)
# create an operator object
O
.
coreObjectIds
=
getSuccessorList
(
id
)
# update the list of objects that the operator operates
# calling the getSuccesorList() method on the operator
G
.
OperatorsList
.
append
(
O
)
# add the operator to the RepairmanList
G
.
OperatorPreemptivesList
.
append
(
O
)
G
.
ModelResourceList
.
append
(
O
)
#
elif resourceClass=='Dream.OperatorPreemptive':
#
id = element.get('id', 'not found') # get the id of the element / default 'not_found'
#
name = element.get('name', 'not found') # get the name of the element / default 'not_found'
#
capacity = int(element.get('capacity') or 1) # get the capacity of the el. / defautl '1'
#
schedulingRule=element.get('schedulingRule', 'FIFO') # get the scheduling rule of the el. (how to choose which
#
# station to serve first) / default 'FIFO' i.e. the one that
#
# called first
#
O = OperatorPreemptive(element_id, name, capacity,schedulingRule) # create an operator object
#
O.coreObjectIds=getSuccessorList(id) # update the list of objects that the operator operates
#
# calling the getSuccesorList() method on the operator
#
G.OperatorsList.append(O) # add the operator to the RepairmanList
#
G.OperatorPreemptivesList.append(O)
#
G.ModelResourceList.append(O)
elif
resourceClass
==
'Dream.OperatorManagedJob'
:
id
=
element
.
get
(
'id'
,
'not found'
)
# get the id of the element / default 'not_found'
name
=
element
.
get
(
'name'
,
'not found'
)
# get the name of the element / default 'not_found'
...
...
dream/simulation/OperatorPreemptive.py
deleted
100644 → 0
View file @
01c103d8
# ===========================================================================
# Copyright 2013 University of Limerick
#
# This file is part of DREAM.
#
# DREAM is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# DREAM is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with DREAM. If not, see <http://www.gnu.org/licenses/>.
# ===========================================================================
'''
Created on 27 Jan 2014
@author: Ioannis
'''
'''
Inherits from Operator. When he gets called for an operation while he is busy,
he checks if the operation that calls him is of higher priority than the one
that he is currently in.
'''
from
Operator
import
Operator
# ===========================================================================
# Error in the setting up of the WIP
# ===========================================================================
class
NoCallerError
(
Exception
):
def
__init__
(
self
,
callerError
):
Exception
.
__init__
(
self
,
callerError
)
# ===========================================================================
# the resource that operates the machines
# ===========================================================================
class
OperatorPreemptive
(
Operator
):
# def __init__(self, id, name, capacity=1):
# Operator.__init__(self,id=id,name=name,capacity=capacity)
# self.type="OperatorPreemptive"
# =======================================================================
# Check if Operator Can perform a preemption
# =======================================================================
def
checkIfResourceCanPreempt
(
self
,
callerObject
=
None
):
# TODO: to discuss with George about the use of callerObject
activeResource
=
self
.
getResource
()
activeResourceQueue
=
self
.
getResourceQueue
()
# find out which station is requesting the operator?
thecaller
=
callerObject
# assert that the callerObject is not None
try
:
if
callerObject
:
thecaller
=
callerObject
else
:
raise
NoCallerError
(
'The caller must be defined for checkIfResourceCanPreempt'
)
except
NoCallerError
as
noCaller
:
print
'No caller error: {0}'
.
format
(
noCaller
)
# Otherwise check the operator has a reason to preempt the machine he is currently working on
# TODO: update the objects requesting the operator
requestingObject
=
thecaller
.
requestingObject
# TODO: update the last object calling the operatorPool
receivingObject
=
thecaller
.
receivingObject
# TODO: the entity that is requesting the operator
requestingEntity
=
receivingObject
.
requestingEntity
# if the operator is not occupied return True
if
len
(
activeResourceQueue
)
==
0
:
return
True
# read the station currently operated by the operator
# TODO: the victim of the operator is the Broker of the Machine. Modify to preempt the machine and not the broker
victim
=
activeResourceQueue
[
0
].
victim
# read its activeQ
victimQueue
=
victim
.
getActiveObjectQueue
()
requestingObjectQueue
=
requestingObject
.
getActiveObjectQueue
()
receivingObjectQueue
=
receivingObject
.
getActiveObjectQueue
()
#if the receiver is not empty and the caller is not empty
if
len
(
victimQueue
)
and
len
(
requestingObjectQueue
):
try
:
#if the Entity to be forwarded to the station currently processed by the operator is critical
if
requestingObjectQueue
[
0
].
isCritical
:
#if the receiver does not hold an Entity that is also critical
if
not
victimQueue
[
0
].
isCritical
and
not
receivingObjectQueue
[
0
].
isCritical
and
victim
.
Up
:
# then the receiver must be preemptied before it can receive any entities from the calerObject
victim
.
shouldPreempt
=
True
victim
.
preempt
()
victim
.
timeLastEntityEnded
=
self
.
env
.
now
#required to count blockage correctly in the preemptied station
return
True
# if the entity has no isCritical property then ran the default behaviour
except
:
pass
return
len
(
self
.
Res
.
activeQ
)
<
self
.
capacity
# =======================================================================
# override the default method so that Entities
# that are critical got served first
# TODO: NOT USED!
# =======================================================================
def
sortEntities
(
self
):
Operator
.
sortEntities
(
self
)
#do the default sorting first
activeObjectQ
=
self
.
activeCallersList
activeObjectQ
.
sort
(
key
=
lambda
x
:
x
.
identifyEntityToGet
().
isCritical
,
reverse
=
True
)
\ No newline at end of file
dream/simulation/imports.py
View file @
accfa6d6
...
...
@@ -72,7 +72,7 @@ from dream.simulation.OrderComponent import OrderComponent
from
dream.simulation.Repairman
import
Repairman
from
dream.simulation.OperatorPool
import
OperatorPool
from
dream.simulation.Operator
import
Operator
from
dream.simulation.OperatorPreemptive
import
OperatorPreemptive
#
from dream.simulation.OperatorPreemptive import OperatorPreemptive
#ObjectInterruption
from
dream.simulation.Failure
import
Failure
...
...
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