Commit ef1b9f48581f0369063c565c51a3fe61b903d280
1 parent
8384ec9f
Exists in
master
rename experiment runner project
Showing
6 changed files
with
318 additions
and
318 deletions
Show diff stats
cultural_matrix.ico
No preview for this file type
cultural_matrix.lpi
@@ -1,198 +0,0 @@ | @@ -1,198 +0,0 @@ | ||
1 | -<?xml version="1.0" encoding="UTF-8"?> | ||
2 | -<CONFIG> | ||
3 | - <ProjectOptions> | ||
4 | - <Version Value="9"/> | ||
5 | - <General> | ||
6 | - <SessionStorage Value="InProjectDir"/> | ||
7 | - <MainUnit Value="0"/> | ||
8 | - <Title Value="cultural_matrix"/> | ||
9 | - <ResourceType Value="res"/> | ||
10 | - <UseXPManifest Value="True"/> | ||
11 | - <Icon Value="0"/> | ||
12 | - </General> | ||
13 | - <i18n> | ||
14 | - <EnableI18N LFM="False"/> | ||
15 | - </i18n> | ||
16 | - <VersionInfo> | ||
17 | - <StringTable ProductVersion=""/> | ||
18 | - </VersionInfo> | ||
19 | - <BuildModes Count="3"> | ||
20 | - <Item1 Name="Linux64" Default="True"/> | ||
21 | - <Item2 Name="Win32 Debug"> | ||
22 | - <CompilerOptions> | ||
23 | - <Version Value="11"/> | ||
24 | - <Target> | ||
25 | - <Filename Value="cultural_matrix"/> | ||
26 | - </Target> | ||
27 | - <SearchPaths> | ||
28 | - <IncludeFiles Value="$(ProjOutDir)"/> | ||
29 | - <Libraries Value="/usr/lib/gcc/x86_64-linux-gnu/4.9/"/> | ||
30 | - <OtherUnitFiles Value="units;../../dependency/delphizmq;../../units"/> | ||
31 | - <UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/> | ||
32 | - </SearchPaths> | ||
33 | - <Linking> | ||
34 | - <Options> | ||
35 | - <Win32> | ||
36 | - <GraphicApplication Value="True"/> | ||
37 | - </Win32> | ||
38 | - </Options> | ||
39 | - </Linking> | ||
40 | - </CompilerOptions> | ||
41 | - </Item2> | ||
42 | - <Item3 Name="Win32 Release"> | ||
43 | - <CompilerOptions> | ||
44 | - <Version Value="11"/> | ||
45 | - <Target> | ||
46 | - <Filename Value="cultural_matrix"/> | ||
47 | - </Target> | ||
48 | - <SearchPaths> | ||
49 | - <IncludeFiles Value="$(ProjOutDir)"/> | ||
50 | - <Libraries Value="/usr/lib/gcc/x86_64-linux-gnu/4.9/"/> | ||
51 | - <OtherUnitFiles Value="units;../../dependency/delphizmq;../../units"/> | ||
52 | - <UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/> | ||
53 | - </SearchPaths> | ||
54 | - <CodeGeneration> | ||
55 | - <SmartLinkUnit Value="True"/> | ||
56 | - <Optimizations> | ||
57 | - <OptimizationLevel Value="4"/> | ||
58 | - </Optimizations> | ||
59 | - </CodeGeneration> | ||
60 | - <Linking> | ||
61 | - <Debugging> | ||
62 | - <GenerateDebugInfo Value="False"/> | ||
63 | - <StripSymbols Value="True"/> | ||
64 | - </Debugging> | ||
65 | - <LinkSmart Value="True"/> | ||
66 | - <Options> | ||
67 | - <Win32> | ||
68 | - <GraphicApplication Value="True"/> | ||
69 | - </Win32> | ||
70 | - </Options> | ||
71 | - </Linking> | ||
72 | - </CompilerOptions> | ||
73 | - </Item3> | ||
74 | - </BuildModes> | ||
75 | - <PublishOptions> | ||
76 | - <Version Value="2"/> | ||
77 | - </PublishOptions> | ||
78 | - <RunParams> | ||
79 | - <local> | ||
80 | - <FormatVersion Value="1"/> | ||
81 | - </local> | ||
82 | - </RunParams> | ||
83 | - <RequiredPackages Count="2"> | ||
84 | - <Item1> | ||
85 | - <PackageName Value="FCL"/> | ||
86 | - </Item1> | ||
87 | - <Item2> | ||
88 | - <PackageName Value="LCL"/> | ||
89 | - </Item2> | ||
90 | - </RequiredPackages> | ||
91 | - <Units Count="15"> | ||
92 | - <Unit0> | ||
93 | - <Filename Value="cultural_matrix.lpr"/> | ||
94 | - <IsPartOfProject Value="True"/> | ||
95 | - </Unit0> | ||
96 | - <Unit1> | ||
97 | - <Filename Value="form_matrixgame.pas"/> | ||
98 | - <IsPartOfProject Value="True"/> | ||
99 | - <ComponentName Value="FormMatrixGame"/> | ||
100 | - <HasResources Value="True"/> | ||
101 | - <ResourceBaseClass Value="Form"/> | ||
102 | - </Unit1> | ||
103 | - <Unit2> | ||
104 | - <Filename Value="README.md"/> | ||
105 | - <IsPartOfProject Value="True"/> | ||
106 | - </Unit2> | ||
107 | - <Unit3> | ||
108 | - <Filename Value="units/zmq_network.pas"/> | ||
109 | - <IsPartOfProject Value="True"/> | ||
110 | - </Unit3> | ||
111 | - <Unit4> | ||
112 | - <Filename Value="units/game_zmq_actors.pas"/> | ||
113 | - <IsPartOfProject Value="True"/> | ||
114 | - </Unit4> | ||
115 | - <Unit5> | ||
116 | - <Filename Value="units/game_actors.pas"/> | ||
117 | - <IsPartOfProject Value="True"/> | ||
118 | - </Unit5> | ||
119 | - <Unit6> | ||
120 | - <Filename Value="units/game_experiment.pas"/> | ||
121 | - <IsPartOfProject Value="True"/> | ||
122 | - </Unit6> | ||
123 | - <Unit7> | ||
124 | - <Filename Value="units/game_file_methods.pas"/> | ||
125 | - <IsPartOfProject Value="True"/> | ||
126 | - </Unit7> | ||
127 | - <Unit8> | ||
128 | - <Filename Value="units/game_resources.pas"/> | ||
129 | - <IsPartOfProject Value="True"/> | ||
130 | - </Unit8> | ||
131 | - <Unit9> | ||
132 | - <Filename Value="units/game_control.pas"/> | ||
133 | - <IsPartOfProject Value="True"/> | ||
134 | - </Unit9> | ||
135 | - <Unit10> | ||
136 | - <Filename Value="units/string_methods.pas"/> | ||
137 | - <IsPartOfProject Value="True"/> | ||
138 | - </Unit10> | ||
139 | - <Unit11> | ||
140 | - <Filename Value="units/game_actors_point.pas"/> | ||
141 | - <IsPartOfProject Value="True"/> | ||
142 | - </Unit11> | ||
143 | - <Unit12> | ||
144 | - <Filename Value="units/game_visual_elements.pas"/> | ||
145 | - <IsPartOfProject Value="True"/> | ||
146 | - </Unit12> | ||
147 | - <Unit13> | ||
148 | - <Filename Value="form_chooseactor.pas"/> | ||
149 | - <IsPartOfProject Value="True"/> | ||
150 | - <ComponentName Value="FormChooseActor"/> | ||
151 | - <HasResources Value="True"/> | ||
152 | - <ResourceBaseClass Value="Form"/> | ||
153 | - </Unit13> | ||
154 | - <Unit14> | ||
155 | - <Filename Value="units/csv_writer.pas"/> | ||
156 | - <IsPartOfProject Value="True"/> | ||
157 | - </Unit14> | ||
158 | - </Units> | ||
159 | - </ProjectOptions> | ||
160 | - <CompilerOptions> | ||
161 | - <Version Value="11"/> | ||
162 | - <Target> | ||
163 | - <Filename Value="cultural_matrix"/> | ||
164 | - </Target> | ||
165 | - <SearchPaths> | ||
166 | - <IncludeFiles Value="$(ProjOutDir)"/> | ||
167 | - <Libraries Value="/usr/lib/gcc/x86_64-linux-gnu/4.9/"/> | ||
168 | - <OtherUnitFiles Value="units;../../dependency/delphizmq;../../units"/> | ||
169 | - <UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/> | ||
170 | - </SearchPaths> | ||
171 | - <Linking> | ||
172 | - <Options> | ||
173 | - <Win32> | ||
174 | - <GraphicApplication Value="True"/> | ||
175 | - </Win32> | ||
176 | - </Options> | ||
177 | - </Linking> | ||
178 | - <Other> | ||
179 | - <CustomOptions Value="-dUseCThreads"/> | ||
180 | - <OtherDefines Count="1"> | ||
181 | - <Define0 Value="UseCThreads"/> | ||
182 | - </OtherDefines> | ||
183 | - </Other> | ||
184 | - </CompilerOptions> | ||
185 | - <Debugging> | ||
186 | - <Exceptions Count="3"> | ||
187 | - <Item1> | ||
188 | - <Name Value="EAbort"/> | ||
189 | - </Item1> | ||
190 | - <Item2> | ||
191 | - <Name Value="ECodetoolError"/> | ||
192 | - </Item2> | ||
193 | - <Item3> | ||
194 | - <Name Value="EFOpenError"/> | ||
195 | - </Item3> | ||
196 | - </Exceptions> | ||
197 | - </Debugging> | ||
198 | -</CONFIG> |
cultural_matrix.lpr
@@ -1,120 +0,0 @@ | @@ -1,120 +0,0 @@ | ||
1 | -{ | ||
2 | - Stimulus Control | ||
3 | - Copyright (C) 2014-2016 Carlos Rafael Fernandes Picanço, Universidade Federal do Pará. | ||
4 | - | ||
5 | - The present file is distributed under the terms of the GNU General Public License (GPL v3.0). | ||
6 | - | ||
7 | - You should have received a copy of the GNU General Public License | ||
8 | - along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
9 | -} | ||
10 | -program cultural_matrix; | ||
11 | - | ||
12 | -{$mode objfpc}{$H+} | ||
13 | - | ||
14 | -{$DEFINE DEBUG} | ||
15 | - | ||
16 | -uses | ||
17 | - {$IFDEF UNIX}{$IFDEF UseCThreads} | ||
18 | - cthreads, | ||
19 | - {$ENDIF}{$ENDIF} | ||
20 | - Interfaces // this includes the LCL widgetset | ||
21 | - {$IFDEF DEBUG} | ||
22 | - , Dialogs, FileUtil, LazFileUtils | ||
23 | - {$IFDEF LINUX} | ||
24 | - , BaseUnix | ||
25 | - {$ENDIF} | ||
26 | - {$ENDIF} | ||
27 | - , StrUtils, Forms, Classes, sysutils | ||
28 | - , form_matrixgame, game_actors | ||
29 | - , zhelpers, form_chooseactor | ||
30 | - ; | ||
31 | - | ||
32 | - | ||
33 | -var | ||
34 | - ApplicationPath, | ||
35 | - F : string; | ||
36 | - | ||
37 | -const | ||
38 | - PAdmin : array [0..3] of string = ('--admin','--adm','-admin','-adm'); | ||
39 | - PPlayer : array [0..3] of string = ('--player','--play','-player','-play'); | ||
40 | - PWatcher : array [0..3] of string = ('--watcher','--watch','-watcher','-watch'); | ||
41 | - | ||
42 | -{$R *.res} | ||
43 | - | ||
44 | - | ||
45 | -{$IFDEF DEBUG} | ||
46 | - function CreateDebugFoldersForPlayers:Boolean; | ||
47 | - var | ||
48 | - i : integer; | ||
49 | - begin | ||
50 | - Result := True; | ||
51 | - for i := 0 to 2 do | ||
52 | - begin | ||
53 | - if Pos(('Participant'), Application.ExeName) > 0 then | ||
54 | - Break; | ||
55 | - F := ApplicationPath+'Participant'+IntToStr(i+1); | ||
56 | - WriteLn(F); | ||
57 | - if ForceDirectoriesUTF8(F) then // ensure we have always the newer version for tests | ||
58 | - begin | ||
59 | - CopyFile(Application.ExeName,F+PathDelim+ApplicationName,[cffOverwriteFile]); | ||
60 | - {$IFDEF LINUX} | ||
61 | - FpChmod(F+PathDelim+ApplicationName,S_IRWXU); | ||
62 | - {$ENDIF} | ||
63 | - end | ||
64 | - else Result := False; | ||
65 | - end; | ||
66 | - end; | ||
67 | -{$ENDIF} | ||
68 | - | ||
69 | - function GetZMQNetworkID(var F:string):Boolean; | ||
70 | - var ID : TStringList; | ||
71 | - begin | ||
72 | - Result := True; | ||
73 | - ID := TStringList.Create; | ||
74 | - if FileExists(F) then | ||
75 | - try | ||
76 | - ID.LoadFromFile(F); | ||
77 | - F := Copy(ID.Text,0,Length(ID.Text)-2); | ||
78 | - finally | ||
79 | - ID.Free; | ||
80 | - end | ||
81 | - else | ||
82 | - try | ||
83 | - ID.Text := s_random(32); | ||
84 | - ID.SaveToFile(F); | ||
85 | - F := Copy(ID.Text,0,Length(ID.Text)-2); | ||
86 | - except | ||
87 | - on E: Exception do | ||
88 | - begin | ||
89 | - ID.Free; | ||
90 | - {$IFDEF DEBUG} | ||
91 | - ShowMessage(E.Message); | ||
92 | - {$ENDIF} | ||
93 | - Result := False; | ||
94 | - end; | ||
95 | - end; | ||
96 | - end; | ||
97 | - | ||
98 | -begin | ||
99 | - ApplicationPath := ExtractFilePath(Application.ExeName); | ||
100 | - {$IFDEF DEBUG} | ||
101 | - if not CreateDebugFoldersForPlayers then Exit; | ||
102 | - {$ENDIF} | ||
103 | - Application.Initialize; | ||
104 | - F := ApplicationPath+PathDelim+'id'; | ||
105 | - if not GetZMQNetworkID(F) then Exit; | ||
106 | - Application.CreateForm(TFormMatrixGame, FormMatrixGame); | ||
107 | - | ||
108 | - FormMatrixGame.SetID(F); | ||
109 | - if Paramcount > 0 then | ||
110 | - begin | ||
111 | - if AnsiMatchStr(lowercase(ParamStr(0)), PAdmin) then | ||
112 | - FormMatrixGame.SetGameActor(gaAdmin); | ||
113 | - if AnsiMatchStr(lowercase(ParamStr(0)), PPlayer) then | ||
114 | - FormMatrixGame.SetGameActor(gaPlayer); | ||
115 | - if AnsiMatchStr(lowercase(ParamStr(0)), PWatcher) then | ||
116 | - FormMatrixGame.SetGameActor(gaWatcher); | ||
117 | - end; | ||
118 | - Application.Run; | ||
119 | -end. | ||
120 | - |
No preview for this file type
@@ -0,0 +1,198 @@ | @@ -0,0 +1,198 @@ | ||
1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
2 | +<CONFIG> | ||
3 | + <ProjectOptions> | ||
4 | + <Version Value="9"/> | ||
5 | + <General> | ||
6 | + <SessionStorage Value="InProjectDir"/> | ||
7 | + <MainUnit Value="0"/> | ||
8 | + <Title Value="experiment_runner"/> | ||
9 | + <ResourceType Value="res"/> | ||
10 | + <UseXPManifest Value="True"/> | ||
11 | + <Icon Value="0"/> | ||
12 | + </General> | ||
13 | + <i18n> | ||
14 | + <EnableI18N LFM="False"/> | ||
15 | + </i18n> | ||
16 | + <VersionInfo> | ||
17 | + <StringTable ProductVersion=""/> | ||
18 | + </VersionInfo> | ||
19 | + <BuildModes Count="3"> | ||
20 | + <Item1 Name="Linux64" Default="True"/> | ||
21 | + <Item2 Name="Win32 Debug"> | ||
22 | + <CompilerOptions> | ||
23 | + <Version Value="11"/> | ||
24 | + <Target> | ||
25 | + <Filename Value="experiment_runner"/> | ||
26 | + </Target> | ||
27 | + <SearchPaths> | ||
28 | + <IncludeFiles Value="$(ProjOutDir)"/> | ||
29 | + <Libraries Value="/usr/lib/gcc/x86_64-linux-gnu/4.9/"/> | ||
30 | + <OtherUnitFiles Value="units;../../dependency/delphizmq;../../units"/> | ||
31 | + <UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/> | ||
32 | + </SearchPaths> | ||
33 | + <Linking> | ||
34 | + <Options> | ||
35 | + <Win32> | ||
36 | + <GraphicApplication Value="True"/> | ||
37 | + </Win32> | ||
38 | + </Options> | ||
39 | + </Linking> | ||
40 | + </CompilerOptions> | ||
41 | + </Item2> | ||
42 | + <Item3 Name="Win32 Release"> | ||
43 | + <CompilerOptions> | ||
44 | + <Version Value="11"/> | ||
45 | + <Target> | ||
46 | + <Filename Value="experiment_runner"/> | ||
47 | + </Target> | ||
48 | + <SearchPaths> | ||
49 | + <IncludeFiles Value="$(ProjOutDir)"/> | ||
50 | + <Libraries Value="/usr/lib/gcc/x86_64-linux-gnu/4.9/"/> | ||
51 | + <OtherUnitFiles Value="units;../../dependency/delphizmq;../../units"/> | ||
52 | + <UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/> | ||
53 | + </SearchPaths> | ||
54 | + <CodeGeneration> | ||
55 | + <SmartLinkUnit Value="True"/> | ||
56 | + <Optimizations> | ||
57 | + <OptimizationLevel Value="4"/> | ||
58 | + </Optimizations> | ||
59 | + </CodeGeneration> | ||
60 | + <Linking> | ||
61 | + <Debugging> | ||
62 | + <GenerateDebugInfo Value="False"/> | ||
63 | + <StripSymbols Value="True"/> | ||
64 | + </Debugging> | ||
65 | + <LinkSmart Value="True"/> | ||
66 | + <Options> | ||
67 | + <Win32> | ||
68 | + <GraphicApplication Value="True"/> | ||
69 | + </Win32> | ||
70 | + </Options> | ||
71 | + </Linking> | ||
72 | + </CompilerOptions> | ||
73 | + </Item3> | ||
74 | + </BuildModes> | ||
75 | + <PublishOptions> | ||
76 | + <Version Value="2"/> | ||
77 | + </PublishOptions> | ||
78 | + <RunParams> | ||
79 | + <local> | ||
80 | + <FormatVersion Value="1"/> | ||
81 | + </local> | ||
82 | + </RunParams> | ||
83 | + <RequiredPackages Count="2"> | ||
84 | + <Item1> | ||
85 | + <PackageName Value="FCL"/> | ||
86 | + </Item1> | ||
87 | + <Item2> | ||
88 | + <PackageName Value="LCL"/> | ||
89 | + </Item2> | ||
90 | + </RequiredPackages> | ||
91 | + <Units Count="15"> | ||
92 | + <Unit0> | ||
93 | + <Filename Value="experiment_runner.lpr"/> | ||
94 | + <IsPartOfProject Value="True"/> | ||
95 | + </Unit0> | ||
96 | + <Unit1> | ||
97 | + <Filename Value="form_matrixgame.pas"/> | ||
98 | + <IsPartOfProject Value="True"/> | ||
99 | + <ComponentName Value="FormMatrixGame"/> | ||
100 | + <HasResources Value="True"/> | ||
101 | + <ResourceBaseClass Value="Form"/> | ||
102 | + </Unit1> | ||
103 | + <Unit2> | ||
104 | + <Filename Value="README.md"/> | ||
105 | + <IsPartOfProject Value="True"/> | ||
106 | + </Unit2> | ||
107 | + <Unit3> | ||
108 | + <Filename Value="units/zmq_network.pas"/> | ||
109 | + <IsPartOfProject Value="True"/> | ||
110 | + </Unit3> | ||
111 | + <Unit4> | ||
112 | + <Filename Value="units/game_zmq_actors.pas"/> | ||
113 | + <IsPartOfProject Value="True"/> | ||
114 | + </Unit4> | ||
115 | + <Unit5> | ||
116 | + <Filename Value="units/game_actors.pas"/> | ||
117 | + <IsPartOfProject Value="True"/> | ||
118 | + </Unit5> | ||
119 | + <Unit6> | ||
120 | + <Filename Value="units/game_experiment.pas"/> | ||
121 | + <IsPartOfProject Value="True"/> | ||
122 | + </Unit6> | ||
123 | + <Unit7> | ||
124 | + <Filename Value="units/game_file_methods.pas"/> | ||
125 | + <IsPartOfProject Value="True"/> | ||
126 | + </Unit7> | ||
127 | + <Unit8> | ||
128 | + <Filename Value="units/game_resources.pas"/> | ||
129 | + <IsPartOfProject Value="True"/> | ||
130 | + </Unit8> | ||
131 | + <Unit9> | ||
132 | + <Filename Value="units/game_control.pas"/> | ||
133 | + <IsPartOfProject Value="True"/> | ||
134 | + </Unit9> | ||
135 | + <Unit10> | ||
136 | + <Filename Value="units/string_methods.pas"/> | ||
137 | + <IsPartOfProject Value="True"/> | ||
138 | + </Unit10> | ||
139 | + <Unit11> | ||
140 | + <Filename Value="units/game_actors_point.pas"/> | ||
141 | + <IsPartOfProject Value="True"/> | ||
142 | + </Unit11> | ||
143 | + <Unit12> | ||
144 | + <Filename Value="units/game_visual_elements.pas"/> | ||
145 | + <IsPartOfProject Value="True"/> | ||
146 | + </Unit12> | ||
147 | + <Unit13> | ||
148 | + <Filename Value="form_chooseactor.pas"/> | ||
149 | + <IsPartOfProject Value="True"/> | ||
150 | + <ComponentName Value="FormChooseActor"/> | ||
151 | + <HasResources Value="True"/> | ||
152 | + <ResourceBaseClass Value="Form"/> | ||
153 | + </Unit13> | ||
154 | + <Unit14> | ||
155 | + <Filename Value="units/csv_writer.pas"/> | ||
156 | + <IsPartOfProject Value="True"/> | ||
157 | + </Unit14> | ||
158 | + </Units> | ||
159 | + </ProjectOptions> | ||
160 | + <CompilerOptions> | ||
161 | + <Version Value="11"/> | ||
162 | + <Target> | ||
163 | + <Filename Value="experiment_runner"/> | ||
164 | + </Target> | ||
165 | + <SearchPaths> | ||
166 | + <IncludeFiles Value="$(ProjOutDir)"/> | ||
167 | + <Libraries Value="/usr/lib/gcc/x86_64-linux-gnu/4.9/"/> | ||
168 | + <OtherUnitFiles Value="units;../../dependency/delphizmq;../../units"/> | ||
169 | + <UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/> | ||
170 | + </SearchPaths> | ||
171 | + <Linking> | ||
172 | + <Options> | ||
173 | + <Win32> | ||
174 | + <GraphicApplication Value="True"/> | ||
175 | + </Win32> | ||
176 | + </Options> | ||
177 | + </Linking> | ||
178 | + <Other> | ||
179 | + <CustomOptions Value="-dUseCThreads"/> | ||
180 | + <OtherDefines Count="1"> | ||
181 | + <Define0 Value="UseCThreads"/> | ||
182 | + </OtherDefines> | ||
183 | + </Other> | ||
184 | + </CompilerOptions> | ||
185 | + <Debugging> | ||
186 | + <Exceptions Count="3"> | ||
187 | + <Item1> | ||
188 | + <Name Value="EAbort"/> | ||
189 | + </Item1> | ||
190 | + <Item2> | ||
191 | + <Name Value="ECodetoolError"/> | ||
192 | + </Item2> | ||
193 | + <Item3> | ||
194 | + <Name Value="EFOpenError"/> | ||
195 | + </Item3> | ||
196 | + </Exceptions> | ||
197 | + </Debugging> | ||
198 | +</CONFIG> |
@@ -0,0 +1,120 @@ | @@ -0,0 +1,120 @@ | ||
1 | +{ | ||
2 | + Stimulus Control | ||
3 | + Copyright (C) 2014-2016 Carlos Rafael Fernandes Picanço, Universidade Federal do Pará. | ||
4 | + | ||
5 | + The present file is distributed under the terms of the GNU General Public License (GPL v3.0). | ||
6 | + | ||
7 | + You should have received a copy of the GNU General Public License | ||
8 | + along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
9 | +} | ||
10 | +program experiment_runner; | ||
11 | + | ||
12 | +{$mode objfpc}{$H+} | ||
13 | + | ||
14 | +{$DEFINE DEBUG} | ||
15 | + | ||
16 | +uses | ||
17 | + {$IFDEF UNIX}{$IFDEF UseCThreads} | ||
18 | + cthreads, | ||
19 | + {$ENDIF}{$ENDIF} | ||
20 | + Interfaces // this includes the LCL widgetset | ||
21 | + {$IFDEF DEBUG} | ||
22 | + , Dialogs, FileUtil, LazFileUtils | ||
23 | + {$IFDEF LINUX} | ||
24 | + , BaseUnix | ||
25 | + {$ENDIF} | ||
26 | + {$ENDIF} | ||
27 | + , StrUtils, Forms, Classes, sysutils | ||
28 | + , form_matrixgame, game_actors | ||
29 | + , zhelpers, form_chooseactor | ||
30 | + ; | ||
31 | + | ||
32 | + | ||
33 | +var | ||
34 | + ApplicationPath, | ||
35 | + F : string; | ||
36 | + | ||
37 | +const | ||
38 | + PAdmin : array [0..3] of string = ('--admin','--adm','-admin','-adm'); | ||
39 | + PPlayer : array [0..3] of string = ('--player','--play','-player','-play'); | ||
40 | + PWatcher : array [0..3] of string = ('--watcher','--watch','-watcher','-watch'); | ||
41 | + | ||
42 | +{$R *.res} | ||
43 | + | ||
44 | + | ||
45 | +{$IFDEF DEBUG} | ||
46 | + function CreateDebugFoldersForPlayers:Boolean; | ||
47 | + var | ||
48 | + i : integer; | ||
49 | + begin | ||
50 | + Result := True; | ||
51 | + for i := 0 to 2 do | ||
52 | + begin | ||
53 | + if Pos(('Participant'), Application.ExeName) > 0 then | ||
54 | + Break; | ||
55 | + F := ApplicationPath+'Participant'+IntToStr(i+1); | ||
56 | + WriteLn(F); | ||
57 | + if ForceDirectoriesUTF8(F) then // ensure we have always the newer version for tests | ||
58 | + begin | ||
59 | + CopyFile(Application.ExeName,F+PathDelim+ApplicationName,[cffOverwriteFile]); | ||
60 | + {$IFDEF LINUX} | ||
61 | + FpChmod(F+PathDelim+ApplicationName,S_IRWXU); | ||
62 | + {$ENDIF} | ||
63 | + end | ||
64 | + else Result := False; | ||
65 | + end; | ||
66 | + end; | ||
67 | +{$ENDIF} | ||
68 | + | ||
69 | + function GetZMQNetworkID(var F:string):Boolean; | ||
70 | + var ID : TStringList; | ||
71 | + begin | ||
72 | + Result := True; | ||
73 | + ID := TStringList.Create; | ||
74 | + if FileExists(F) then | ||
75 | + try | ||
76 | + ID.LoadFromFile(F); | ||
77 | + F := Copy(ID.Text,0,Length(ID.Text)-2); | ||
78 | + finally | ||
79 | + ID.Free; | ||
80 | + end | ||
81 | + else | ||
82 | + try | ||
83 | + ID.Text := s_random(32); | ||
84 | + ID.SaveToFile(F); | ||
85 | + F := Copy(ID.Text,0,Length(ID.Text)-2); | ||
86 | + except | ||
87 | + on E: Exception do | ||
88 | + begin | ||
89 | + ID.Free; | ||
90 | + {$IFDEF DEBUG} | ||
91 | + ShowMessage(E.Message); | ||
92 | + {$ENDIF} | ||
93 | + Result := False; | ||
94 | + end; | ||
95 | + end; | ||
96 | + end; | ||
97 | + | ||
98 | +begin | ||
99 | + ApplicationPath := ExtractFilePath(Application.ExeName); | ||
100 | + {$IFDEF DEBUG} | ||
101 | + if not CreateDebugFoldersForPlayers then Exit; | ||
102 | + {$ENDIF} | ||
103 | + Application.Initialize; | ||
104 | + F := ApplicationPath+PathDelim+'id'; | ||
105 | + if not GetZMQNetworkID(F) then Exit; | ||
106 | + Application.CreateForm(TFormMatrixGame, FormMatrixGame); | ||
107 | + | ||
108 | + FormMatrixGame.SetID(F); | ||
109 | + if Paramcount > 0 then | ||
110 | + begin | ||
111 | + if AnsiMatchStr(lowercase(ParamStr(0)), PAdmin) then | ||
112 | + FormMatrixGame.SetGameActor(gaAdmin); | ||
113 | + if AnsiMatchStr(lowercase(ParamStr(0)), PPlayer) then | ||
114 | + FormMatrixGame.SetGameActor(gaPlayer); | ||
115 | + if AnsiMatchStr(lowercase(ParamStr(0)), PWatcher) then | ||
116 | + FormMatrixGame.SetGameActor(gaWatcher); | ||
117 | + end; | ||
118 | + Application.Run; | ||
119 | +end. | ||
120 | + |