Export Fails


Sanchez

Recommended Posts

Hi Azeotech,

I have a strange problem with an Export. I have a sequence that adds data to several channels and then I call a export with those channels. This is the sequence that adds data:

if(!isempty(PLANT_KW_TON))
   ExportData1.AddValue(PLANT_KW_TON[0] / 100)
else
   ExportData1.AddValue(0)
endif

if(!isempty(CHLRCAPACITY))
   ExportData2.AddValue(CHLRCAPACITY[0])
else
   ExportData2.AddValue(0)
endif

if(!isempty(TOT_CHLR_KW))
   ExportData3.AddValue(TOT_CHLR_KW[0]/10)
else
   ExportData3.AddValue(0)
endif

if(!isempty(TOT_CHWPUMPS_KW))
   ExportData4.AddValue(TOT_CHWPUMPS_KW[0]/10)
else
   ExportData4.AddValue(0)
endif

if(!isempty(TOT_CDWPUMPS_KW))
   ExportData5.AddValue(TOT_CDWPUMPS_KW[0]/10)
else
   ExportData5.AddValue(0)
endif

if(!isempty(TOT_FANS_KW))
   ExportData6.AddValue(TOT_FANS_KW[0]/10)
else
   ExportData6.AddValue(0)
endif

if(!isempty(TOTKW))
   ExportData7.AddValue(TOTKW[0]/10)
else
   ExportData7.AddValue(0)
endif

if(!isempty(PERCENT_CAPACITY))
   ExportData8.AddValue(PERCENT_CAPACITY[0]/10)
else
   ExportData8.AddValue(0)
endif

if(!isempty(AVECHWKW))
   ExportData9.AddValue(AVECHWKW[0] / 10)
else
   ExportData9.AddValue(0)
endif

if(!isempty(B ))
   ExportData10.AddValue(B[0] / 100)
else
   ExportData10.AddValue(0)
endif

if(!isempty(A))
   ExportData11.AddValue(A[0] / 100)
else
   ExportData11.AddValue(0)
endif

if(!isempty(NOC))
   ExportData12.AddValue(NOC[0])
else
   ExportData12.AddValue(0)
endif

if(!isempty(DIFF_TEMPERATURE))
   ExportData13.AddValue(DIFF_TEMPERATURE[0] / 10)
else
   ExportData13.AddValue(0)
endif

then I call the Export like this:

ExportData13[0,8640]

In my computer it works fine, no problem, but I installed DAQFactory on a customers site and the export fails with the error:

"The channel doesn't have valid Values"

What can be causing this? Why it doesn't work on that particular PC? I am using DF V5.40 on both cases.

Thanks.

Link to comment
Share on other sites

BY doing this every 5 minutes:

if(!isempty(PLANT_KW_TON))
  ExportData1.AddValue(PLANT_KW_TON[0] / 100)
else
  ExportData1.AddValue(0)
endif

Am I not making sure there is data in the channels?

I already checked and all the channels in the export are being updated. I am not sure if that takes care of the timing too.

Thanks.

Link to comment
Share on other sites

It has to do with alignment. Depending on the export set settings, the data will be aligned so that it can be on consistent rows. The data is aligned to the first expression in the export set. The problem is that if there is no overlap in time between the first expression and one of the other expressions, you end up with no data in that expression and thus your error. This same thing can happen if your align threshold is too tight. I'm not saying this is the problem, but its a good start. Take a look at the details page of the export set and see what it says, maybe posting a screenshot.

Link to comment
Share on other sites

I'm not sure, but I would consider using the File. functions instead of the export set. This gives you total control. You'd have to combine your data into a single big array and then write it out using the file.writedelim() function. To combine the data, just create a loop (I'll assume you have 13 channels named exportdata0 to exportdata12):

private bigarray
bigarray[][0] = exportdata0.time[0,3600]
for (private x = 0, x < 13, x++)
   bigarray[][x+1] = evaluate("exportdata" + doubletostr(x) + "[0,3600]")
endfor
// at this point we have a big two dimensional array, with time in the first column, now write to file:
private handle = file.open("c:\myfile.csv",0,1,0,1)
file.writedelim(handle,bigarray,",",chr(10))
file.close(handle)

That's it. The first part puts all the data in a big block. The second part writes it to file using just three lines of script. The other advantage to this is that you can better format your data. For example, lets say you wanted to put your date in human readable format instead of raw DAQFactory time, and you want the first 6 channels to have 2 decimals, and the rest to have 1. First thing is that I make bigarray into a string array instead of just numbers, that way I can do the formatting. Then its basically the same thing:

private string bigarray
bigarray[][0] = formatdatetime("%c",exportdata0.time[0,3600])
for (private x = 0, x < 13, x++)
   bigarray[][x+1] = format("%." + iif(x < 6,"2","1") + "f", evaluate("exportdata" + doubletostr(x) + "[0,3600]")
endfor
// at this point we have a big two dimensional string array, with time in the first column, now write to file:
private handle = file.open("c:\myfile.csv",0,1,0,1)
file.writedelim(handle,bigarray,",",chr(10))
file.close(handle)

Basically I just added some formatting commands. Notice how I used the iif() function to do either "%.2f" or "%.1f" in the format depending on x. Of course you can use regular if statements too, but the inline if will process faster.

Link to comment
Share on other sites

  • 2 weeks later...

Hi,

When I created a log file with direct file functions, I still got an error. Somehow the channel didn't have any values which is weird because the same application has worked before. However, when generating the log from a sequence I got an Alert telling my exactly on which line the error was and therefore I knew which channel was giving problems. I crated a new channel with the same characteristics, replaced it and it worked.

Thanks

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.