|
1 | | -function import_concore |
2 | | - global concore; |
3 | | - |
4 | | - try |
5 | | - pid = getpid(); |
6 | | - catch exc |
7 | | - pid = feature('getpid'); |
8 | | - end |
9 | | - outputpid = fopen('concorekill.bat','w'); |
10 | | - fprintf(outputpid,'%s',['taskkill /F /PID ',num2str(pid)]); |
11 | | - fclose(outputpid); |
12 | | - |
13 | | - |
14 | | - try |
15 | | - iportfile = fopen('concore.iport'); |
16 | | - concore.iports = fscanf(iportfile,'%c'); |
17 | | - catch exc |
18 | | - iportfile = ''; |
19 | | - end |
20 | | - |
21 | | - try |
22 | | - oportfile = fopen('concore.oport'); |
23 | | - concore.oports = fscanf(oportfile,'%c'); |
24 | | - catch exc |
25 | | - oportfile = ''; |
26 | | - end |
27 | | - |
28 | | - concore.s = ''; |
29 | | - concore.olds = ''; |
30 | | - concore.delay = 1; |
31 | | - concore.retrycount = 0; |
32 | | - if exist('/in1','dir')==7 % 5/20/21 work for docker or local |
33 | | - concore.inpath = '/in'; |
34 | | - concore.outpath = '/out'; |
35 | | - else |
36 | | - concore.inpath = 'in'; |
37 | | - concore.outpath = 'out'; |
38 | | - end |
39 | | - concore.simtime = 0; |
40 | | - |
41 | | - concore_default_maxtime(100); |
42 | | -end |
| 1 | +function import_concore |
| 2 | + global concore; |
| 3 | + |
| 4 | + if ispc |
| 5 | + try |
| 6 | + pid = getpid(); |
| 7 | + catch exc |
| 8 | + pid = feature('getpid'); |
| 9 | + end |
| 10 | + outputpid = fopen('concorekill.bat','w'); |
| 11 | + if outputpid ~= -1 |
| 12 | + fprintf(outputpid,'%s',['taskkill /F /PID ',num2str(pid)]); |
| 13 | + fclose(outputpid); |
| 14 | + else |
| 15 | + warning('import_concore:ConcoreKillFileOpenFailed', ... |
| 16 | + 'Could not create concorekill.bat. Continuing without kill script.'); |
| 17 | + end |
| 18 | + end |
| 19 | + |
| 20 | + |
| 21 | + try |
| 22 | + iportfile = fopen('concore.iport'); |
| 23 | + concore.iports = fscanf(iportfile,'%c'); |
| 24 | + if isnumeric(iportfile) && iportfile ~= -1 |
| 25 | + fclose(iportfile); |
| 26 | + end |
| 27 | + iportfile = -1; |
| 28 | + catch exc |
| 29 | + if exist('iportfile', 'var') && isnumeric(iportfile) && iportfile ~= -1 |
| 30 | + fclose(iportfile); |
| 31 | + end |
| 32 | + iportfile = -1; |
| 33 | + end |
| 34 | + |
| 35 | + try |
| 36 | + oportfile = fopen('concore.oport'); |
| 37 | + concore.oports = fscanf(oportfile,'%c'); |
| 38 | + if isnumeric(oportfile) && oportfile ~= -1 |
| 39 | + fclose(oportfile); |
| 40 | + end |
| 41 | + oportfile = -1; |
| 42 | + catch exc |
| 43 | + if exist('oportfile', 'var') && isnumeric(oportfile) && oportfile ~= -1 |
| 44 | + fclose(oportfile); |
| 45 | + end |
| 46 | + oportfile = -1; |
| 47 | + end |
| 48 | + |
| 49 | + concore.s = ''; |
| 50 | + concore.olds = ''; |
| 51 | + concore.delay = 1; |
| 52 | + concore.retrycount = 0; |
| 53 | + if exist('/in1','dir')==7 % 5/20/21 work for docker or local |
| 54 | + concore.inpath = '/in'; |
| 55 | + concore.outpath = '/out'; |
| 56 | + else |
| 57 | + concore.inpath = 'in'; |
| 58 | + concore.outpath = 'out'; |
| 59 | + end |
| 60 | + concore.simtime = 0; |
| 61 | + |
| 62 | + concore_default_maxtime(100); |
| 63 | +end |
0 commit comments