Hi everyone! I am having trouble getting data to be properly written to a dataset. I am modifying a python script so that it can add a new device to a dataset. I know that the paths I have set to test are correct because the values are correct in the data. However for some reason the data for the new device, and only for the new device, is not making it all the way to the dataset. I have no idea why I would be able to get the correct data, but not be able to write it to the dataset. Can any of you help?
Here is the code:
lineups = [ '22A01','22A02','22A03','22A04','22A05','22A06','22A07','22A08','22B01','22B02','22B03','22B04','22B05','22B06','22B07', '22B08']
legend = {None: 'Unknown', 0: 'Unknown', 1: 'Fault', 2: 'Outage', 3: 'Comm Error', 4: 'Available', 5: 'Maintenance',
6: 'Curtailed'}
header = ['LU #',
'State',
'CON A/B Temp',
'CON C/D Temp',
'PCS Mods',
'kW',
'kVAR',
'Bus 1 SOC',
'Bus 2 SOC',
'Racks In Serv', #Column 9
'Bus 1 Racks',
'Bus 2 Racks',
'Bus 1 Volt',
'Bus 2 Volt',
'Partial Operation',
'SOC Override']
data = []
# Loop through all of the lineups and update the values in the tables
for lineup in lineups:
# Define the base path that all the other tags will read from
basePath = "LU{}".format(lineup)
# Define the paths
if lineup == '22B08':
paths = ["[default]" + basePath + "/LUX/PLC_Norm_State", # index 0
"[default]" + basePath + "/INVX/GRID_POWER_P", # index 1
"[default]" + basePath + "/INVX/GRID_POWER_Q", # index 2
"[default]" + basePath + "/BMS1/MBMU1/SERVICE_SOC", # index 3
"[default]" + basePath + "/BMS2/MBMU1/SERVICE_SOC", # index 4
"[default]" + basePath + "/BMS1/MBMU1/NUMBER_OF_HV_CONNECTED_SUBSYS", # index 5
"[default]" + basePath + "/BMS1/MBMU1/RACKS_TOTAL", # index 6
"[default]" + basePath + "/BMS2/MBMU_RACKS_IN_SERVICE", # index 7
"[default]" + basePath + "/BMS2/MBMU_RACKS_TOTAL", # index 8
"[default]" + basePath + "/BMS1/MBMU1/SYSTEM_VOLTAGE", # index 9
"[default]" + basePath + "/BMS2/MBMU_SYSTEM_VOLTAGE", # index 10
"[default]" + basePath + "/INVX/NUM_RUNNING_MODULES", # index 11
"[default]" + basePath + "/INVX/NUMBER_OF_MODULES", # index 12
"[default]" + basePath + "/BMS1/MBMU_TMS_NO1_ENVIRONMENT_TEMP_IN_CONT1", # index 13
"[default]" + basePath + "/BMS2/MBMU_TMS_NO2_ENVIRONMENT_TEMP_IN_CONT1", # index 14
"[default]" + basePath + "/LUX/PLC_HMI_Partial_Op_En", # index 15
"[default]" + basePath + "/LUX/PLC_HMI_SOC_Override", # index 16
"[default]" + basePath + "/BMS1/RACKS_IN_SERVICE_USING_FB_FROM_CONTACTORS", # index 17
"[default]" + basePath + "/BMS2/RACKS_IN_SERVICE_USING_FB_FROM_CONTACTORS"] # index 18
else :
paths = ["[default]" + basePath + "/LUX/PLC_Norm_State", # index 0
"[default]" + basePath + "/INVX/GRID_POWER_P", # index 1
"[default]" + basePath + "/INVX/GRID_POWER_Q", # index 2
"[default]" + basePath + "/BMS1/MBMU_SERVICE_SOC", # index 3
"[default]" + basePath + "/BMS2/MBMU_SERVICE_SOC", # index 4
"[default]" + basePath + "/BMS1/MBMU_RACKS_IN_SERVICE", # index 5
"[default]" + basePath + "/BMS1/MBMU_RACKS_TOTAL", # index 6
"[default]" + basePath + "/BMS2/MBMU_RACKS_IN_SERVICE", # index 7
"[default]" + basePath + "/BMS2/MBMU_RACKS_TOTAL", # index 8
"[default]" + basePath + "/BMS1/MBMU_SYSTEM_VOLTAGE", # index 9
"[default]" + basePath + "/BMS2/MBMU_SYSTEM_VOLTAGE", # index 10
"[default]" + basePath + "/INVX/NUM_RUNNING_MODULES", # index 11
"[default]" + basePath + "/INVX/NUMBER_OF_MODULES", # index 12
"[default]" + basePath + "/BMS1/MBMU_TMS_NO1_ENVIRONMENT_TEMP_IN_CONT1", # index 13
"[default]" + basePath + "/BMS2/MBMU_TMS_NO2_ENVIRONMENT_TEMP_IN_CONT1", # index 14
"[default]" + basePath + "/LUX/PLC_HMI_Partial_Op_En", # index 15
"[default]" + basePath + "/LUX/PLC_HMI_SOC_Override", # index 16
"[default]" + basePath + "/BMS1/RACKS_IN_SERVICE_USING_FB_FROM_CONTACTORS", # index 17
"[default]" + basePath + "/BMS2/RACKS_IN_SERVICE_USING_FB_FROM_CONTACTORS"] # index 18
# Get the most up to date tags to put in the dataset
vals = system.tag.readBlocking(paths)
print(vals)
temp1 = "{} / {}".format(vals[11].value, vals[12].value)
temp2 = "{} / {}".format(vals[5].value, vals[6].value)
temp3 = "{} / {}".format(vals[7].value, vals[8].value)
# RACKS_IN_SERVICE_USING_FB_FROM_CONTACTORS
try:
bms1Racks = int(vals[17].value)
except:
bms1Racks = 0
try:
bms2Racks = int(vals[18].value)
except:
bms2Racks = 0
racksInService = str(bms1Racks + bms2Racks) + " / 40"
data.append([basePath, legend[vals[0].value], vals[13].value, vals[14].value, temp1, vals[1].value, vals[2].value,
vals[3].value, vals[4].value, racksInService, temp2, temp3, vals[9].value, vals[10].value, vals[15].value,
vals[16].value])
set = system.dataset.toDataSet(header, data)
system.tag.write("[default]Site/lineupDataset_1A",set)
Here is the data from the new device:
['LU22B08', 'Unknown', None, None, 'None / None', None, None, None, None, '0 / 40', '1 / 1', 'None / None', u'1', None, None, None]]
The parts that I made into memory tags to test are the '1/1' and u'1'
As you can see from this screenshot. These values are not showing up in the data set while test values from other devices are. Can anyone help me figure out what is going on?