def addTriggerCount(self, value=None, validFor=None):
     self.checkControlParametersTag()
     if type(value) == int:
         self.typeValueTC = "NumericParameter"
         self.triggerCountAttrib = {
             "value": str(value),
             "validFor": validFor
         }
         self.triggerCountAttrib = utility.filterNoneAttributes(
             self.triggerCountAttrib)
         if self.triggerCountPointer is None:
             self.triggerCountPointer = etree.SubElement(
                 self.controlPointer, utility.BPSIM + "TriggerCount")
         new_parameter = etree.SubElement(self.triggerCountPointer,
                                          utility.BPSIM + self.typeValueTC,
                                          attrib=self.triggerCountAttrib)
         utility.write_on_file(self.write, self.tree)
         utility.checkCalendar(self.scenario.getCalendars(), validFor,
                               self.verbosity)
         if self.verbosity == 0:
             print("INFO: TriggerCount added " + self.typeValueTC + " ",
                   self.triggerCountAttrib)
     else:
         raise ValueError(
             "ERROR: Type of TriggerCount is not correct, must be NumericParameter"
         )
Esempio n. 2
0
 def filterParameterAttributes(self, value, timeUnit, validFor):
     if timeUnit is not None:
         utility.checkTimeUnit(timeUnit)
     utility.checkCalendar(self.scenario.getCalendars(), validFor,
                           self.verbosity)
     value = str(value)
     attributes = attributes = {
         "value": value,
         "timeUnit": timeUnit,
         "validFor": validFor
     }
     return utility.filterNoneAttributes(attributes)
Esempio n. 3
0
	def setAvailability(self,value,validFor=None):
		if self.availabilityPointer is None:
			raise ValueError("ERROR: Availability not exist")
		if not super().checkBooleanParameter(value):
			raise ValueError("ERROR: Type of Availability is not correct, must be BooleanParameter")
		newAvailability=self.availabilityPointer.findall("./" + utility.BPSIM + 'BooleanParameter')
		newAvailability[-1].set('value',str(value))
		if validFor is not None:
			utility.checkCalendar(self.scenario.getCalendars(), validFor, self.verbosity)
			newAvailability[-1].set('validFor', validFor)
		utility.write_on_file(self.write, self.tree)
		if self.verbosity==0:
			print("INFO: Availability updated")
Esempio n. 4
0
	def addAvailability(self,value,validFor):
		self.checkResourceParametersTag()
		if super().checkBooleanParameter(value):
			typeValue = "BooleanParameter"
			utility.checkCalendar(self.scenario.getCalendars(), validFor, self.verbosity)
			self.availabilityAttrib = {"value": str(value), "validFor": validFor}
			self.availabilityAttrib = utility.filterNoneAttributes(self.availabilityAttrib)
			if self.availabilityPointer is None:
				self.availabilityPointer=etree.SubElement(self.resourcePointer, utility.BPSIM + "Availability")
			new_parameter= etree.SubElement(self.availabilityPointer, utility.BPSIM + typeValue, attrib=self.availabilityAttrib)
			utility.write_on_file(self.write, self.tree)
			if self.verbosity==0:
				print("INFO: Availability added " + typeValue, self.availabilityAttrib)
		else:
			raise ValueError("ERROR: Type of Availability is not correct, must be BooleanParameter")
 def setTriggerCount(self, value=None, validFor=None, result_request=None):
     if self.triggerCountPointer is None:
         raise ValueError("ERROR: TriggerCount not exist")
     if value is None and result_request is None:
         raise ValueError("ERROR: insert value or result_request")
     newTriggerCount = self.triggerCountPointer.findall("./" +
                                                        utility.BPSIM +
                                                        self.typeValueTC)
     if len(newTriggerCount) > 0:
         self.triggerCountPointer.remove(newTriggerCount[-1])
     if value is not None and result_request is None:
         if not super().checkNumericParameter(value):
             raise ValueError(
                 "ERROR: Type of TriggerCount is not correct, must be NumericParameter"
             )
         self.typeValueTC = "NumericParameter"
         newTriggerCount = etree.SubElement(self.triggerCountPointer,
                                            utility.BPSIM +
                                            "NumericParameter",
                                            attrib={'value': str(value)})
         if validFor is not None:
             utility.checkCalendar(self.scenario.getCalendars(), validFor,
                                   self.verbosity)
             newTriggerCount.set('validFor', validFor)
     elif value is None and result_request is not None:
         attributes = {'value': value, 'validFor': validFor}
         attributes = utility.filterNoneAttributes(attributes)
         if len(attributes) == 0:
             self.typeValueTC = "ResultRequest"
             request = etree.SubElement(self.triggerCountPointer,
                                        utility.BPSIM + "ResultRequest")
             request.text = result_request
         else:
             raise ValueError("ERROR: insert only result_request parameter")
     utility.write_on_file(self.write, self.tree)
     if self.verbosity == 0:
         print("INFO: TriggerCount updated")
Esempio n. 6
0
 def filterDistributionAttributes(self, timeUnit, nameDistribution, shape,
                                  scale, probability, trials, mean, k,
                                  standardDeviation, mode, min, max,
                                  discrete, points, validFor):
     self.checkNameDistribution(nameDistribution)
     utility.checkCalendar(self.scenario.getCalendars(), validFor,
                           self.verbosity)
     if nameDistribution == 'UserDistribution':
         attributes = {'discrete': discrete, 'points': points}
         attributes = utility.filterNoneAttributes(attributes)
         self.checkDistributionAttributes('UserDistribution', attributes)
         self.checkBooleanType(discrete, 'discrete')
     else:
         attributes = {
             'shape': shape,
             'scale': scale,
             'probability': probability,
             'trials': trials,
             'mean': mean,
             'k': k,
             'standardDeviation': standardDeviation,
             'mode': mode,
             'min': min,
             'max': max
         }
         attributes = utility.filterNoneAttributes(attributes)
         self.checkDistributionAttributes(nameDistribution, attributes)
         self.checkNumericDistributionAttributes(attributes)
     for key in list(attributes.keys()):
         attributes[key] = str(attributes[key])
     if timeUnit is not None:
         utility.checkTimeUnit(timeUnit)
         attributes['timeUnit'] = timeUnit
     if validFor is not None:
         attributes['validFor'] = validFor
     return attributes
Esempio n. 7
0
 def addCostParameter(self, value, validFor, resultRequest, pointer, name):
     attributes = None
     if value is None and validFor is None and resultRequest is not None:
         typeValue = "ResultRequest"
         new_parameter = etree.SubElement(pointer,
                                          utility.BPSIM + typeValue)
         new_parameter.text = resultRequest
     elif value is not None and resultRequest is None:
         typeValue = super().checkParameterType(value)
         if not super().checkNumericParameter(
                 value) and not super().checkFloatingParameter(value):
             raise ValueError(
                 'ERROR: type of ' + name +
                 ' must be NumericParameter or FloatingParameter')
         utility.checkCalendar(self.scenario.getCalendars(), validFor,
                               self.verbosity)
         attributes = {"value": str(value), "validFor": validFor}
         attributes = utility.filterNoneAttributes(attributes)
         new_parameter = etree.SubElement(pointer,
                                          utility.BPSIM + typeValue,
                                          attrib=attributes)
     else:
         raise ValueError('ERROR: insert only value or resultRequest')
     return typeValue, pointer, attributes