The relevant piece of my code looks like this:
const int WINCC_ERROR_CODE = -1; // return code from standard functions in case of error
const string MCO_ACT_DP_NAME = "Win.Msc.Mco.Act";
const string MCO_SCAN_DP_NAME = "TceProRolPurAct.Rol.Len";
const string WEI_SCAN_DP_NAME = "TceProRolPurAct.Rol.Wei";
const string DIA_ACT_DP_NAME = "RdhRol.Win.DiaAct";
const string DEN_ACT_DP_NAME = "RdhRol.Win.DenAct";
void ILM_CreateRollDataFile(string rollID, time timeStamp)
{
// indices of the dyn_dyn types below where dpGetPeriod puts that data
const int IDX_TIME = 1;
const int IDX_VALUE = 2;
dyn_dyn_anytype len, l_s, wei, dia, den;
// when calling dpGetPeriod() like this with the parameter "count" set to 1and the parameters "t1" and "t2" set to the same time, the first entry return will contain the actual value at timeStamp
int answer = dpGetPeriod(timeStamp, timeStamp, 1,
MCO_ACT_DP_NAME, len[IDX_VALUE], len[IDX_TIME],
MCO_SCAN_DP_NAME, l_s[IDX_VALUE], l_s[IDX_TIME],
WEI_SCAN_DP_NAME, wei[IDX_VALUE], wei[IDX_TIME],
DIA_ACT_DP_NAME, dia[IDX_VALUE], dia[IDX_TIME],
DEN_ACT_DP_NAME, den[IDX_VALUE], den[IDX_TIME]);
if (answer == WINCC_ERROR_CODE)
{
dyn_errClass err = getLastError();
throwError(err);
}
if ((len[IDX_VALUE][1] > l_s[IDX_VALUE][1]) && (l_s[IDX_VALUE][1] > 0)) // this is line 688, the place where the error below appears
{
wei[IDX_VALUE][1] = wei[IDX_VALUE][1] * len[IDX_VALUE][1] / l_s[IDX_VALUE][1];
}
and this is the error message that I get:
WCCOActrl (2), 2017.05.16 16:08:27.054, SYS, INFO, 1, Manager Start, PROJ, Sml, V 3.14 - 3.14 platform Linux x86_64 linked at Dec 6 2016 22:17:00
WCCOActrl (2), 2017.05.16 16:08:27.055, SYS, INFO, 3, Trying to connect to (SYS: 0 Data -num 0 CONN: 1) @ Sml:5801
WCCOActrl (2), 2017.05.16 16:08:27.055, SYS, INFO, 4, Connected to (SYS: 0 Data -num 0 CONN: 1) @ localhost (::1)
WCCOActrl (2), 2017.05.16 16:08:27.454, SYS, INFO, 6, Initialization by Data Manager finished
WCCOActrl (2), 2017.05.16 16:08:27.454, SYS, INFO, 3, Trying to connect to (SYS: 1 Event -num 0 CONN: 1) @ Sml:7801
WCCOActrl (2), 2017.05.16 16:08:27.455, SYS, INFO, 4, Connected to (SYS: 1 Event -num 0 CONN: 1) @ localhost (::1)
WCCOActrl (2), 2017.05.16 16:08:27.785, SYS, INFO, 102, Waiting for user names/passwords
WCCOActrl (2), 2017.05.16 16:08:27.788, SYS, INFO, 103, User names/passwords initialized
WCCOActrl (2), 2017.05.23 18:32:17.077, CTRL, SEVERE, 176, Uncaught exception in thread started at main:
WCCOActrl (2), 2017.05.23 18:32:17.055, CTRL, SEVERE, 79, Index out of range, ILM_PLC.ctl Line: 688, len, 1
Stacktrace:
1: ILM_CreateRollDataFile(string rollID = "A170523114326", time timeStamp = 2017.05.23 18:32:16.885) at ILM_PLC.ctl:688
2: ILM_ReadRoll(bool start = FALSE, time timeStamp = 2017.05.23 18:32:16.885) at ILM_PLC.ctl:618
3: ILM_ReadFromPlcSocket(int socket = 0) at ILM_PLC.ctl:520
4: main() at ILM_PLC.ctl:255
The code usually works without any problem, I only get the error sometimes.
The datapoints I am using all have the archive config set, otherwise I would never get any data.
I thought maybe the reason was that the data at the time "timeStamp" had not yet been written to the archives, so I tried forcing the timeStamp one day into the future.
Even in that case I always got at least one entry returned, which was the newest value written to the archive, so that ruled out that theory.
Any other ideas what could be causing the problem?
I know that I can catch these cases by checking if dynlen() of my data arrays is 0, but since this should never be happening, I don't really want to handle this case.
My call to dpGetPeriod() sometimes returns no data, even if its parameter \"count\" is set to 1. The function return status is OK and I get no error message in the log viewer. Can anyone explain why?
- RudiKreiner
- Posts:198
- Joined: Mon May 16, 2011 2:10 pm
My call to dpGetPeriod() sometimes returns no data, even if its parameter \"count\" is set to 1. The function return status is OK and I get no error message in the log viewer. Can anyone explain why?
- leoknipp
- Posts:2928
- Joined: Tue Aug 24, 2010 7:28 pm
Re: My call to dpGetPeriod() sometimes returns no data, even if its parameter \"count\" is set to 1. The function return status is OK and I get no error message in the log viewer. Can anyone explain why?
What is the use case of doing a dpGetPeriod() with the same start- and endtime?
If you want to know which value was valid for a specific time you can use dpGetAsynch().
Best Regards
Leopold Knipp
Senior Support Specialist
If you want to know which value was valid for a specific time you can use dpGetAsynch().
Best Regards
Leopold Knipp
Senior Support Specialist
- RudiKreiner
- Posts:198
- Joined: Mon May 16, 2011 2:10 pm
Re: My call to dpGetPeriod() sometimes returns no data, even if its parameter \"count\" is set to 1. The function return status is OK and I get no error message in the log viewer. Can anyone explain why?
Thanks for the info. You are right that using dpGetAsynch(), would give me the required information too,
as described in the help here:
Note that if there is no value available at the specified time, the value of the element that was last saved before the query time is returned.
The only advantage that I see in using dpGetPeriod() is that I could see how old the value is, it could be one second or one year old.
I'll have to decide whether I can live without that information.
as described in the help here:
Note that if there is no value available at the specified time, the value of the element that was last saved before the query time is returned.
The only advantage that I see in using dpGetPeriod() is that I could see how old the value is, it could be one second or one year old.
I'll have to decide whether I can live without that information.
- mkoller
- Posts:741
- Joined: Fri Sep 17, 2010 9:03 am
Re: My call to dpGetPeriod() sometimes returns no data, even if its parameter \"count\" is set to 1. The function return status is OK and I get no error message in the log viewer. Can anyone explain why?
Just also get the _stime attribute and you'll have the time
- RudiKreiner
- Posts:198
- Joined: Mon May 16, 2011 2:10 pm
Re: My call to dpGetPeriod() sometimes returns no data, even if its parameter \"count\" is set to 1. The function return status is OK and I get no error message in the log viewer. Can anyone explain why?
Perfect, thanks.