-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcsInterpreter.c
More file actions
executable file
·706 lines (617 loc) · 22 KB
/
csInterpreter.c
File metadata and controls
executable file
·706 lines (617 loc) · 22 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
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <assert.h>
#include "cs.h"
#define MATCH (0) // makes use of strncmp() more readable
extern const char csNameSetTemp[];
extern const char csNameSetVolt[];
extern const char csNameHoldMin[];
extern const char csNameCommand[];
extern const char csNameResumeCommand[];
extern const char csNameSaveInterval[];
extern const char csNameRestart[];
extern const char csNameSequence[];
extern const char csNameEndSequence[];
extern const char csNameLoop[];
extern const char csNameSave[];
extern const char csNameVersion[];
extern const char csNameSumValue[];
extern const char csNameLabel[];
extern const char csNameResume[];
extern const char csNameInitialTemperatureSet[];
int execIdx;
Byte resumeFlg = 0;
csInitialTemperature csITemp;
/*****************************************************************************/
int csInterpreter( const char *sequenceFile, long sequenceLength )
/*****************************************************************************/
{
const long MaxFileSize = MAX_FILE_SIZE;
const long MaxCtrlStep = MAX_CTRL_STEP;
const csCtrlStep csZeroStructure = { NULL };
char mySequence[MaxFileSize];
long myLength = 0;
long idx = 0;
long stIdx = 0;
long clearIdx = 0;
long restartIdx = 0;
Dword restartTime = 0;
int status;
// long *seqStatus;
int rc = 0;
Byte returnCode;
csCtrlStep csCtrlStructure[MaxCtrlStep];
TCPRINTF("Entry:%p,%ld", sequenceFile, sequenceLength);
// Zero clear for all structure
for ( clearIdx = 0; clearIdx < MaxCtrlStep; clearIdx++ ) {
csCtrlStructure[clearIdx] = csZeroStructure;
}
// Zero clear for sequence area
memset( mySequence, '\0', MaxFileSize );
TCPRINTF(" +++ csInterpreter run.");
// Error Check part ( return : 2 )
if ( sequenceFile == NULL ) {
TCPRINTF(" ** Input file error! : Address is NULL.");
rc = 1;
goto END_CS_INTERPRETER;
}
if ( (unsigned long)&sequenceFile & 0x00000003 ) {
TCPRINTF(" ** Input file error! : Address is not 4bytes aligned.");
rc = 1;
goto END_CS_INTERPRETER;
}
if ( sequenceLength > MaxFileSize ) {
TCPRINTF(" ** Input file error! : Size over %.0f kbytes.", (float)(MaxFileSize / 1024) );
rc = 1;
goto END_CS_INTERPRETER;
}
if ( sequenceLength <= 0 ) {
TCPRINTF(" ** Input file error! : Size is under 0.");
rc = 1;
goto END_CS_INTERPRETER;
}
TCPRINTF(" +++ input file has no error.");
// Memory allocation for sequence data in my thread.
status = csAllocateMyArea( sequenceFile, sequenceLength, mySequence, &myLength );
if ( status > 0 ) {
rc = 3;
goto END_CS_INTERPRETER;
}
while ( idx < myLength ) {
// putchar(mySequence[idx]);
idx++;
}
idx = 0;
TCPRINTF(" -- myLength : %ld", myLength);
fflush(stdout);
// Sugering data.
status = csCosmeticSurgery( mySequence, &myLength );
if ( status > 0 ) {
rc = 4;
goto END_CS_INTERPRETER;
}
while ( idx < myLength ) {
// putchar(mySequence[idx]);
idx++;
}
TCPRINTF(" -- myLength after surgery : %ld", myLength);
idx = 0;
// Check syntax & build structure for control API.
status = csValidateSyntax( mySequence, myLength, csCtrlStructure, &stIdx );
if ( status > 0 ) {
rc = 5;
goto END_CS_INTERPRETER;
}
while ( idx < stIdx ) {
TCPRINTF(" -- cmdWord : %s, \t\t argStr : %s", csCtrlStructure[idx].cmdName, csCtrlStructure[idx].argStr );
// puts( csCtrlStructure[idx].cmdName );
// putchar(',');
// puts( csCtrlStructure[idx].argStr );
// putchar('\n');
idx++;
}
status = csStringToStructure( csCtrlStructure, stIdx );
if (status > 0) {
rc = 6;
goto END_CS_INTERPRETER;
}
status = csDeleteElapsedStep( csCtrlStructure, &stIdx );
if (status > 0) {
rc = 6;
goto END_CS_INTERPRETER;
}
status = csExpandLoop( csCtrlStructure, MaxCtrlStep, &stIdx);
if (status > 0) {
rc = 7;
goto END_CS_INTERPRETER;
}
returnCode = csConfigureJumpTable( csCtrlStructure);
status = csConfigureResume( csCtrlStructure, stIdx, &restartIdx, &restartTime);
if (status > 0) {
rc = 8;
goto END_CS_INTERPRETER;
}
status = csSetInitialTemperature( csCtrlStructure);
if (status > 0) {
rc = 10;
goto END_CS_INTERPRETER;
}
TCPRINTF(" +++ End of processing sequence file. Next, Execute control.");
status = csExecuteChamberControl( csCtrlStructure, stIdx , restartIdx , restartTime);
if (status > 0) {
rc = 9;
goto END_CS_INTERPRETER;
}
// Chamber control thread is End
TCPRINTF(" +++ End of csThread program.");
END_CS_INTERPRETER:
TCPRINTF("Exit:%d", rc);
return rc;
}
/*****************************************************************************/
int csAllocateMyArea(const char *sequenceFile, long sequenceLength,
char *mySequence, long *myLength )
/*****************************************************************************/
{
int rc = 0;
long readIdx = 0;
long eofFlag = 0;
TCPRINTF("Entry: %p, %ld, %p, %ld", sequenceFile, sequenceLength, mySequence, *myLength);
/* checking for EOF at last character. only check of end of file.
* if EOF exist in mid of sequence file, return error code this function.
*/
TCPRINTF("++ End character of sequence file : %c / %ld", sequenceFile[sequenceLength - 1], sequenceLength);
if ( sequenceFile[sequenceLength - 1] == 0x1A ) {
// exist EOF. delete character or decrease length of source data.(-1)
TCPRINTF("++ EOF exist in end of sequence file. \n" );
// decrease length. * bad idea *
/* sequenceLength--;
TCPRINTF("++ sequence length : %ld / %c", sequenceLength, sequenceFile[sequenceLength]);
*/
// alternate idea: replace null from EOF(0x1A)
// sequenceFile[sequenceLength - 1] = NULL;
// eof flag on
eofFlag = 1;
} else {
// nothing EOF. no action.
TCPRINTF("++ not found EOF in sequence file. \n" );
}
for ( readIdx = 0; readIdx < ( sequenceLength - eofFlag ); readIdx++ ) {
mySequence[readIdx] = sequenceFile[readIdx];
if ( !isprint( mySequence[readIdx]) && !isspace( mySequence[readIdx]) ) {
TCPRINTF(" *** Read file error!! : found unexpected character. please, check a reading file.");
TCPRINTF(" *** offset %ld 0x%02x", readIdx, mySequence[readIdx]);
rc = 1;
goto END_CS_ALLOCATE_MY_AREA;
}
}
*myLength = readIdx;
END_CS_ALLOCATE_MY_AREA:
TCPRINTF("Exit:%d", rc);
return rc;
}
/*****************************************************************************/
int csCosmeticSurgery(char *mySequence, long *myLength)
/*****************************************************************************/
{
const long bufLength = MAX_FILE_SIZE;
int rc = 0;
char seqBuffer[bufLength];
char ch;
long copyIdx = 0;
long visibleIdx = 0;
TCPRINTF("Entry:%p,%ld", mySequence, *myLength);
// TCPRINTF("=> myLength in Surgery : %ld\n", *myLength);
while ( copyIdx < *myLength ) {
ch = mySequence[copyIdx];
if ( isgraph( ch ) ) { // isgraph() arrowed only visible character.
seqBuffer[visibleIdx] = ch;
visibleIdx++;
}
copyIdx++;
if ( visibleIdx > copyIdx ) {
TCPRINTF(" ** File processing error!! : Unexpected accident.");
rc = 1;
goto END_CS_SURGERY;
}
}
memset( mySequence, '\0', *myLength );
*myLength = visibleIdx;
for ( copyIdx = 0; copyIdx < visibleIdx; copyIdx++ ) {
mySequence[copyIdx] = seqBuffer[copyIdx];
}
END_CS_SURGERY:
TCPRINTF("Exit:%d", rc);
return 0;
}
/*****************************************************************************/
int csExecuteChamberControl( csCtrlStep *csCtrlStruct, const long structIdx, const long restartIdx , Dword restartTime)
/*****************************************************************************/
{
execIdx = 0;
int rc = 0;
SM_MESSAGE smMessage;
TCPRINTF("Entry: %p, %ld, %ld", csCtrlStruct, structIdx, restartIdx);
#if defined(UNIT_TEST)
#else
if (tccb.optionSyncManagerDebug) {
// strncpy(smMessage.string,string,64);
smMessage.type = SM_CS_SD_CSREADY;
char string[] = "ChamberScript:READY";
strncpy(smMessage.string, string, sizeof(smMessage.string));
smMessage.param[0] = restartTime;
rc = smSendSyncMessage(&smMessage, SM_CS_SD_TIMEOUT);
if (rc) {
goto END_CS_EXECUTE_CHAMBER_CONTROL;
}
} else {
tccb.isChamberScriptReadyToStart = 1;
}
// tccb.isChamberScriptReadyToStart = 1;
#endif /* UNIT_TEST */
if ( restartIdx < 0 ) {
TCPRINTF(" ** Arguments error!! : invalid parameter restartIdx >> %ld", restartIdx);
rc = 5;
goto END_CS_EXECUTE_CHAMBER_CONTROL;
}
if ( restartIdx > structIdx ) {
TCPRINTF(" ** Arguments error!! : invalid parameter structIdx >> %ld, restartIdx >> %ld", structIdx, restartIdx);
rc = 6;
goto END_CS_EXECUTE_CHAMBER_CONTROL;
}
csInitializeTimer();
for ( execIdx = restartIdx; execIdx < structIdx; execIdx++ ) {
rc = csCtrlStruct[execIdx].function( csCtrlStruct[execIdx].arg1,
csCtrlStruct[execIdx].arg2,
csCtrlStruct[execIdx].arg3,
csCtrlStruct[execIdx].string,
csCtrlStruct[execIdx].length );
if (rc > 0) {
TCPRINTF(" ** Control error!! : %s function cause problem.", csCtrlStruct[execIdx].cmdName);
rc = 1;
goto END_CS_EXECUTE_CHAMBER_CONTROL;
}
}
END_CS_EXECUTE_CHAMBER_CONTROL:
TCPRINTF("Exit:%d", rc);
return rc;
}
/****************************************************************/
Byte csDeleteResumeIdx(void)
/****************************************************************/
{
int i;
Byte rc = 0;
int ret = 0;
FILE *fp;
char saveFileName[30] = "";
TCPRINTF("ENTRY:");
for (i = 0;i < tccb.optionNumOfTestScriptThread;i++) {
ret = snprintf(saveFileName, sizeof(saveFileName), "/var/lib/hgst/cs%03d.saveindex", (int)tccb.ts[i].wHGSTCellNo);
if (ret != 29) {
rc = 1;
goto END_CS_DELETE_RESUME_IDX;
}
const char *cSaveFileName = saveFileName;
if ((fp = fopen(cSaveFileName, "w")) == NULL) {
rc = 1;
TCPRINTF("!!!!!!!!!!!!!!!!!index file delete error %s", cSaveFileName);
goto END_CS_DELETE_RESUME_IDX;
}
fclose(fp);
}
END_CS_DELETE_RESUME_IDX:
TCPRINTF("Exit:%d", rc);
return rc;
}
/****************************************************************/
Byte csWriteResumeIdx( Dword minute, Word csindex, Byte tempResumeMode)
/****************************************************************/
{
int i;
Byte rc = 0;
int ret = 0;
FILE *fp;
char saveFileName[30] = "";
char saveString[32] = "";
TCPRINTF("ENTRY:");
if ((tempResumeMode != 0) && (tempResumeMode != 1)) {
rc = 1;
TCPRINTF("!!!!!!!!!!Value of tempResumeMode is over the limit !!!!!!!%d", tempResumeMode);
goto END_CS_WRITE_RESUME_IDX;
}
ret = snprintf(saveString, sizeof(saveString), "%08d,%08d,%1d,", (int)minute, (int)csindex, (int)tempResumeMode);
unsigned long crcByCalcuration = ts_crc32(saveString, sizeof(saveString) - 12);
ret = snprintf(saveString, sizeof(saveString), "%08d,%08d,%1d,0x%08lx\n", (int)minute, (int)csindex, (int)tempResumeMode, crcByCalcuration);
TCPRINTF("savestring:%s", saveString);
if (ret == EOF) {
rc = 1;
goto END_CS_WRITE_RESUME_IDX;
}
for (i = 0;i < tccb.optionNumOfTestScriptThread;i++) {
ret = snprintf(saveFileName, sizeof(saveFileName), "/var/lib/hgst/cs%03d.saveindex", (int)tccb.ts[i].wHGSTCellNo);
if (ret != 29) {
rc = 1;
goto END_CS_WRITE_RESUME_IDX;
}
if ((fp = fopen((const char *)saveFileName, "a")) == NULL) {
rc = 1;
TCPRINTF("!!!!!!!!!!!!!!!!!index file open error %s", saveFileName);
goto END_CS_WRITE_RESUME_IDX;
}
ret = fputs(saveString, fp);
if (ret == EOF) {
TCPRINTF("!!!!!!!!!!!!!!!!!index file write error %s", saveFileName);
rc = 1;
goto END_CS_WRITE_RESUME_IDX;
}
fclose(fp);
}
END_CS_WRITE_RESUME_IDX:
TCPRINTF("Exit:%d", rc);
return rc;
}
/****************************************************************/
Byte csReadResumeIdx( Dword *minute, Word *csIndex, Byte *tempResumeMode)
/****************************************************************/
{
int i, j;
Byte rc = 0;
int ret = 0;
FILE *fp;
char saveFileName[30] = "";
char saveString[32] = "";
char readCrc[11];
char readData[9];
TCPRINTF("ENTRY:");
*minute = 0;
*csIndex = 0;
i = 0;
ret = snprintf(saveFileName, sizeof(saveFileName), "/var/lib/hgst/cs%03d.saveindex", (int)tccb.ts[i].wHGSTCellNo);
if (ret != 29 ) {
rc = 1;
goto END_CS_READ_RESUME_IDX;
}
if ((fp = fopen((const char *)saveFileName, "rb")) == NULL) {
rc = 1;
TCPRINTF("!!!!!!!!!!!!!!!!!index file open error %s", saveFileName);
goto END_CS_READ_RESUME_IDX;
}
if (fseek(fp, -(sizeof(saveString) - 1), SEEK_END) != 0) {
rc = 1;
TCPRINTF("!!!!!!!!!!!!!!!!!index file open error %s", saveFileName);
goto END_CS_READ_RESUME_IDX;
}
if ((sizeof(saveString) - 1) != fread(saveString, 1, sizeof(saveString) - 1, fp)) {
;
rc = 1;
TCPRINTF("!!!!!!!!!!!!!!!!!index file open error %s", saveFileName);
goto END_CS_READ_RESUME_IDX;
}
unsigned long crcByCalcuration = ts_crc32(saveString, sizeof(saveString) - 12);
char crcByCalcurationString[11];
ret = snprintf(crcByCalcurationString, sizeof(crcByCalcurationString), "0x%08lx", crcByCalcuration);
if (ret != 10 ) {
rc = 1;
TCPRINTF("!!!!!!!!!!!!!!!!!CRC calcuration error");
goto END_CS_READ_RESUME_IDX;
}
strncpy(readCrc, saveString + 20, sizeof(readCrc));
readCrc[10] = '\0';
if (strcmp(crcByCalcurationString, readCrc) != MATCH) {
rc = 1;
for (j = 0;j < 11;j++) {
TCPRINTF("%d,%d", crcByCalcurationString[j], readCrc[j]);
}
TCPRINTF("!!!!!!!!!!!!!!!!!CRC error %s - %s", crcByCalcurationString, readCrc);
goto END_CS_READ_RESUME_IDX;
}
strncpy(readData, saveString, sizeof(readData));
for (j = 0;j < 8;j++) {
if (isdigit(readData[j])) {
} else {
rc = 1;
TCPRINTF("!!!!!!!!!!!!!!!!! minute read error !!!!!!!!!!!!!!!");
goto END_CS_READ_RESUME_IDX;
}
}
*minute = (Dword)atoi(readData);
if (*minute > 60*24*365) {
rc = 1;
TCPRINTF("!!!!!!!!!!!!!!!!! read minute is too big error!!!!!!!!!!!!!!!");
goto END_CS_READ_RESUME_IDX;
}
strncpy(readData, saveString + 9, sizeof(readData));
for (j = 0;j < 8;j++) {
if (isdigit(readData[j])) {
} else {
rc = 1;
TCPRINTF("!!!!!!!!!!!!!!!!! Index read error !!!!!!!!!!!!!!!");
goto END_CS_READ_RESUME_IDX;
}
}
*csIndex = (Word)atoi(readData);
if (*csIndex > MAX_CTRL_STEP) {
rc = 1;
TCPRINTF("!!!!!!!!!!!!!!!!! read index is too big error!!!!!!!!!!!!!!!");
goto END_CS_READ_RESUME_IDX;
}
readData[0] = *(saveString + 18);
if (isdigit(readData[0])) {
if (readData[0] == '0') {
*tempResumeMode = 0;
} else if (readData[0] == '1') {
*tempResumeMode = 1;
} else {
rc = 1;
TCPRINTF("!!!!!!!!!!Value of tempResumeMode is over the limit !!!!!!!%s", readData);
goto END_CS_READ_RESUME_IDX;
}
}
// }
END_CS_READ_RESUME_IDX:
TCPRINTF("Exit:%d", rc);
return rc;
}
/*************************************************************************************/
Byte csConfigureJumpTable( csCtrlStep *csCtrlStruct)
/*************************************************************************************/
{
Dword totalMinute = 0;
Word ctrlStepIndex = 0;
Word jumpTableIndex = 0;
Word labelTableIndex = 0;
TCPRINTF("ENTRY:");
const long MaxCtrlStep = MAX_CTRL_STEP;
for (ctrlStepIndex = 0;ctrlStepIndex < MaxCtrlStep;ctrlStepIndex++) {
if (strcmp(csCtrlStruct[ctrlStepIndex].cmdName, csNameHoldMin) == MATCH) {
totalMinute = totalMinute + (Dword)csCtrlStruct[ctrlStepIndex].arg1;
} else if (strcmp(csCtrlStruct[ctrlStepIndex].cmdName, csNameResume) == MATCH) {
jumpTableIndex--;
} else if (strcmp(csCtrlStruct[ctrlStepIndex].cmdName, csNameLabel) == MATCH) {
if (csCtrlStruct[ctrlStepIndex].argStr[0] == '#') {
strncpy(csJumpTable[labelTableIndex].string, csCtrlStruct[ctrlStepIndex].argStr + 1, sizeof(csCtrlStruct[ctrlStepIndex].argStr) - 1);
} else {
strncpy(csJumpTable[labelTableIndex].string, csCtrlStruct[ctrlStepIndex].argStr, sizeof(csCtrlStruct[ctrlStepIndex].argStr));
}
csJumpTable[labelTableIndex].index = jumpTableIndex;
csJumpTable[labelTableIndex].minute = totalMinute;
labelTableIndex++;
}
jumpTableIndex++;
}
TCPRINTF("Exit:");
return 0;
}
/*************************************************************************************/
Byte csDeleteElapsedStep( csCtrlStep *csCtrlStruct, long *stIdx)
/*************************************************************************************/
{
Word inputStepIndex = 0;
Word outputStepIndex = 0;
Byte rc = 0;
long totalIndex = *stIdx;
TCPRINTF("ENTRY:");
if (csCtrlStruct == NULL) {
rc = 1;
TCPRINTF("!!!!!!!!!!!!!!!!! control struct is NULL !!!!!!!!!!!!!!!");
goto END_CS_DELETE_ELAPSED_STEP;
}
if (*stIdx > MAX_CTRL_STEP) {
rc = 1;
TCPRINTF("!!!!!!!!!!!!!!!!! index is too big !!!!!!!!!!!!!!!");
goto END_CS_DELETE_ELAPSED_STEP;
}
resumeFlg = 0;
csITemp.initialTemperatureFlag = 0;
csITemp.targetTemperature = 25;
csITemp.minimumTemperature = 15;
csITemp.maximumTemperature = 35;
for (inputStepIndex = 0;inputStepIndex < *stIdx;inputStepIndex++) {
if (strcmp(csCtrlStruct[inputStepIndex].cmdName, csNameResume) == MATCH) {
totalIndex--;
if ((csCtrlStruct[inputStepIndex].arg1 != 0)
|| (csCtrlStruct[inputStepIndex].arg2 != 0)
|| (csCtrlStruct[inputStepIndex].arg3 != 0)) {
resumeFlg = 1;
}
} else {
if (strcmp(csCtrlStruct[inputStepIndex].cmdName, csNameInitialTemperatureSet) == MATCH) {
csITemp.initialTemperatureFlag = 1;
csITemp.targetTemperature = csCtrlStruct[inputStepIndex].arg1;
csITemp.minimumTemperature = csCtrlStruct[inputStepIndex].arg2;
csITemp.maximumTemperature = csCtrlStruct[inputStepIndex].arg3;
}
csCtrlStruct[outputStepIndex] = csCtrlStruct[inputStepIndex];
outputStepIndex++;
}
}
*stIdx = totalIndex;
END_CS_DELETE_ELAPSED_STEP:
TCPRINTF("Exit:%d", rc);
return rc;
}
/**
* <pre>
* Description:
* Display back trace by using tcPrintf() and check recursive call
* Arguments:
* recursiveCheckFunc - INPUT - function name to be checked recursive call
* Return:
* 0: no recursive call. 1:recursive call 2:back trace is empty
* Note:
* </pre>
*****************************************************************************/
/*************************************************************************************/
Byte csSetInitialTemperature( csCtrlStep *csCtrlStruct)
/*************************************************************************************/
{
TCPRINTF("ENTRY:");
Word wTempInHundredth = 0;
Byte rc = 0;
TCPRINTF("resumeFlg= %d,setInitialTemperatureFlg= %d", resumeFlg, csITemp.initialTemperatureFlag);
if ( csITemp.targetTemperature < 10 ) {
TCPRINTF(" ** Arguments error!! : invalid parameter target temperature< 10 degreeC %d", csITemp.targetTemperature);
rc = 1;
goto END_CS_SET_INITIAL_TEMPERATURE;
}
if ( csITemp.targetTemperature > 70 ) {
TCPRINTF(" ** Arguments error!! : invalid parameter target temperature> 70 degreeC %d", csITemp.targetTemperature);
rc = 1;
goto END_CS_SET_INITIAL_TEMPERATURE;
}
if ( csITemp.targetTemperature > csITemp.maximumTemperature ) {
TCPRINTF(" ** Arguments error!! : invalid parameter target temperature> maximum temperature %d", csITemp.maximumTemperature);
rc = 1;
goto END_CS_SET_INITIAL_TEMPERATURE;
}
if ( csITemp.targetTemperature < csITemp.minimumTemperature ) {
TCPRINTF(" ** Arguments error!! : invalid parameter target temperature< minimum temperature %d", csITemp.minimumTemperature);
rc = 1;
goto END_CS_SET_INITIAL_TEMPERATURE;
}
if ( csITemp.maximumTemperature == csITemp.minimumTemperature ) {
TCPRINTF(" ** Arguments error!! : invalid parameter maximum temperature == minimum temperature %d,%d", csITemp.maximumTemperature, csITemp.minimumTemperature);
rc = 1;
goto END_CS_SET_INITIAL_TEMPERATURE;
}
if ((resumeFlg == 0) && (csITemp.initialTemperatureFlag == 1)) {
TCPRINTF("ramp rate change is not supported right now");
rc = setTargetTemperature(tccb.ts[0].wHGSTCellNo + 1, csITemp.targetTemperature * 100);
if (rc) {
TCPRINTF("error");
exit(EXIT_FAILURE);
}
for (;;) {
rc = getCurrentTemperature(tccb.ts[0].wHGSTCellNo + 1, &wTempInHundredth);
if (rc) {
TCPRINTF("error");
exit(EXIT_FAILURE);
}
TCPRINTF("current temperature %d", wTempInHundredth);
if ((wTempInHundredth >= csITemp.minimumTemperature * 100)
&& (wTempInHundredth <= csITemp.maximumTemperature * 100)) {
TCPRINTF("current temperature is reached target temperature");
break;
}
// Mutex Unlock
rc = pthread_mutex_unlock(&mutex_slotio);
if (rc) {
TCPRINTF("error");
tcExit(EXIT_FAILURE);
}
sleep(TEMP_CHECK_DURATION);
// Mutex Lock
rc = pthread_mutex_lock(&mutex_slotio);
if (rc) {
TCPRINTF("error");
tcExit(EXIT_FAILURE);
}
}
}
END_CS_SET_INITIAL_TEMPERATURE:
TCPRINTF("Exit:");
return rc;
}