so the binding is on the “example” prop and is set to and expression of “now(60000)” then i use a script transform to get the dataset i want. it has a lot of other columns that aren’t used in the graph because the same dataset is used with other components.
basePath = self.custom.TagPath#system.tag.read("[default]LineTest/LineMori61/TagPath").value
endTime = system.date.midnight(value)
endTime = system.date.addHours(endTime,system.date.getHour24(value))
startTime = system.date.addDays(endTime,-1)
DBInfo = system.tag.queryTagHistory(paths=[basePath+"/dischargeCount",basePath+"/spoilageCount"], startDate=startTime, endDate=endTime, aggregationMode="Sum", returnFormat='Wide', columnNames=["t_stamp","Production","Spoilage"], intervalHours=1)
FaultInfo = system.tag.queryTagHistory(paths=[basePath+"/fault"], startDate=startTime, endDate=endTime, aggregationMode="DurationOn", returnFormat='Wide', columnNames=["t_stamp","Fault"], intervalHours=1)
RatedInfo = system.tag.queryTagHistory(paths=[basePath+"/rated_speed"], startDate=startTime, endDate=endTime, aggregationMode="Average", returnFormat='Wide', columnNames=["t_stamp","Rated"], intervalHours=1)
hours = []
faultDuration = []
ratedSpeed = []
for row in range(DBInfo.rowCount):
hour = system.date.getHour24(DBInfo.getValueAt(row,"t_stamp"))
hours.append(hour)
fault = FaultInfo.getValueAt(row,"Fault")
if fault == None:
fault = 0
faultDuration.append(fault)
rated = RatedInfo.getValueAt(row,"Rated")
if rated == None:
rated = 0
ratedSpeed.append(rated)
DBInfo = system.dataset.addColumn(DBInfo,1,hours,"Hour",int)
DBInfo = system.dataset.addColumn(DBInfo,4,faultDuration,"Faulted",int)
DBInfo = system.dataset.addColumn(DBInfo,5,ratedSpeed,"Rated Speed",float)
DBInfo = system.dataset.deleteRow(DBInfo,DBInfo.rowCount-1)
target = []
OEE_Q = []
OEE_A = []
OEE_P = []
OEE = []
for row in range(DBInfo.rowCount):
OEE_Temp = 1.00
hour = DBInfo.getValueAt(row,"Hour")
rated = DBInfo.getValueAt(row,"Rated Speed")
production = DBInfo.getValueAt(row,"Production")
spoilage = DBInfo.getValueAt(row,"Spoilage")
fault = DBInfo.getValueAt(row,"Faulted")
target.append(3600.00/rated)
if production == 0:
OEE_Q.append(1.00)
OEE_Temp = OEE_Temp*1.00
else:
OEE_Q.append(round(1.00 - spoilage/(production + spoilage),2))
OEE_Temp = OEE_Temp*round(1.00 - spoilage/(production + spoilage),2)
OEE_A.append(round((3600.00-fault)/3600.00,2))
OEE_Temp = OEE_Temp*round((3600.00-fault)/3600.00,2)
if target == 0:
OEE_P.append(1.00)
OEE_Temp = OEE_Temp*1.00
else:
OEE_P.append(round(production/(3600.00/rated),2))
OEE_Temp = OEE_Temp*round(production/(3600.00/rated),2)
OEE.append(OEE_Temp)
DBInfo = system.dataset.addColumn(DBInfo,6,target,"Target",float)
DBInfo = system.dataset.addColumn(DBInfo,7,OEE_Q,"Quality",float)
DBInfo = system.dataset.addColumn(DBInfo,8,OEE_A,"Availability",float)
DBInfo = system.dataset.addColumn(DBInfo,9,OEE_P,"Performance",float)
DBInfo = system.dataset.addColumn(DBInfo,10,OEE,"OEE",float)
return DBInfo
the reason i am using scripting to get tag history is because the tag path i am pulling isn’t in the tag browser and the history binding setting seemed to not like that.