Skip to content

Commit 1688b79

Browse files
committed
CHI: CheckInstallation is now aware of the installation configuration saved
In a previous commit the installer saves now information on the configuration. This is now evaluated by CHI_CheckInstallation and the output is adapted accordingly. XOPs required for hardware support are not checked if the installation was without hardware.
1 parent 866aecc commit 1688b79

File tree

1 file changed

+98
-6
lines changed

1 file changed

+98
-6
lines changed

Packages/MIES/MIES_CheckInstallation.ipf

+98-6
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ static StrConstant CHI_JSON_XOP_VERSION = "version-892-g9251933"
1616
static StrConstant CHI_TUF_XOP_VERSION = "version-163-g686effb"
1717
static StrConstant CHI_ITC_XOP_VERSION = "latest-174-gb9915a9"
1818

19+
static StrConstant CHI_INSTALLCONFIG_NAME = "installation_configuration.json"
20+
static Constant CHI_INSTALLDEFAULT_WITHHARDWARE = 1
21+
static StrConstant CHI_INSTALLDEFAULT_ALLUSER = "current"
22+
1923
/// @brief Collection of counters used for installation checking
2024
static Structure CHI_InstallationState
2125
variable numErrors
@@ -135,6 +139,83 @@ static Function CHI_CheckXOP(string &list, string item, string name, STRUCT CHI_
135139
endswitch
136140
End
137141

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+
138219
/// @brief Check the installation and print the results to the history
139220
///
140221
/// Currently checks that all expected/optional XOPs are installed.
@@ -144,7 +225,7 @@ Function CHI_CheckInstallation()
144225

145226
string symbPath, allFiles, path, extName, info, igorBuild
146227
string allFilesSystem, allFilesUser, listOfXOPs
147-
variable aslrEnabled, archBits
228+
variable aslrEnabled, archBits, installedWithHW
148229

149230
symbPath = GetUniqueSymbolicPath()
150231
extName = GetIgorExtensionFolderName()
@@ -223,6 +304,11 @@ Function CHI_CheckInstallation()
223304
printf "No\r"
224305
#endif // THREADING_DISABLED
225306

307+
printf "\rInstallation 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+
226312
printf "\rChecking base installation:\r"
227313

228314
SVAR miesVersion = $GetMiesVersion()
@@ -236,9 +322,11 @@ Function CHI_CheckInstallation()
236322
endif
237323

238324
#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
242330
#endif // WINDOWS
243331

244332
// one operation/function of each non-hardware XOP needs to be called in CheckCompilation_IGNORE()
@@ -253,7 +341,9 @@ Function CHI_CheckInstallation()
253341

254342
CHI_CheckJSONXOPVersion(state)
255343
#ifdef WINDOWS
256-
CHI_CheckITCXOPVersion(state)
344+
if(installedWithHW)
345+
CHI_CheckITCXOPVersion(state)
346+
endif
257347
#endif // WINDOWS
258348
CHI_CheckTUFXOPVersion(state)
259349

@@ -264,7 +354,9 @@ Function CHI_CheckInstallation()
264354
CHI_InitInstallationState(stateExtended)
265355
printf "\rChecking extended installation:\r"
266356

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
268360

269361
printf "Results: %d checks, %d number of errors\r", stateExtended.numTries, stateExtended.numErrors
270362
#endif // WINDOWS

0 commit comments

Comments
 (0)