@@ -16,6 +16,10 @@ static StrConstant CHI_JSON_XOP_VERSION = "version-892-g9251933"
16
16
static StrConstant CHI_TUF_XOP_VERSION = "version-163-g686effb"
17
17
static StrConstant CHI_ITC_XOP_VERSION = "latest-174-gb9915a9"
18
18
19
+ static StrConstant CHI_INSTALLCONFIG_NAME = "installation_configuration.json"
20
+ static Constant CHI_INSTALLDEFAULT_WITHHARDWARE = 1
21
+ static StrConstant CHI_INSTALLDEFAULT_ALLUSER = "current"
22
+
19
23
/// @brief Collection of counters used for installation checking
20
24
static Structure C HI_InstallationState
21
25
variable numErrors
@@ -135,6 +139,83 @@ static Function CHI_CheckXOP(string &list, string item, string name, STRUCT CHI_
135
139
endswitch
136
140
End
137
141
142
+ /// @return JSON id or NaN if configuration file does not exist
143
+ static Function CHI_LoadInstallationConfiguration ()
144
+
145
+ string folder, fullFilePath, txt
146
+
147
+ folder = ParseFilePath ( 1, FunctionPath ( "" ) , ":" , 1, 2 )
148
+ fullFilePath = folder + CHI_INSTALLCONFIG_NAME
149
+ if ( ! FileExists ( fullFilePath))
150
+ return NaN
151
+ endif
152
+ [ txt, fullFilePath] = LoadTextFile ( fullFilePath)
153
+ return JSON_Parse ( txt, ignoreErr = 1 )
154
+ End
155
+
156
+ /// @param key key in JSON tree under /Installation
157
+ /// @param defValue [optional] default value to return if the key does not exist. Either defValue or defSValue can be given as argument, not both.
158
+ /// @param defSValue [optional] default value to return if the key does not exist. Either defValue or defSValue can be given as argument, not both.
159
+ /// @return either value or sValue depending on requested JSOn key, the unused result value is either Nan or "".
160
+ static Function [variable value, string sValue] CHI_GetInstallationConfigProp ( string key, [ variable defValue, string defSValue] )
161
+
162
+ variable jsonId, objType
163
+ string jPath
164
+
165
+ ASSERT (( ParamIsDefault ( defValue) + ParamIsDefault ( defSValue)) == 1, "Either defValue or defSValue must be given" )
166
+
167
+ jsonId = CHI_LoadInstallationConfiguration ()
168
+ if ( IsNaN ( jsonId))
169
+ if ( ParamIsDefault ( defValue))
170
+ return [ NaN , defSValue]
171
+ endif
172
+ return [ defValue, "" ]
173
+ endif
174
+
175
+ jPath = "/Installation/" + key
176
+
177
+ ClearRTError ()
178
+ try
179
+ objType = JSON_GetType ( jsonId, jPath)
180
+ catch
181
+ ASSERT ( 0, "The following path could not be found in installation configuration: " + jPath)
182
+ endtry
183
+ if ( objType == JSON_NUMERIC)
184
+ value = JSON_GetVariable ( jsonId, jPath)
185
+ JSON_Release ( jsonId)
186
+ return [ value, "" ]
187
+ elseif ( objType == JSON_STRING)
188
+ sValue = JSON_GetString ( jsonId, jPath)
189
+ JSON_Release ( jsonId)
190
+ return [ NaN , sValue]
191
+ endif
192
+
193
+ ASSERT ( 0, "Unsupported JSON object type" )
194
+ End
195
+
196
+ /// @return 1 if MIES was installed with hardware support, 0 otherwise
197
+ Function CHI_IsMIESInstalledWithHardware ()
198
+
199
+ variable installedWithHW
200
+ string s
201
+
202
+ [ installedWithHW, s] = CHI_GetInstallationConfigProp ( "WithHardware" , defValue = CHI_INSTALLDEFAULT_WITHHARDWARE)
203
+
204
+ return installedWithHW
205
+ End
206
+
207
+ /// @return 1 if MIES was installed for all users, 0 otherwise
208
+ Function CHI_IsMIESInstalledForAllUsers ()
209
+
210
+ variable value
211
+ string installType
212
+
213
+ [ value, installType] = CHI_GetInstallationConfigProp ( "User" , defSValue = CHI_INSTALLDEFAULT_ALLUSER)
214
+ ASSERT ( ! CmpStr ( installType, "current" ) || ! CmpStr ( installType, "all" ) , "Read unknown installation type from installation configuration" )
215
+
216
+ return ! CmpStr ( installType, "all" )
217
+ End
218
+
138
219
/// @brief Check the installation and print the results to the history
139
220
///
140
221
/// Currently checks that all expected/optional XOPs are installed.
@@ -144,7 +225,7 @@ Function CHI_CheckInstallation()
144
225
145
226
string symbPath, allFiles, path, extName, info, igorBuild
146
227
string allFilesSystem, allFilesUser, listOfXOPs
147
- variable aslrEnabled, archBits
228
+ variable aslrEnabled, archBits, installedWithHW
148
229
149
230
symbPath = GetUniqueSymbolicPath ()
150
231
extName = GetIgorExtensionFolderName ()
@@ -223,6 +304,11 @@ Function CHI_CheckInstallation()
223
304
printf "No\r "
224
305
#endif // THREADING_DISABLED
225
306
307
+ printf "\r Installation Configuration:\r "
308
+ installedWithHW = CHI_IsMIESInstalledWithHardware ()
309
+ printf " Installation with hardware: %s\r " , ToTrueFalse ( installedWithHW)
310
+ printf " Installated for all users: %s\r " , ToTrueFalse ( CHI_IsMIESInstalledForAllUsers ())
311
+
226
312
printf "\r Checking base installation:\r "
227
313
228
314
SVAR miesVersion = $ GetMiesVersion ()
@@ -236,9 +322,11 @@ Function CHI_CheckInstallation()
236
322
endif
237
323
238
324
#ifdef WINDOWS
239
- CHI_CheckXOP ( listOfXOPs, "itcxop2-64.xop" , "ITC XOP" , state)
240
- CHI_CheckXOP ( listOfXOPs, "AxonTelegraph64.xop" , "Axon Telegraph XOP" , state)
241
- CHI_CheckXOP ( listOfXOPs, "MultiClamp700xCommander64.xop" , "Multi Clamp Commander XOP" , state)
325
+ if ( installedWithHW)
326
+ CHI_CheckXOP ( listOfXOPs, "itcxop2-64.xop" , "ITC XOP" , state)
327
+ CHI_CheckXOP ( listOfXOPs, "AxonTelegraph64.xop" , "Axon Telegraph XOP" , state)
328
+ CHI_CheckXOP ( listOfXOPs, "MultiClamp700xCommander64.xop" , "Multi Clamp Commander XOP" , state)
329
+ endif
242
330
#endif // WINDOWS
243
331
244
332
// one operation/function of each non-hardware XOP needs to be called in CheckCompilation_IGNORE()
@@ -253,7 +341,9 @@ Function CHI_CheckInstallation()
253
341
254
342
CHI_CheckJSONXOPVersion ( state)
255
343
#ifdef WINDOWS
256
- CHI_CheckITCXOPVersion ( state)
344
+ if ( installedWithHW)
345
+ CHI_CheckITCXOPVersion ( state)
346
+ endif
257
347
#endif // WINDOWS
258
348
CHI_CheckTUFXOPVersion ( state)
259
349
@@ -264,7 +354,9 @@ Function CHI_CheckInstallation()
264
354
CHI_InitInstallationState ( stateExtended)
265
355
printf "\r Checking extended installation:\r "
266
356
267
- CHI_CheckXOP ( listOfXOPs, "NIDAQmx64.xop" , "NI-DAQ MX XOP" , stateExtended, expectedHash = CHI_NIDAQ_XOP_64 _HASH)
357
+ if ( installedWithHW)
358
+ CHI_CheckXOP ( listOfXOPs, "NIDAQmx64.xop" , "NI-DAQ MX XOP" , stateExtended, expectedHash = CHI_NIDAQ_XOP_64 _HASH)
359
+ endif
268
360
269
361
printf "Results: %d checks, %d number of errors\r " , stateExtended. numTries, stateExtended. numErrors
270
362
#endif // WINDOWS
0 commit comments