-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsample1.txt
More file actions
87 lines (71 loc) · 3.17 KB
/
sample1.txt
File metadata and controls
87 lines (71 loc) · 3.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
If Me.bSCADAScriptsEnabled == True
And (me.WasteGrid.t_CellValueChanged > 0 or me.WasteGrid.t_Writeback > 0) then 'or Me.t_ValidateData.Start > 0) Then
dim i as integer;
dim PreviousStatus as string;
dim Status as String;
dim WasteCode as String;
dim bTriggerRefresh as Boolean;
dim bWasteQtyError as Boolean;
dim bLoadQtyError as Boolean;
dim Quantity as Double;
dim ConsumeQuantity as double;
dim AvailableConsumeQty as double;
if me.debug > 0 then logmessage("begin validate script");endif;
ConsumeQuantity = 0;
'AvailableConsumeQty = Round(MyContainer.Material.CurrentLoadQty, MyEngine.config. Places);
AvailableConsumeQty = Round(MyContainer.Material.CurrentLoadQty, MyContainer.MaxDecimalPlaces);
if me.debug > 0 then logmessage("AvailableConsumeQty : " + AvailableConsumeQty );endif;
For i = 1 to Me.WasteQty.Dimension1
If me.debug > 0 Then logmessage("Starting FOR LOOP: Waste Qty Dimensions = " + Me.WasteQty.Dimension1); EndIf;
{If Me.WasteCauseCode[i] == "" Then
Me.WasteQty[i] = 0;
Me.WasteStatus[i] = "";
EndIf;}
PreviousStatus = Me.WasteStatus[i];
'Quantity = Round(Me.WasteQty[i], MyEngine.config.MaxDecimalPlaces);
Quantity = Round(Me.WasteQty[i], MyContainer.MaxDecimalPlaces);
'logmessage("Quantity = " + Quantity); '***************
'Trigger a refresh if we have rounded the quantity entered;
If Quantity <> Me.WasteQty[i] Then
If me.debug > 0 Then logmessage("Quantity <> me.WasteQty[i]"); EndIf;
bTriggerRefresh = True;
Me.WasteQty[i] = Quantity;
Endif;
If Me.WasteCauseCode[i] <> "" Then
ConsumeQuantity = ConsumeQuantity + Quantity;
'logmessage("Consume Quantity = " + ConsumeQuantity);
EndIf;
'me.ManualConsume.ConsumeQty = ConsumeQuantity;
me.WasteGridTotalQty = ConsumeQuantity;
If Quantity > AvailableConsumeQty or Quantity < 0
or ( ConsumeQuantity > AvailableConsumeQty and Quantity <> 0 ) Then
logmessage("Status Error... ConsumeQty,AvailQty,Quantity: " + ConsumeQuantity + ", " + AvailableConsumeQty + ", " + Quantity);
Status = "Error";
bWasteQtyError = True;
ElseIf Quantity <> 0 and Me.WasteCauseCode[i] == "" Then
bWasteQtyError = True;
Status = "Error";
Else
Status = "";
Endif;
Me.WasteStatus[i] = Status;
If Status <> PreviousStatus Then
bTriggerRefresh = True;
Endif;
{If Quantity <> 0 and Me.WasteCauseCode[i] == "" Then
bWasteQtyError = True;
Endif;}
Next;
If me.bAutoCalcLoadQty == True Then
'Me.LoadQty = Round((AvailableConsumeQty - ConsumeQuantity), MyEngine.config.MaxDecimalPlaces);
Me.LoadQty = Round((AvailableConsumeQty - ConsumeQuantity), MyContainer.MaxDecimalPlaces);
Me.bLoadQtyAutoUpdated = True;
Elseif me.bAutoCalcLoadQty == False Then
'Me.LoadQty = Round(Me.LoadQty, MyEngine.config.MaxDecimalPlaces);
Me.LoadQty = Round(Me.LoadQty, MyContainer.MaxDecimalPlaces);
Endif;
If Me.LoadQty < 0 or Me.LoadQty > Round((AvailableConsumeQty - ConsumeQuantity), MyContainer.MaxDecimalPlaces) Then
Me.bLoadQtyError = True;
Else
Me.bLoadQtyError = False;
Endif;