# This script consists of one object and several methods, the use of these methods allow the integration of the KE tool and Simul8 simulation software.
# By using this script the KE tool integrates with Simul8 accessing the XML of one model and modifying several info based on the available data
fromxml.etreeimportElementTreeaset
# The Distributions object
classSimul8Output:
defSimul8Dist(self,dist):#Using this method the statistical distributions from the DistributionFitting objects translated to meaningful info for the Simul8 package
self.sim8Dist=[]
ifdist['distributionType']=='Normal':
self.sim8Dist.insert(0,'3')
self.sim8Dist.insert(1,dist['mean'])
self.sim8Dist.insert(2,dist['stdev'])
elifdist['distributionType']=='Exp':
self.sim8Dist.insert(0,'7')
self.sim8Dist.insert(1,dist['mean'])
elifdist['distributionType']=='Lognormal':
self.sim8Dist.insert(0,'9')
self.sim8Dist.insert(1,dist['logmean'])
self.sim8Dist.insert(2,dist['logsd'],)
elifdist['distributionType']=='Weibull':
self.sim8Dist.insert(0,'10')
self.sim8Dist.insert(1,dist['shape'])
self.sim8Dist.insert(2,dist['scale'])
elifdist['distributionType']=='Gamma':
self.sim8Dist.insert(0,'11')
self.sim8Dist.insert(1,dist['shape'])
rate=1.0/dist['scale']
self.sim8Dist.insert(2,rate)
elifdist['distributionType']=='Poisson':
self.sim8Dist.insert(0,'17')
self.sim8Dist.insert(1,dist['lambda'])
elifdist['distributionType']=='NegativeBinomial':
self.sim8Dist.insert(0,'18')
self.sim8Dist.insert(1,dist['size'])
self.sim8Dist.insert(2,dist['mu'])
elifdist['distributionType']=='Geometric':
self.sim8Dist.insert(0,'20')
self.sim8Dist.insert(1,dist['probability'])
returnself.sim8Dist
defTitle(self,tree,title):# Calling this method, the user can modify the title of the simulation model, as arguments are given the tree, which is the XML file after parsing, and the proposed title
defResultsPeriod(self,tree,collectPreiod):# Calling this method, the user can modify the ResultsCollectionPeriod of the simulation model, as arguments are given the tree, which is the XML file after parsing, and the simulation time
defInterArrivalTime(self,tree,name,dist):# A method to define the Interarrival times of the start point item or source, the Simul8Dist method called in this method
defProcTimes(self,tree,name,dist):# Another method to modify the processing times of the Activities or stations, using this method the user exports the outcome of the KE tool distribution fitting into the simul8 XML
defMTTR(self,tree,name,dist):# Similar to the MTBF method, the MTTR (Mean Time To Repair) to export the results from the KE tool distribution fitting process
defQueueCap(self,tree,name,cap):#By calling this method the user is able to modify the capacity of Queues in the simulation object, as arguments the user should give the tree and the number of the capacity