I want to assign a value to tag "Shift" based on another daytime tag "Prod_Datetime" from a past event and not the current time. The operator will enter the time to the prod_Datetime tag using a datetime input object. The goal is to autofill the shift value when the event occurred. Get a value of 1 for first shift between 6am and 2 pm. Get a value of 2 for second shift between 2pm and 10 pm. Get a value of 3 for third shift between 10pm and 6 am. I don’t fully understand syntax or scope yet.
Shift tag is Integer
Path [GSI_LabelPrinterControl]Lines/Line 5/LeakerData/Shift
Prod_DateTime is Datetime
Path is [GSI_LabelPrinterControl]Lines/Line 5/LeakerData/Prod_DateTime
Format is yyyy-MM-dd h:mm:ss aa can this be changed to 24hr?
I think suedo code would look something like this
ProdHour = getHour24([GSI_LabelPrinterControl]Lines/Line 5/LeakerData/Prod_DateTime.value)
Shift = [GSI_LabelPrinterControl]Lines/Line 5/LeakerData/Shift.value
if ProdHour >= 06:00:00 and ProdHour < 14:00:00 then Shift = 1
elseif eventTime >= 14:00:00 and eventTime < 22:00:00 then Shift = 2
else Shift = 3
Again, I’m not sure on the syntax here. Not sure where the script would go. Would it be at the shift tag? at the datetime input? There are so many ways this can go and I don't want to start bad habits while learning this platform.
Respectfully,
Anthony