private bool InitLicenseAndCallee() { short activationResult; nmsCOMcallee = new nmsQA5coreClass(); int tProcessId = nmsCOMcallee.nmsSDKgetProcessId(); string actCode = nmsQA5LicServer.nmsSRV_GetActivationLicense(ref tProcessId); if (!short.TryParse(actCode.Substring(0, 4), out activationResult)) activationResult = 0; if (activationResult == NMS_SDKERROR_LICENSERENEWNEEDEDNOW) { Console.WriteLine("The system requires re-licensing to operate!"); Marshal.ReleaseComObject(nmsCOMcallee); nmsCOMcallee = null; return false; } if (activationResult == NMS_SDKERROR_PROTECTIONERROR) { Console.WriteLine("The activation license could not be generated due to a protection error!"); Marshal.ReleaseComObject(nmsCOMcallee); nmsCOMcallee = null; return false; } if (activationResult == NMS_SDKERROR_OPERATIONNOTALLOWED) { Console.WriteLine("The activation license could not be generated because too many processes are already running. Please wait until one of the other calls is ended, and obtain a license again"); Marshal.ReleaseComObject(nmsCOMcallee); nmsCOMcallee = null; return false; } switch (nmsCOMcallee.nmsInitCore(ref actCode, ref lioDataSEGMENTfile, ref defOwner)) { case NMS_OK: break; case NMS_LIOERROR_FILENOTFOUND: Console.WriteLine("Error LioNet file missing - Deal here with Missing LioNet files"); Marshal.ReleaseComObject(nmsCOMcallee); nmsCOMcallee = null; return false; case NMS_LIONET_CREATED_OK: Console.WriteLine("New LioNet file created!"); break; default: { actCode = nmsQA5LicServer.nmsSRV_GetActivationLicense(ref tProcessId); int nmsInitCoreResult = nmsCOMcallee.nmsInitCore(ref actCode, ref lioDataSEGMENTfile, ref defOwner); switch (nmsInitCoreResult) { case NMS_SDKERROR_UNSPECIFIED: Console.WriteLine("An unspecified type of error occurred. The operation will now abort."); Marshal.ReleaseComObject(nmsCOMcallee); nmsCOMcallee = null; return false; case NMS_SDKERROR_PROTECTIONERROR: Console.WriteLine("The Activation License was not valid. The operation will now abort."); Marshal.ReleaseComObject(nmsCOMcallee); nmsCOMcallee = null; return false; } Console.WriteLine("Error initializing QA5COM. Error: {0}.", nmsInitCoreResult); Marshal.ReleaseComObject(nmsCOMcallee); nmsCOMcallee = null; return false; } } return true; }
private bool InitQA5Core() { try { nmsQA5LicServer = new nmsQA5coreClass(); short nmsSRV_INITResult = nmsQA5LicServer.nmsSRV_INIT(ref defOwner); if (nmsSRV_INITResult != 0) { if (nmsSRV_INITResult == NMS_SDKERROR_PROTECTIONERROR) { Console.WriteLine("Plug Not found, or general security error."); } if (nmsSRV_INITResult != NMS_SDK_LICENSERENEWNEEDED) { Console.WriteLine("ERROR initializing SDK Server. Error Code:" + nmsSRV_INITResult); } if (nmsSRV_INITResult == NMS_SDKERROR_LICENSERENEWNEEDEDNOW) { Console.WriteLine("SDK Error. License renew needed"); } if (nmsSRV_INITResult != NMS_SDK_LICENSERENEWNEEDED) { return false; } } nmsLioNet = new nmsLioNetV6Class(); } catch (Exception exception) { Console.WriteLine(exception.Message); return false; } return true; }
private bool ConfigureCoreForItsDesignatedTasks() { int nmsConfigTestDataResult; short waveOutSamplesPerSecond = 11025; short backgroundLevel = 1000; short lengthOfSegmentInSeconds = 1; short calibrationType = 5; /* Configure the background noise. Default 1000 */ nmsConfigTestDataResult = nmsCOMcallee.nmsConfigTestData(ref waveOutSamplesPerSecond, ref backgroundLevel, ref lengthOfSegmentInSeconds, ref calibrationType); if (nmsConfigTestDataResult != 0) { if (nmsConfigTestDataResult == NMS_SDKERROR_WAVESMPRATEWRONG) { Console.WriteLine("The wave format provided is not supported. The operation will now abort."); Marshal.ReleaseComObject(nmsCOMcallee); nmsCOMcallee = null; return false; } Console.WriteLine("An error was detected while configuring the core. The operation will now abort. Error = {0}", nmsConfigTestDataResult); Marshal.ReleaseComObject(nmsCOMcallee); nmsCOMcallee = null; return false; } nmsCOMcallee.nmsQA_ConfigUse(); nmsCOMcallee.nmsSD_ConfigStressCL(); nmsCOMcallee.nmsBordersLoad(ref bordersFileName); bool bActive = true; nmsCOMcallee.nmsBordersSetConfig(ref bActive); return true; }
private bool ConfigureCoreForItsDesignatedTasks() { int nmsConfigTestDataResult; short lengthOfSegmentInSeconds; short calibrationType = ui.GetCalibrationType(); if (ui.GetAnalysisType() == 1) calibrationType = (short) (calibrationType + 2); short backgroundLevel = ui.GetBackgroundLevel(); if (ui.IsOneSecondBufferUsed()) { lengthOfSegmentInSeconds = 1; nmsConfigTestDataResult = nmsCOMcallee.nmsConfigTestData(ref waveOutSamplesPerSecond, ref backgroundLevel, ref lengthOfSegmentInSeconds, ref calibrationType); } else { lengthOfSegmentInSeconds = 2; nmsConfigTestDataResult = nmsCOMcallee.nmsConfigTestData(ref waveOutSamplesPerSecond, ref backgroundLevel, ref lengthOfSegmentInSeconds, ref calibrationType); } if (nmsConfigTestDataResult != 0) { if (nmsConfigTestDataResult == NMS_SDKERROR_WAVESMPRATEWRONG) { ui.ShowMessage("The wave format provided is not supported. The operation will now abort."); Marshal.ReleaseComObject(nmsCOMcallee); nmsCOMcallee = null; return false; } ui.ShowMessage( string.Format( "An error was detected while configuring the core. The operation will now abort. Error = {0}", nmsConfigTestDataResult)); Marshal.ReleaseComObject(nmsCOMcallee); nmsCOMcallee = null; return false; } nmsCOMcallee.nmsQA_ConfigUse(); nmsCOMcallee.nmsSD_ConfigStressCL(); nmsCOMcallee.nmsBordersLoad(ref bordersFileName); bool bActive = true; nmsCOMcallee.nmsBordersSetConfig(ref bActive); return true; }