Repository navigation
Expand file tree
/
Copy pathBulkLoader.src
More file actions
2041 lines (1452 loc) · 47.6 KB
/
Copy pathBulkLoader.src
File metadata and controls
2041 lines (1452 loc) · 47.6 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
program BulkLoader;
#include import.iri
----------------------------------------------------------------------------
-- Begin constants and aliases definitions here.
g_csProgName : constant string := " BulkLoader";
g_csVersion : constant string := "2.01";
-- End of constants and aliases.
----------------------------------------------------------------------------
----------------------------------------------------------------------------
-- Begin user created types (enumerations, records, arrays) definitions.
type BatchStatusType is (Idle,ReadyToBatch,Paused,Batching,Done);
type integerarray is array[50] of integer;
type stringarray is array[20] of string;
type stringarray1 is array[50] of string;
type realarray is array[20] of real;
type realarray1 is array[50] of real;
-- End of user created types (enumerations, records, arrays).
----------------------------------------------------------------------------
----------------------------------------------------------------------------
-- Start global variables definitions here. Don't forget to initialize
-- them in the system startup event handler.
g_Startup : integer;
g_BatchStatus : BatchStatusType :=Idle;
g_BatchTarget : stored real ;
g_iBuild : integer;
g_srcResult : SysCode;
g_DraftsSoFar : integer ;
g_BatchedSoFar : real :=0;
g_FinalDraft : real :=0;
-- Config Values
g_DefaultDraft : real :=0;
g_Header1 : string;
g_Header2 : string;
g_DraftMin : real :=0;
g_DraftMax : real :=0;
g_SettleTime : integer;
g_EmptyScale : real :=0;
g_PreAct : real :=0;
-- Jobs List
g_JobNumber : integerarray;
g_CarNumber : stringarray1;
g_Commodity : stringarray1;
g_Target : realarray1;
g_Draft : realarray1;
-- Commodity List
g_NumberofCommodities : integer;
g_CommodityName : stringarray;
g_CommodityPreAct : realarray;
-- Transaction Values
g_CurrentTransaction : integer;
g_CurrentJob : integer;
g_TranCarNumber : string;
g_DraftTarget : real;
g_PreActTarget : real;
g_TranCommodity : string;
-- Current Scale Values
g_NumberofJobs :integer;
g_iScreenPosition :integer;
g_iUserSelection :integer;
g_Gross : real :=0;
g_Tare : real :=0;
g_ScaleCheck : integer;
-- End of global variables.
----------------------------------------------------------------------------
----------------------------------------------------------------------------
-- Start functions and procedures definitions here.
----------------------------------------------------------------------------
-- Function Name : MakeVersionString
-- Created by : Company Name or Programmer Name
-- Last modified on : Jan 10, 2002
-- Purpose : This function will format the version and build into
-- a string and return the string.
-- Value Parameters : none
-- Variable Params : none
-- Return Parameter : a string representation of the version and build in
-- the format xx.xx.xx
-- Side Effects : none
----------------------------------------------------------------------------
function MakeVersionString : string;
sTemp : string;
begin
if g_iBuild > 9 then
sTemp := ("Ver " + g_csVersion + "." + IntegerToString(g_iBuild, 2));
else
sTemp := ("Ver " + g_csVersion + ".0" + IntegerToString(g_iBuild, 1));
end if;
return sTemp;
end;
----------------------------------------------------------------------------
-- Procedure Name : DisplayVersion
-- Created by : Company Name or Programmer Name
-- Last modified on : Jan 15, 2002
-- Purpose : This procedure will diplay the program name and
-- version number to the diplay.
-- Value Parameters : none
-- Variable Params : none
-- Side Effects : The program name and version is put on the display.
----------------------------------------------------------------------------
procedure DisplayVersion;
begin
DisplayStatus(g_csProgName + " - 021915");
end;
procedure Load_Commodities;
--Declaration Section
ComodityDb : ComodityDatabase;
DisplayText : string;
begin
g_NumberofCommodities:=0;
if ComodityDb.GetFirst<>SysOk then
ComodityDb.Name:="Misc.";
ComodityDb.PreAct:=100;
ComodityDb.Clear;
if ComodityDb.Add<>SysOk then
DisplayText:="Error Writing to DataBase call (208)344-8644";
DisplayStatus("Press Enter to Confirm");
PromptUser("This Error:");
else
DisplayText:="Creating Commodity DB";
end if;
if g_Startup = 1 then
SetLabelText(lbl5s9,DisplayText);
else
SetLabelText(lbl15s1,DisplayText);
end if;
else
ComodityDb.Sort(1);
ComodityDb.GetFirst;
while g_NumberofCommodities < 21
loop
g_NumberofCommodities := g_NumberofCommodities+1;
g_CommodityName[g_NumberofCommodities] := ComodityDb.Name;
g_CommodityPreAct[g_NumberofCommodities] := ComodityDb.PreAct;
if g_Startup=1 then
SetLabelText(lbl5s9,"Loading Commodities "+IntegerToString(g_NumberofCommodities,2));
else
SetLabelText(lbl15s1,"Loading Commodities "+IntegerToString(g_NumberofCommodities,2));
end if;
if ComodityDb.GetNext<>SysOk then
exit;
end if;
end loop;
end if;
StartTimer(12);
return;
end;
procedure Save_Config;
--Declaration Section
DbConfig : ConfigDatabase;
DisplayText : string;
ErrorCode : integer;
begin
if DbConfig.GetFirst<>SysOk then
DisplayText:="Error Accessing Config DB call (208)344-8644";
Errorcode:=1;
else
DbConfig.Draft:=g_DefaultDraft;
DbConfig.Header1:=g_Header1;
DbConfig.Header2:=g_Header2;
DbConfig.DrMin:=g_DraftMin;
DbConfig.DrMax:=g_DraftMax;
DbConfig.Settle:=g_SettleTime;
DbConfig.Empty:=g_EmptyScale;
SetSPValue(11,g_SettleTime);
SetSPValue(13,g_SettleTime);
SetSPValue(15,g_EmptyScale);
SetSPValue(16,g_SettleTime);
if DbConfig.Update <> SysOk then
DisplayText:="Error Updating Config call (208)344-8644";
Errorcode:=1;
else
DisplayText:="Saving Config Values";
end if;
end if;
SetLabelText(lbl9s3,DisplayText);
g_ScaleCheck:=9;
if ErrorCode = 1 then
DisplayStatus("Press Enter To Confirm");
PromptUser("This Error:");
end if;
StartTimer(12);
return;
end;
procedure DeleteJob;
--Declaration Section
JobsDb : JobsDatabase;
begin
JobsDb.CarNum:=g_CarNumber[g_iUserSelection];
if JobsDb.FindFirst(2) = SysOk then
JobsDb.Delete;
end if;
return;
end;
procedure Load_Config;
--Declaration Section
DbConfig : ConfigDatabase;
DisplayText : string;
ErrorCode : integer;
begin
if DbConfig.GetFirst<>SysOk then
DbConfig.Draft:=5015;
DbConfig.Header1:="Company Name";
DbConfig.Header2:="Company Address";
DbConfig.DrMin:=100;
DbConfig.DrMax:=6000;
DbConfig.Settle:=60;
DbConfig.Empty:=50;
DbConfig.PreAct:=250;
DbConfig.Clear;
if DbConfig.Add<>SysOk then
DisplayText:="Error Creating Config DB call (208)344-8644";
Errorcode:=1;
else
DisplayText:="Creating Config DB with preset values";
end if;
else
DisplayText:="Loading Config DB values";
end if;
g_DefaultDraft := DbConfig.Draft;
g_Header1 := DbConfig.Header1;
g_Header2 := DbConfig.Header2;
g_DraftMin := DbConfig.DrMin;
g_DraftMax := DbConfig.DrMax;
g_SettleTime := DbConfig.Settle;
g_EmptyScale := DbConfig.Empty;
g_PreAct := DbConfig.PreAct;
-- Update Settle Time and Empty Scale Values into Set Points.
SetSPValue(11,g_SettleTime);
SetSPValue(13,g_SettleTime);
SetSPValue(15,g_EmptyScale);
SetSPValue(16,g_SettleTime);
if g_Startup = 0 then
SetLabelText(lbl5s9,DisplayText);
else
SetLabelText(lbl15s1,DisplayText);
end if;
if ErrorCode = 1 then
DisplayStatus("Press Enter To Confirm");
PromptUser("This Error:");
else
StartTimer(12);
end if;
return;
end;
procedure MainScreen;
--Declaration Section
DraftWt:real;
EstDrafts: integer;
Net : real;
begin
EnableHandler(Numerickeypressed);
SelectScreen(1);
if g_BatchStatus=Idle then
SetSoftkeyText(1,"Start Batch");
SetSoftkeyText(2,"");
elsif g_BatchStatus=Batching then
SetSoftkeyText(1,"Finish Batch");
SetSoftkeyText(2,"");
elsif g_BatchStatus=Paused then
SetSoftkeyText(1,"Resume Batch");
SetSoftkeyText(2,"");
end if;
SetSoftkeyText(3,"Jobs Menu");
SetSoftkeyText(4,"Quick Fill");
SetSoftkeyText(5,"Setup");
Net:=G_Gross-G_Tare;
if g_BatchTarget > 0 and g_DraftTarget > 0 then
EstDrafts:=g_BatchTarget/g_DraftTarget+1;
else
EstDrafts:=0;
end if;
SetLabelText(lbl1S1,RealToString(g_BatchTarget,4,0));
SetLabelText(lbl4S1,IntegerToString(EstDrafts,0));
SetLabelText(lbl5S1,IntegerToString(g_DraftsSoFar,0));
SetLabelText(lbl10S1,RealToString(g_BatchedSoFar,6,0));
SetLabelText(lbl20s1,IntegerToString(g_CurrentJob,0));
SetLabelText(lbl22s1,g_TranCarNumber);
SetLabelText(lbl6s1,"Commodity"); -- Change this to actual Commodity when code is created.
return;
end;
procedure Start_Batching;
--Declaration Section
StatusDb : StatusDatabase;
begin
-- Check for database. If empty clear and add a record.
if StatusDb.GetFirst<>SysOk then
StatusDb.Trans:=0;
StatusDb.LastFill:=SystemTime;
StatusDb.Job:=0;
StatusDb.Clear;
StatusDb.Add;
SetLabelText(Lbl15S1,"Creating Database...");
StartTimer(12);
end if;
-- If the current date doesn't match the date of the last ticket
-- then reset the job number to 0
if Date$(StatusDb.LastFill)<>Date$(SystemTime) then
StatusDb.Job:=0;
StatusDb.Update;
end if;
StatusDb.Job:=StatusDb.Job+1;
StatusDb.Trans:=StatusDb.Trans+1;
g_CurrentJob:=StatusDb.Job;
g_CurrentTransaction:=StatusDb.Trans;
StatusDb.Update;
g_FinalDraft:=0;
g_ScaleCheck:=0;
g_BatchStatus:=Batching;
g_BatchedSoFar:=0;
g_DraftsSoFar:=0;
g_Gross :=0;
g_Tare:=0;
StartTimer(7);
-- Print AuxFmt1 Ticket
SetPrintText(1,IntegerToString(g_CurrentTransaction,0));
SetPrintText(7,IntegerToString(g_CurrentJob,0));
SetPrintText(2,g_TranCarNumber);
SetPrintText(3,RealToString(g_BatchTarget,6,0));
Print(AuxFmt1);
SetBatchingMode(Auto);
SetTimerMode(10,TimerOneShot);
SetTimer(10,100);
StartTimer(10);
SetDigout(2,3,0);
MainScreen;
SetLabelText(Lbl15S1,"Closing Dump Gate");
return;
end;
procedure CheckForZero;
--Declaration Section
CurWt : real;
begin
g_Startup:=5;
GetGross(1,Primary,CurWt);
if CurWt <= g_EmptyScale then
Start_Batching;
else
SetLabelText(lbl15s1,"Scale will not settle. Proceed Anyway?");
SetSoftkeyText(1,"Yes");
SetSoftkeyText(2,"No");
end if;
return;
end;
procedure Check_Motion;
--Declaration Section
motion : integer;
begin
SetSoftkeyText(1,"");
SetSoftkeyText(2,"");
SetSoftkeyText(3,"");
SetSoftkeyText(4,"");
SetSoftkeyText(5,"");
g_ScaleCheck:=0;
g_Startup:=4;
StartTimer(13);
SetLabelText(lbl15s1,"Waiting for scale to settle");
while motion <> 0 and g_ScaleCheck < 3
loop
InMotion(1,motion);
if g_ScaleCheck = 1 then
SetLabelText(lbl15s1,"Scale is in motion. Rechecking.");
g_ScaleCheck:=2;
StartTimer(13);
end if;
end loop;
StopTimer(13);
if g_ScaleCheck = 3 then
SetLabelText(lbl15s1,"Scale will not settle. Proceed Anyway?");
SetSoftkeyText(1,"Yes");
SetSoftkeyText(2,"No");
else
g_ScaleCheck:=0;
CheckForZero;
end if;
return;
end;
procedure PrintDraft;
--Declaration Section
Net : real ;
begin
Net:=g_Gross-g_Tare;
--WriteLn(2,IntegerToString(g_DraftsSoFar,4)," DRAFT NET "+IntegerToString(Net,5)+ "LB");
SetPrintText(4,RealToString(Net,4,0));
SetPrintText(5,RealToString(g_BatchedSoFar,6,0));
Print(AuxFmt2);
return;
end;
procedure Batch_Is_Done;
--Declaration Section
begin
g_BatchStatus:=Idle;
g_CurrentJob:=0;
SetPrintText(6,RealToString(g_BatchedSoFar,6,0));
Print(AuxFmt3);
--WriteLn(2, "END DATE "+Date$(SystemTime)+" "+Time$(SystemTime));
--WriteLn(2,"TOTAL NET WEIGHT "+RealToString(g_BatchedSoFar,0));
SetLabelText(Lbl15S1,"Batch Done");
StopTimer(7);
g_Startup:=2;
MainScreen;
return;
end;
procedure StopAuger;
--Declaration Section
begin
SetDigout(2,1,0);
DisplayStatus("Stopping Auger");
SetTimerMode(1,TimerOneShot);
SetTimer(1,50);
StartTimer(1);
return;
end;
procedure StartAuger;
--Declaration Section
begin
SetDigout(2,1,1);
DisplayStatus("Starting Auger");
SetTimer(1,50);
StartTimer(1);
return;
end;
procedure FinishBatch;
--Declaration Section
g_Fill:integer;
g_Dump : integer;
begin
StopBatch;
ResetBatch;
SetBatchingMode(Off);
StopAuger;
g_BatchStatus:=Idle;
SetBargraphLevel(Bar1S1,1);
SetBargraphLevel(Bar2s1,1);
if g_Startup = 11 then
DeleteJob;
end if;
SetDigout(2,2,0);
SetDigout(2,3,0);
SetTimer(2,300);
SetTimerMode(2,TimerOneShot);
StartTimer(2);
SetLabelText(Lbl15S1,"Finishing Batch");
if g_Startup = 7 then
Load_Config;
end if;
return;
end;
procedure RunBatch;
--Declaration Section
DraftWt : real;
WhatsLeft : real;
StopAugerTarget : real;
MinDraft : real;
Preact : real;
CurWt : real;
begin
GetGross(1,Primary,CurWt);
g_Tare:=CurWt;
if g_BatchStatus=Batching then
StartAuger;
ResetBatch;
--GetSPValue(1,DraftWt);
--GetSPValue(5,Preact);
--GetSPValue(2,StopAugerTarget);
--GetSPValue(3,MinDraft);
--DraftWt:=DraftWt-Preact;
--if WhatsLeft<=StopAugerTarget then
-- StopAuger;
--end if;
--if WhatsLeft<DraftWt then
-- DraftWt:= WhatsLeft;
--end if;
if g_FinalDraft > 0 then
g_FinalDraft:=g_FinalDraft+1;
else
DraftWt:=g_DraftTarget;
end if;
Preact:=g_PreActTarget;
WhatsLeft:=g_BatchTarget-g_BatchedSoFar;
if g_FinalDraft = 0 and WhatsLeft < g_DraftTarget*2 then
DraftWt:=WhatsLeft/2;
g_FinalDraft:=1;
elsif g_FinalDraft = 2 then
DraftWt:=WhatsLeft;
end if;
-- Set the Setpoint for Draft Target
SetLabelText(lbl16s1,RealToString(DraftWt,4,0));
SetSPValue(12,DraftWt-g_Preact+g_Tare);
GetSPValue(12,DraftWt);
SetLabelText(CutOff,RealToString(DraftWt,4,0));
SetLabelText(lbl14s1,"");
SetLabelText(Lbl15S1,"Opening Fill Gate");
StartBatch;
if g_FinalDraft = 3 then
FinishBatch;
end if;
MainScreen;
end if;
return;
end;
procedure SwitchBit(Bit : integer);
--Declaration Section
State : integer;
begin
GetDigout(2,Bit,State);
if State=1 then
State:=0;
else
State:=1;
end if;
SetDigout(2,Bit,State);
DisplayStatus("Output "+IntegerToString(Bit,0)+"="+IntegerToString(State,0));
return;
end;
procedure Load_Jobs;
--Declaration Section
JobsDb : JobsDatabase;
StatusDb : StatusDatabase;
jobcount : integer;
iCounter : integer;
begin
g_NumberofJobs:=0;
-- Clear Arrays
for iCounter:=1 to 50
loop
g_JobNumber[iCounter]:=0;
g_CarNumber[iCounter]:="";
-- g_Commodity[iCounter]:=""
g_Target[iCounter]:=0;
g_Draft[iCounter]:=0;
end loop;
-- Load Jobs
if JobsDb.GetFirst=SysOk then
jobcount:=1;
loop
g_JobNumber[jobcount]:=JobsDb.Job;
g_CarNumber[jobcount]:=JobsDb.CarNum;
-- g_Commodity[jobcount]:=JobsDb.Comodity
g_Target[jobcount]:=JobsDb.Target;
g_Draft[jobcount]:=JobsDb.Draft;
if JobsDb.GetNext <> SysOk then
exit;
else
jobcount:=jobcount+1;
end if;
end loop;
g_NumberofJobs:=jobcount;
end if;
return;
end;
procedure Display_Setup;
--Declaration Section
iCounter : integer;
begin
for iCounter:=76 to 82
loop
SetWidgetVisibility(iCounter,VOn);
end loop;
SelectScreen(3);
SetLabelText(lbl1s3,"Config Menu");
SetLabelText(lbl2s3,"Default Draft:");
SetLabelText(lbl10s3,RealToString(g_DefaultDraft,4,0));
SetLabelText(lbl3s3,"Default CutOff:");
SetLabelText(lbl11s3,realtostring(g_PreAct,4,0));
SetLabelText(lbl4s3,"");
SetLabelText(lbl12s3,"");
SetLabelText(lbl5s3,"Min Draft:");
SetLabelText(lbl13s3,RealToString(g_DraftMin,4,0));
SetLabelText(lbl6s3,"Max Draft:");
SetLabelText(lbl14s3,RealToString(g_DraftMax,4,0));
SetLabelText(lbl7s3,"Settling Val");
SetLabelText(lbl15s3,IntegerToString(g_SettleTime,0));
SetLabelText(lbl8s3,"Empty Level:");
SetLabelText(lbl16s3,RealToString(g_EmptyScale,4,0));
SetLabelText(lbl9s3,"Press the Number of the Entry to Change");
SetSoftkeyText(1,"");
SetSoftkeyText(2,"Save & Exit");
SetSoftkeyText(3,"");
SetSoftkeyText(4,"");
SetSoftkeyText(5,"");
return;
end;
procedure DisplayJobs;
--Declaration Section
iCounter : integer;
CurrentPosition : integer;
begin
-- g_Startup 11 User starting batch and needs to select a job
-- g_Startup 12 User entering job menu and wants to add / edit jobs
Load_Jobs;
SelectScreen(2);
SetLabelText(lbl1s2,"Jobs Menu "+IntegerToString(g_NumberofJobs,2));
SetLabelText(lbl9s2,"Car ID");
SetLabelText(lbl15s2,"Target");
SetLabelText(lbl21s2,"Draft");
if g_iScreenPosition < 1 then
g_iScreenPosition:=1;
end if;
if g_iUserSelection < 1 then
g_iUserSelection:=1;
end if;
if g_NumberofJobs > 0 then
for iCounter:=0 to 4 -- References where on screen to display row data
loop
CurrentPosition:=iCounter+g_iScreenPosition; -- References which row data to display
--WriteLn(2,"Screen Pos= "+IntegerToString(g_iScreenPosition,2));
--WriteLn(2,"Counter = "+IntegerToString(iCounter,2));
--WriteLn(2,"User Sel = "+IntegerToString(g_iUserSelection,2));
--WriteLn(2,"Current P = "+IntegerToString(CurrentPosition,2));
if CurrentPosition < g_NumberofJobs+1 then
SetLabelText(26+iCounter,g_CarNumber[CurrentPosition]);
-- g_Commodity[CurrentPosition]:=""
SetLabelText(32+iCounter,RealToString(g_Target[CurrentPosition],6,0));
SetLabelText(38+iCounter,RealToString(g_Draft[CurrentPosition],4,0));
if CurrentPosition = g_iUserSelection then
SetWidgetVisibility(19+iCounter,VOn);
SetWidgetVisibility(43+iCounter,VOn);
else
SetWidgetVisibility(19+iCounter,VOff);
SetWidgetVisibility(43+iCounter,VOff);
end if;
else
SetLabelText(26+iCounter,"");
-- g_Commodity[CurrentPosition]:=""
SetLabelText(32+iCounter,"");
SetLabelText(38+iCounter,"");
SetWidgetVisibility(19+iCounter,VOff);
SetWidgetVisibility(43+iCounter,VOff);
end if;
end loop;
if g_Startup = 12 then
SetSoftkeyText(2,"Edit Job");
SetSoftkeyText(3,"Delete Job");
else
SetSoftkeyText(2,"");
SetSoftkeyText(3,"");
end if;
else
for iCounter:=1 to 5
loop
SetLabelText(25+iCounter,"");
-- g_Commodity[CurrentPosition]:=""
SetLabelText(31+iCounter,"");
SetLabelText(37+iCounter,"");
SetWidgetVisibility(18+iCounter,VOff);
SetWidgetVisibility(42+iCounter,VOff);
end loop;
SetLabelText(27,"No Jobs in");
SetLabelText(33,"Database");
SetSoftkeyText(2,"");
SetSoftkeyText(3,"");
end if;
if g_Startup = 12 then
SetSoftkeyText(1,"Add Job");
else
SetSoftkeyText(1,"");
end if;
SetSoftkeyText(4,"");
SetSoftkeyText(5,"Main Menu");
return;
end;
procedure Save_Job;
--Declaration Section
JobsDb : JobsDatabase;
begin
if g_ScaleCheck < 10 then
JobsDb.CarNum:=g_TranCarNumber;
--JobsDb.Comodity:=g_Commodity;
JobsDb.Target:=g_BatchTarget;
JobsDb.Draft:=g_DraftTarget;
JobsDb.Add;
else
JobsDb.Carnum:=g_CarNumber[g_iUserSelection];
JobsDb.FindFirst(2);
if g_TranCarNumber <> "" then
JobsDb.CarNum:=g_TranCarNumber;
end if;
--JobsDb.Comodity:=g_Commodity;
if g_BatchTarget > 0 then
JobsDb.Target:=g_BatchTarget;
end if;
if g_DraftTarget > 0 then
JobsDb.Draft:=g_DraftTarget;
end if;
JobsDb.Update;
end if;
g_ScaleCheck:=0;
DisplayJobs;
return;
end;
procedure JobScreen;
--Declaration Section
begin
SetLabelText(lbl1s3,"Job Screen");
SetLabelText(lbl2s3,"Job #");
SetLabelText(lbl3s3,"Car #");
-- Commodity will go here
SetLabelText(lbl4s3,"Target");
SetLabelText(lbl5s3,"Draft");
SetLabelText(lbl6s3,"");
SetLabelText(lbl7s3,"");
SetLabelText(lbl8s3,"");
SetLabelText(lbl10s3,"");
SetLabelText(lbl11s3,"");
SetLabelText(lbl12s3,"");
SetLabelText(lbl13s3,"");
SetLabelText(lbl14s3,"");
SetLabelText(lbl15s3,"");
SetLabelText(lbl16s3,"");
SetWidgetVisibility(76,VOn);
SetWidgetVisibility(77,VOn);
SetWidgetVisibility(78,VOn);
SetWidgetVisibility(79,VOn);
SetWidgetVisibility(80,VOff);
SetWidgetVisibility(81,VOff);
SetWidgetVisibility(82,VOff);
SetLabelText(lbl9s3,"Press the Number of the Entry to Change");
SetSoftkeyText(1,"");
SetSoftkeyText(2,"");
SetSoftkeyText(3,"");
SetSoftkeyText(4,"");
SetSoftkeyText(5,"Save / Exit");
SelectScreen(3);
return;
end;
procedure EditaJob;
--Declaration Section
begin
SetLabelText(lbl11s3,g_CarNumber[g_iUserSelection]);
SetLabelText(lbl12s3,RealToString(g_Target[g_iUserSelection],6,0));
SetLabelText(lbl13s3,RealToString(g_Draft[g_iUserSelection],4,0));
g_TranCarNumber:="";
g_BatchTarget:=0;
g_DraftTarget:=0;
return;
end;
procedure ConfigEntryCheck(UserString: string); -- Check Configuration Changes entered by user
-- Declaration Section
rCheck : real;
iCheck : integer;
ErrorCheck : integer;
begin