
adccommunitymod (AutomationDirect) asked a question.
Created Date: September 12,2015
Created By: GlennLee
**** This post has been imported from our legacy forum. Information in this post may be outdated and links contained in the post may no longer work.****
:confused: Gents! It is late on a Friday evening and I'm feeling particularly stupid:o. I have been trying to write values to the UDT0 Structure. I am parsing SCADA-supplied Date/Time into the individual data-points needed to set the individual segments of UDT0. I added a MATH statement to add 2000 to the 2-digit year. Example: MOVE V6052:B0 (the lower byte of a SCADA-Supplied Date-structure for DOW originally configured for a D2-260) to UDT0.DayOfWeek. I also tried to move a $NOW.DATE to D1 (Unused) and it displays a "15 ". The same with $NOW.TIME into D3. I was looking for a hint of the structure of the resulting data Also: It appears that I have to set UDT0.Year with the full 4 digits. Correct? I'll keep futzing with it but... (whimper):(
Created Date: September 12,2015
Created by: Do-more PE
Since your SCADA was originally configured for a 260, I would bet that it is handing out BCD numbers. Check your data types to be sure you are getting what you expect in the memory addresses. Do-more memory doesn't know what BCD is. There are multiple ways to convert to Signed integer, one of which is BCDTO.
Created Date: September 12,2015
Created by: GlennLee
That is what I get for working late: I missed an obvious possibility!
I will try it out and let you know tomorrow!
Thanks!
Created Date: September 12,2015
Created by: franji1
All DATETIME structures have the following fields:
.Year (WORD full value, e.g. 2015)
.Month (BYTE 1-12)
.Day (BYTE 1-31)
These 4 BYTEs also make up a composite member of a single DWORD value called .Date. Best to just utilize the individual fields.
.DayOfWeek (BYTE 0-Sunday 6-Saturday)
.Hour (BYTE 0-23)
.Minute (BYTE 0-59)
.Second (BYTE 0-59)
These 4 BYTEs also make up a different composite of a single DWORD value called .Time. Again, just utilize the individual fields.
Created Date: September 12,2015
Created by: GlennLee
DoMore Time-Setting
Thank you Franji1. Working on it this morning. Will update.
Created Date: September 12,2015
Created by: GlennLee
More about DoMore Time-setting
:)Progress!
I can now see that UDT0 has accepted my data. Whew! I have literally forgotten about BCD! (Thankfully)
Now, I try to use SETTIME to transfer my newly-minted UDT0...and failure.
I 've read the Help screens and scanned the forum but I think that this is another Brain-Fart: I am too close to the issue to see what I'm doing wrong.
In the same line that parses and converts the incoming BCD to UDT0.xxxxx, the last function is SETTIME. I can see that the format is correct...but no transfer.
I am watching $Now.Date and .Time but I am having no effect! I must appeal to your good natures and superior experience to once again guide me past this pot-hole in my understanding.;)
Created Date: September 12,2015
Created by: franji1
$Now.Date and .Time but I am having no effect! I must appeal to your good natures and superior experience to once again guide me past this pot-hole in my understanding.
Rather than look at the values in .Date and .Time, what do you see for
.Year
.Month
.Day
.DayOfWeek
.Hour
.Minute
.Second
You can enter just UDT0 in a cell in Data View, then hit Shift+Ctrl+Enter on that cell to expand out all these fields (this works on any structure BTW).
Created Date: September 12,2015
Created by: GlennLee
Fixed!
:)TADA! With your generous help, WE have solved the issue!
I used BCDTO:Bx to parse the data into each UDT0.xxxxxx part of the structure and THEN, for the .Year entry, I followed the BCDTO function with MATH:
UDT0.Year + 2000 With the destination as UDT0.Year!
Now the SETTIME function works great!:D
I can send the code snippet to anyone that requests it.
Created Date: September 12,2015
Created by: GlennLee
:confused: Gents! It is late on a Friday evening and I'm feeling particularly stupid:o.
I have been trying to write values to the UDT0 Structure.
I am parsing SCADA-supplied Date/Time into the individual data-points needed to set the individual segments of UDT0. I added a MATH statement to add 2000 to the 2-digit year.
Example: MOVE V6052:B0 (the lower byte of a SCADA-Supplied Date-structure for DOW originally configured for a D2-260) to UDT0.DayOfWeek.
I also tried to move a $NOW.DATE to D1 (Unused) and it displays a "15 ". The same with $NOW.TIME into D3. I was looking for a hint of the structure of the resulting data
Also: It appears that I have to set UDT0.Year with the full 4 digits. Correct?
I'll keep futzing with it but... (whimper):(