Commit 68e334e6 authored by Georgios Dagkakis's avatar Georgios Dagkakis Committed by Jérome Perrin

Machine/QueuePreemptive added and also LineGenerationJSON updated so that it can read them

parent 9a458a97
...@@ -85,6 +85,7 @@ from OperatedMachine import OperatedMachine ...@@ -85,6 +85,7 @@ from OperatedMachine import OperatedMachine
from BatchDecompositionStartTime import BatchDecompositionStartTime from BatchDecompositionStartTime import BatchDecompositionStartTime
from M3 import M3 from M3 import M3
import ExcelHandler import ExcelHandler
import time import time
import json import json
...@@ -155,6 +156,8 @@ def createObjects(): ...@@ -155,6 +156,8 @@ def createObjects():
G.BrokersList = [] G.BrokersList = []
G.OperatedMachineList = [] G.OperatedMachineList = []
G.BatchScrapMachineList=[] G.BatchScrapMachineList=[]
G.MachinePreemptiveList=[]
G.QueuePreemptiveList=[]
# ----------------------------------------------------------------------- # -----------------------------------------------------------------------
# loop through all the model resources # loop through all the model resources
...@@ -360,6 +363,36 @@ def createObjects(): ...@@ -360,6 +363,36 @@ def createObjects():
G.MachineJobShopList.append(M) G.MachineJobShopList.append(M)
G.MachineList.append(M) G.MachineList.append(M)
G.ObjList.append(M) G.ObjList.append(M)
elif objClass=='Dream.MachinePreemptive':
from MachinePreemptive import MachinePreemptive
id=element.get('id', 'not found')
name=element.get('name', 'not found')
processingTime=element.get('processingTime',{})
distributionType=processingTime.get('distributionType', 'not found')
mean=float(processingTime.get('mean', '0'))
stdev=float(processingTime.get('stdev', '0'))
min=float(processingTime.get('min', '0'))
max=float(processingTime.get('max', '0'))
failures=element.get('failures', {})
failureDistribution=failures.get('failureDistribution', 'not found')
MTTF=float(failures.get('MTTF', '0'))
MTTR=float(failures.get('MTTR', '0'))
availability=float(failures.get('availability', '0'))
resetOnPreemption=bool(int(element.get('resetOnPreemption', '0')))
r='None'
for repairman in G.RepairmanList: # check which repairman in the G.RepairmanList
if(id in repairman.coreObjectIds): # (if any) is assigned to repair
r=repairman # the machine with ID equal to id
M=MachinePreemptive(id, name, 1, distribution=distributionType, failureDistribution=failureDistribution,
MTTF=MTTF, MTTR=MTTR, availability=availability, repairman=r,
mean=mean,stdev=stdev,min=min,max=max, resetOnPreemption=resetOnPreemption)
M.nextIds=getSuccessorList(id) # update the nextIDs list of the machine
G.MachinePreemptiveList.append(M) # add machine to global MachinePreemptiveList
G.MachineList.append(M) # add machine to global MachineList
G.ObjList.append(M) # add machine to ObjList
elif objClass=='Dream.Exit': elif objClass=='Dream.Exit':
id=element.get('id', 'not found') id=element.get('id', 'not found')
...@@ -399,6 +432,19 @@ def createObjects(): ...@@ -399,6 +432,19 @@ def createObjects():
G.QueueJobShopList.append(Q) G.QueueJobShopList.append(Q)
G.ObjList.append(Q) G.ObjList.append(Q)
elif objClass=='Dream.QueuePreemptive':
from QueuePreemptive import QueuePreemptive
id=element.get('id', 'not found')
name=element.get('name', 'not found')
capacity=int(element.get('capacity', '1'))
isDummy=bool(int(element.get('isDummy', '0')))
schedulingRule=element.get('schedulingRule', 'FIFO')
Q=QueuePreemptive(id, name, capacity, isDummy, schedulingRule=schedulingRule)
Q.nextIds=getSuccessorList(id)
G.QueueList.append(Q)
G.QueuePreemptiveList.append(Q)
G.ObjList.append(Q)
elif objClass=='Dream.QueueLIFO': elif objClass=='Dream.QueueLIFO':
id=element.get('id', 'not found') id=element.get('id', 'not found')
name=element.get('name', 'not found') name=element.get('name', 'not found')
......
# ===========================================================================
# 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 20 Dec 2012
@author: George
'''
'''
inherits from MachineJobShop it can preempt the currently processed Entity if need be
'''
from MachinePreemptive import MachinePreemptive
#the MachineJobShop object
class MachinePreemptive(MachineJobShop):
def __init__(self, id, name, capacity=1, distribution='Fixed', mean=1, stdev=0, min=0, max=10,\
failureDistribution='No', MTTF=0, MTTR=0, availability=0, repairman='None', resetOnPreemption=True):
MachineJobShop.__init__(self, id, name, capacity, distribution, mean, stdev, min, max,\
failureDistribution, MTTF, MTTR, availability, repairman)
self.shouldPreempt=False #flag that shows that the machine should preempt or not
self.resetOnPreemption=resetOnPreemption #flag that shows if the processing time should be reset or not
def initilize(self):
MachineJobShop.initialize(self)
self.shouldPreempt=False
#when interrupted call the preempt method
def interruptionAction(self):
self.preempt()
#method to execute the preemption
def preempt(self):
print 'in'
# ===========================================================================
# 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 20 Dec 2012
@author: George
'''
'''
Inherits from QueueJobShop. If it gets an isCritical Entity it can interrupt the destination station
'''
from QueueJobShop import QueueJobShop
#the QueuePreemptive object
class QueuePreemptive(QueueJobShop):
#extend he default so that it can interrupt the receiver if need be
def getEntity(self):
activeEntity=QueueJobShop.getEntity(self) #execute default behaviour
#if the obtained Entity is critical
if activeEntity.isCritical:
#if the receiver is not empty
if len(receiver.getActiveObjectQueue())>0:
#if the receiver does not hold an Entity that is also critical
if not receiver.getActiveObjectQueue()[0].isCritical:
receiver.shouldPreempt=True
receiver.interrupt() #interrupt the receiver
#for future use
def sortEntities(self):
QueueJobShop.sortEntities(self)
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment