Hello! I'm having a problem with my chart data. I have a simulated tag which is a ramp up to 1.9M. When it resets to zero my chart data that time it becomes zero.
Here my Data in Power table:
Heres my chart:
Here's my code:
def dataDaily(self):
def sumOfList(list, size):
if (size == 0):
return 0
else:
return list[size - 1] + sumOfList(list, size - 1)
f = lambda x : x if x > 0 else 0
param2 = self.dateStt
param3 = self.dateEnd
window = system.gui.getWindow('Dashboard/Deep Well Summary/Deep Well Summary')
header1 = ['Label','Power']
header2 = ['Label','Water']
header3 = ['Label','Efficiency']
header4 = ['Label','Power','Water']
data1 = []
data2 = []
data3 = []
#Power
todayPower = system.tag.queryTagHistory(paths = ['[LIMA]'+ window.getRootContainer().locationPath + '/Power/rMains_KWH']
, startDate = self.dateStt
, endDate = system.date.addHours(param3, 2)
, returnFormat='Wide'
, aggregationMode = 'LastValue'
, columnNames = 'rMains_KWH'
,intervalHours = 1)
todayPower_tStamp = [todayPower.getValueAt(row,0) for row in range(todayPower.getRowCount())]
todayPower_Value = [todayPower.getValueAt(row,1) for row in range(todayPower.getRowCount())]
value1 = [j - i for i, j in zip(todayPower_Value[: -1], todayPower_Value[1 :])]
powerValue = [f(x) for x in value1]
sumValuePower = sumOfList(powerValue, len(powerValue))
window.getRootContainer().getComponent('Deep Well Summary').getComponent('Comparison Bar Chart').dataSetPower = system.dataset.toDataSet(header1,zip(todayPower_tStamp,powerValue))
#water
todayWater = system.tag.queryTagHistory(paths = ['[LIMA]'+ window.getRootContainer().locationPath + '/Process/rFlowrate']
, startDate = self.dateStt
, endDate = system.date.addHours(param3, 2)
, returnFormat='Wide'
, aggregationMode = 'LastValue'
, columnNames = 'rMains_KWH'
,intervalHours = 1)
todayWater_tStamp = [todayWater.getValueAt(row,0) for row in range(todayWater.getRowCount())]
todayWater_Value = [todayWater.getValueAt(row,1) for row in range(todayWater.getRowCount())]
value2 = [j - i for i, j in zip(todayWater_Value[: -1], todayWater_Value[1 :])]
waterValue = [f(x) for x in value2]
window.getRootContainer().getComponent('Deep Well Summary').getComponent('Comparison Bar Chart').dataSetWater = system.dataset.toDataSet(header2,zip(todayWater_tStamp,waterValue))
sumValueWater = sumOfList(waterValue, len(waterValue))
I want to fix it when my tag reaches its limit then resets it will still accumulate the data after it resets.