#AutoIt3Wrapper_au3check_parameters=-q -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #RequireAdmin ;The parameters set the app behaviour as follows: ; -q : quiet mode (this will only show errors and warnings) ; -d : set the "MustDeclareVars" option to True ; -w 1 : give a warning if an include file is included more than once ; -w 2 : give a warning if #comments-end (or #ce) is missing ; -w 3 : give a warning if variables are already declared ; -w 4 : give a warning if local variables are used in the global scope ; -w 5 : give a warning if a local variable is declared but not used ; -w 6 : give a warning when using Dim ; -w 7 : give a warning if ByRef parameters are incorrect #include-once #cs --------------------------------------------------------------------------------------------------------------------------- AutoIt Version: 3.3.16.1 Author: John Powers Script Function: Manages the control of an Anritsu MT8801 analyser through a radio equipment test sequence Assumes: The Analyser is switched to Local mode, connected to RS232 via a CH340 USB to Serial adaptor. (Not tested with other adaptors) Revisions: v1.00 19/06/2023 Original Notes: ;GUI Run/Pause/Resume/Restart/Stop Method: ;https://www.autoitscript.com/forum/topic/200355-pause-resume-gui-button-help/ ;https://www.autoitscript.com/forum/profile/105171-yirrlaar/ ;Results box: ;https://www.autoitscript.com/forum/topic/110948-add-text-to-edit-box-and-scroll-it-down/ ;https://www.autoitscript.com/forum/profile/38576-melba23/ ;Redraw GUI ;https://www.autoitscript.com/forum/topic/80881-force-updateredraw-gui/ ;https://www.autoitscript.com/forum/profile/37937-szhlopp/ ;_WinAPI_RedrawWindow ($GUI) ; Also sends $WM_PAINT ;GUISetBkColor(0xF0F0F0) ;Both redraw the window :) ; Setup up RS232 ; Reset analyser ; Configure analyser (inc set date and time) ; Request radio model and load default test information from Anritsu.ini ; Set up CAT and set CAT/Manual flag ; Prompt for connections to radio ; Capture protection attenuation value ; Capture radio serial info ; (Select tests to be done) ; For each band ; Select frequency/antenna socket ; For each mode ; RX Tests set by ini and test selector ; TX tests (ditto) ; Exit to request radio model ; output ini file to excel file (text file initially) ;Test classifications 01=Zero Beat 02=10dB SN 03=12dB SINAD 04=S1 05=S5 06=S9 07=RX 6dB Low 08=RX 6dB High 51=Power High 52=Power Hold 53=Power Medium 54=Power Low 55=Max Spurious 56=2nd Harmonic 57=3rd Harmonic 58=RX 6dB Low 59=RX 6dB High 60=Max deviation 61=Max modulation depth ;Need max RX level stop/protection ;Need warnin/capture of Protection Attenuator value ;Compliance ; Does it comply with power regulations, frequency restrictions, max modulation, interference, receive on transmit frequencies ; TX Power ; Tx Frequency ; TX Bandwidth ; TX Spurious / Harmonics ; RX at -100dBm ;Performance ; Does the receiver sensitivity / transmit power meet spec? ; What are the filter widths and frequency errors ; All of the tests ; For each band ; Select frequency/antenna socket ; For each mode ; RX Tests set by ini and test selector ;RX_Test_SN() ;RX_Test_S1() ;RX_Test_S5() ;RX_Test_S9() ;RX_Test_6dBlo() ;RX_Test_6dBhi() ;RX_Test_BW() ;RX_Test_dVFO() ; TX tests (ditto) ;TX_Test_PWRmax() ;TX_Test_PWRdroop() ;TX_Test_PWRmed() ;TX_Test_PWRmin() ;TX_Test_Purity() ;TX_Test_Spurious() ;TX_Test_Mod() ;TX_Test_Frequency() ;TX_Test_BW() ; Exit to request radio model ;FM SINAD - set deviation to 12.5% of channel spacing (3.125, 1.5625) @ 1kHz mod frequency (ETSI spec) ;CW SINAD - set output frequency beat note to match mod frequency {SINAD filter centre) but no mod. SNR = SINAD ;AM/SSB should have mod .. these will be estimates SNR ~ SINAD ;System $aSYS ;Configuration ;Sig genny settings $aRFGENfix, $aRFGENvar ;Configuration - fixed settings, for info ;RF frequency - volatile ;RF level ;AF frequency ;AF level ;Audio settings $aAFMONfix, $aAFMONvar ;Configuration - fixed settings, for info ;SINAD - volatile ;Level ;Frequency ;Transmitter settings £aRFMONfix, £aRFMONvar ;Configuration - fixed settings, for info ;Power - volatile ;Modulation ;Frequency ;Spectrum Analyser functions, centre, span ;Quick check If _ArrayToString($aOne) == _ArrayToString($aTwo) Then NoChange ;Otherwise need to elements If $aOne[n] == $aTwo[n] Then NoChange ;Antenna (and similar) checks ; Separate ini section for band to antenna ; when starting tests, request which antenna is in use for the band (if there are options) ; when changing band, check that selected antenna is in the list of options and validate that it's still in use ; if not in the list, request which antenna is in use (if there are options) If Ant contains one option: Light up that setting If ant in use = option then auto confirm and continue If not then request check and wait for confirm. Then continue If Ant contains more than one option: If ant in use = any of the options then Light up that option Request check and wait for confirm. Then continue If any other option is clicked, select that, change ant in use and continue If not then request check and wait for confirm. Then continue ;--> If there's more than one antenna for the band... Ask which antenna is to be used/confirm correct antenna selection if one was previously used, set that to unconf, others to available If none previously used, then set all to available If there's only one, and it's the same as the last one then auto confirm If there's only one, and it's not the same as the last one then ask #ce --------------------------------------------------------------------------------------------------------------------------- ;****************************************************************************************************************************** ;Step 1 - Program Setup ;****************************************************************************************************************************** ;============================================================================================================================== #Region Include ;============================================================================================================================== ;Include supplementary function blocks, bundled with AutoIT 3.3.16.1 unless otherwise attributed #include ;#include ;#Include #include #include #include ; tba; Calls also CommAPI.au3 (ComAPIConstants.au3), CommAPIHelper.au3 and CommUtilities.au3; (https://www.autoitscript.com/forum/profile/82356-therealhanuta/) #include <_CommAPI_GetPorts.au3> ; Javier Perez (https://www.autoitscript.com/forum/profile/117498-javiermdq/) ;#include ;#include #include #include ;#include ; Jos (https://www.autoitscript.com/forum/profile/19-j ;#include ;#include #include ;#include #include ; g0gcd (https://www.autoitscript.com/forum/profile/67254-g0gcd/) ; #include #include #include #include #Include #include ;#include ;#include ;#include ; Ward (https://www.autoitscript.com/forum/profile/10768-ward/) ;#include ;#include ;#include ;#include <_pop3.au3> ; Apzo (https://www.autoitscript.com/forum/profile/4782-apzo/) ;#include ; PSaltyDS (https://www.autoitscript.com/forum/topic/70538-_processlistproperties/ ;#include ; JiBe (https://www.autoitscript.com/forum/profile/36446-jibe/) ;#Include #Include ;#include ;#include ;#include ; Realm (https://www.autoitscript.com/forum/profile/35742-realm/) ;#Include ; DanySys (https://www.autoitscript.com/forum/profile/71248-danyfirex/) ;DanySys 30/05/22 #Include ;#include ;#include #include ;#include <_Anritsu_Helper.au3> ;#include <_Anritsu_Helper_Constants.au3> ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #EndRegion Include ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ;============================================================================================================================== #Region Initialisation ;============================================================================================================================== ;Time critical setup ;Note start time for later use Global $hTimer_ProcessStart = TimerInit() ;_Log($LogTab & "_Initialisation: Anritsu process triggered.") FileWrite(StringTrimRight(@ScriptFullPath,3) & "run", "Running") ;Protect against multiple instances of this script ;If _Singleton(@ScriptName, 1) = 0 Then ; Msgbox(0,"Warning","An occurence of " & @Scriptname & " is already running", 5) ; Exit ;EndIf ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #EndRegion Initialisation ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ;============================================================================================================================== #Region Set_AutoIT_Options ;============================================================================================================================== ;default value is listed first in comment ;HotKeys and Timing ;HotKeySet("{PAUSE}", "TogglePause") ;HotKeySet("{ESC}", "Terminate") ;HotKeySet("+!d", "ShowMessage") ;Shift-Alt-d ;Autoit Options ;AutoITSetOption("CaretCoordMode", 1) ;1=absolute, 0=relative, 2=client ;AutoITSetOption("ExpandEnvStrings", 0) ;0=don't expand, 1=do expand ;AutoITSetOption("ExpandVarStrings", 0) ;0=don't expand, 1=do expand ;AutoITSetOption("GUICloseOnESC", 1) ;1=ESC closes, 0=ESC won't close ;AutoITSetOption("GUICoordMode", 1) ;1=absolute, 0=relative, 2=cell ;AutoITSetOption("GUIDataSeparatorChar", "|") ;"|" ;AutoITSetOption("GUIOnEventMode", 0) ;0=disabled, 1=OnEvent mode enabled ;AutoITSetOption("GUIResizeMode", 0) ;0=no resizing, <1024 special resizing ;AutoITSetOption("GUIEventOptions", 0) ;0=default, 1=just notification, 2=GUICtrlRead tab index ;AutoItSetOption("MouseClickDelay", 10) ;10 ;AutoITSetOption("MouseClickDownDelay", 10) ;10ms ;AutoITSetOption("MouseClickDragDelay", 250) ;250ms AutoITSetOption("MouseCoordMode", 1) ;1=absolute, 0=relative, 2=client AutoITSetOption("MustDeclareVars", 0) ;0=no, 1=require pre-declaration AutoITSetOption("PixelCoordMode", 1) ;1=absolute, 0=relative, 2=client ;AutoITSetOption("SendAttachMode", 0) ;0=don't attach, 1=do attach ;AutoITSetOption("SendCapslockMode", 1) ;1=store and restore, 0=don't AutoItSetOption("SendKeyDelay", 1) ;5ms ;AutoItSetOption("SendKeyDownDelay", 1) ;1ms ;AutoITSetOption("TCPTimeout", 100) ;100ms ;AutoITSetOption("TrayAutoPause", 1) ;0=no pause, 1=Pause AutoITSetOption("TrayIconDebug", 1) ;0=no info, 1=debug line info ;AutoITSetOption("TrayIconHide", 0) ;0=show, 1=hide tray icon ;AutoITSetOption("TrayMenuMode", 0) ;0=append, 1=no default menu, 2=no automatic check, 4=menuitemID not return ;AutoITSetOption("TrayOnEventMode", 0) ;0=disable, 1=enable ;AutoITSetOption("WinDetectHiddenText", 0) ;0=don't detect, 1=do detect ;AutoITSetOption("WinSearchChildren", 1) ;0=no, 1=search children also ;AutoITSetOption("WinTextMatchMode", 1) ;1=complete, 2=quick ;AutoITSetOption("WinTitleMatchMode", 1) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase ;AutoItSetOption("WinWaitDelay", 250) ;250ms ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #EndRegion Set_AutoIT_Options ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ;============================================================================================================================== #Region Set_Global_Variables ;============================================================================================================================== ;Parameters used in processing ;Non configurable ;---------------- ;These are either global definitions or are set by the environment around the program. They cannot. therefore, be modified by configuration. ;Environment -----------------------------------------------------------; ;Global $sRunTime = _NowCalc() ; used for LastRun=YYYY/MM/DD HH:MM:SS ;Script variables ;Global $Paused, $Mousespeed, $MacroSpeed ;Abbreviations ;Global $CR = Chr(13) & Chr(10) ; Shortcodes for ASCII string Line Endings ;Global $HCR = "
" ; Shortcode for HTML string Line Endings ;Global $q = Chr(34) ; Used to handle quote mark " Global $ScriptName = StringTrimRight(@ScriptName, 4) ; Core ScriptName (no extension) Global $ScriptFullPath = StringTrimRight(@ScriptFullPath,4); Core ScriptFullPath (no extension) ;Command Processor ;Global $CMD = @ComSpec ; Location and state of command processor ;Folder Structure (not configurable) ;Fixed / implied configuration. These are all configured/adjusted by running the script in the required location. ;Global $CMID = "Cumulus" ; Weather station interface program name. CMID is fixed as "Cumulus" and is UNLIKELY to be changed! ;Global $CMName = $CMID & ".exe" ;System Folder Structure ;Global $NNID = StringTrimRight(@ScriptName, 4) ; Control program name root. $NNID is fixed to the name of this script (and has no extension) ;Global $NNName = $NNID & ".exe" ; $NNName is the name of the compiled version of the script ;Global $NNRoot = _g0gcd_Terminate(@ScriptDir, "\") ; Using where $NNName is installed, determine $NNRoot ;Global $NNDrive = StringLeft($NNRoot,3) ; .. and $NNDrive ;Global $NNIniFilename = $NNRoot & $NNID & ".ini" ; Filename for the configuration file, based on/constrained by script name and location Global $sIniFilename = $ScriptFullPath & ".ini" _g0gcd_IniFile("[O]Name", $ScriptName,"Config",$sIniFilename) ;Configurable. ;------------- ;The defaults below may be adjusted by changing entries in the .ini file. Only Global veriables below; local configurations are set up in the individual procedures. ; WHILE CONFIGURATION ENTRIES ARE "[O]....", THE CONFIGURATION IS CONTROLLED BY THE PROGRAM. CHANGE TO "[C]" FOR .INIFILE CONFIGURATION ;Processing Support ----------------------------------------------------; ;Debugging Control Global $dBugLog = True ; Turns on debug logging. Global $LogTab = " " ;Global $dBugTidy = True ; If true, removes working files after run. Global $dBug_NoAnalyser = True If(_g0gcd_IniFile("[R]NO_ANALYSER", "") = "NotFound") Then $dBug_NoAnalyser = False ;System Folder Structure ;Global $NNDataStore = $NNRoot & "Data\" ; Path to the Control Data Store ;System Filenames Global $sLogFilename = $ScriptFullPath & ".log" _g0gcd_IniFile("[O]LogFilename", $sLogFilename) ;Main Panel Definition (G0) Global $hGUI Global $iGUI_Width = _g0gcd_IniFile("[O]MainPanel_W", "1720") Global $iGUI_Height = _g0gcd_IniFile("[O]MainPanel_H", "800") Global $iGUI_Left = _g0gcd_IniFile("[O]MainPanel_L", "100") Global $iGUI_Top = _g0gcd_IniFile("[O]MainPanel_T", "50") ;Main Panel Control grid Global $aCol[0] ; Holds Left values for cells [index is column number] Global $aRow[0] ; Holds Top values for cells [index is row number] Global $aH[0] ; Holds Height values for cells [index is for multiples of height 1 = single, 2 = double, etc) Global $aW[0] ; Holds Width values for cells [index is for multiples of width 1 = single, 2 = double, etc) Global $iUnitCellWidth = 30 Global $iUnitCellHeight = 30 Global $iCellLeftMargin = 15 Global $iCellTopMargin = 60 Global $iCellHGutter = 5 Global $iCellVGutter = 5 _Set_GUICtrlLayoutGrid($aCol, $aW, $iUnitCellWidth, $iCellLeftMargin, $iCellHGutter, $iGUI_Width) _Set_GUICtrlLayoutGrid($aRow, $aH, $iUnitCellHeight, $iCellTopMargin, $iCellVGutter, $iGUI_Height) ;Enumerate controls Global Enum Step 1 $cFull, $cShow, $cHide, $cConf, $cAvailable, $cUnConf ; Operations Global Enum Step 1 $cPMask, $cPStat, $cFProg, $cAPAdb, $cRFreq, $cRMode, $cRAnt0, $cRAnt1, $cRAnt2, $cRAnt3, $cRAnt4, $cEndOfList1 Global Enum Step 1 $cAll = -1, $cTitle, $cMessage, $cConfirm, $cButton, $cInUse, $cEndOfList2 ; Controls Global $aPanel[$cEndOfList1][$cEndOfList2] ; Holds information about the panel controls Global $cOK = "OK" ; Confirmation text Global $cQY = "?" ; Query text Global $cCentered = BitOR($SS_CENTER, $SS_CENTERIMAGE) ; Horizontal and vertical centring Global $cLefted = BitOR($SS_LEFT, $SS_CENTERIMAGE) ; Left justified, vertically centred Global $_HIDE = $GUI_DISABLE + $GUI_HIDE Global $_SHOW = $GUI_DISABLE + $GUI_SHOW Global $_FULL = $GUI_ENABLE + $GUI_SHOW ;Main Panel Title Global $hTitle Global $sTitle_Caption = _g0gcd_IniFile("[O]MainPanel_Title", "Anritsu MT8801 Radio Test Set Controller") Global $iTitle_Caption_FontSize = 30 ;Test Process control buttons and flags Global $hRun Global $hPause Global $hResume Global $hRestart Global $hStop Global $hKill Global $bRun_press = False Global $bPause_press = False Global $bResume_press = False Global $bRestart_press = False Global $bStop_press = False Global $bKill_press = False ;Test Process control variables Global $bSHUTDOWN = False Global $bTESTING_ENABLED = False Global $hAResultsList Global $sResultFile Global $sItems Global $sFullTestList Global $sCurrentTestCode Global $iTestCount ;Analyser Status Information boxes Global $hAStatusTitle Global $hAStatusMessage Global $hAFrequencyTitle Global $hAFrequencyMessage Global $hAOLVLTitle Global $hAOLVLMessage Global $hASINADTitle Global $hASINADMessage Global $hARFPortTitle Global $hARFPortMessage ;Protection Attenuator Global $sMT8801_RFPort ; Holds MT8801 RF Port setting Global $PAdBValue ; Protection attenutator Global $APAdBMin Global $APAdBLastUsed = _g0gcd_IniFile("[R]ProtectionAttenuatorLastUsedValue","30dB") Global $APAdBAvailableValues = _g0gcd_IniFile("[O]ProtectionAttenuatorAvailableValues", _ "0dB|5dB|10dB|15dB|20dB|25dB|30dB|35dB|40dB|45dB|50dB|55dB|60dB") ; Protection Attenuator selection box Global $hAPAdBSelectTitle Global $hAPAdBSelectMessage Global $hAPAdBSelect ;Radio_Type list box Global $hRTypeList Global $iRTypeList_Style = _g0gcd_IniFile("[O]PanelList1_Style", BitOR($LBS_STANDARD, $LBS_EXTENDEDSEL)) Global $aSelectedItems ;Radio_Type Select button Global $hRTypeSelect Global $bRTypeSelect_press = False Global $sRTypeSelect_Caption = _g0gcd_IniFile("[O]PanelButt1_Caption","Select") ;Radio Frequency Global $sRFreqInUse = 0 ;Radio Mode Global $sRModeInUse = "-" ;Radio Antenna Global $sAnt1 Global $sAnt2 Global $sAnt3 Global $sAnt4 Global $sRAntInUse = "-" ;Processing Variables Global $Result Global $sRadio_Type = "" Global $DEVICE_ENABLED = False Global $MT8801_ENABLED = False ;Information Lookup Global $aSpecific_Bands = IniReadSection($sIniFilename,"Bands") Global $aSpecific_Modes = IniReadSection($sIniFilename,"Modes") Global $aSpecific_Ports = IniReadSection($sIniFilename,"Ports") Global $aSpecific_Tests = IniReadSection($sIniFilename,"Tests") Global $sTestList Global $aFullTestList[1][3] ;Holds the test definitions, [testcode][antenna][spec] ;Device port parameters. These may not exist for none CAT enabled radios. Need to handle these on a per radio basis. ;The CAT interface may be installed (per analyser run) but not be needed, so shouldn't be mandatory, like MT8801 connection.... Global $iRCATPortNo = _g0gcd_IniFile("[O]DevCatPort_Number","1","Config") ;Overwritten by _ACOMM() Global $iRCATPortBaud = _g0gcd_IniFile("[O]DevCatPort_BaudRate","9600") Global $iRCATPortParity = _g0gcd_IniFile("[O]DevCatPort_ParityBit","None") Global $iRCATPortByteSize = _g0gcd_IniFile("[O]DevCatPort_ByteSize","8") Global $iRCATPortStopBits = _g0gcd_IniFile("[O]DevCatPort_StopBits","One") Global $iRCATPortFlowXon = _g0gcd_IniFile("[O]DevCatPort_Xon","On") ; X-on/X-off flow control enabled Global $iRKEYPortNo = _g0gcd_IniFile("[O]DevKeyPort_Number","1","Config") ;Overwritten by _ACOMM() Global $iRKEYPortBaud = _g0gcd_IniFile("[O]DevKeyPort_BaudRate","9600") Global $iRKEYPortParity = _g0gcd_IniFile("[O]DevKeyPort_ParityBit","None") Global $iRKEYPortByteSize = _g0gcd_IniFile("[O]DevKeyPort_ByteSize","8") Global $iRKEYPortStopBits = _g0gcd_IniFile("[O]DevKeyPort_StopBits","One") Global $iRKEYPortFlowXon = _g0gcd_IniFile("[O]DevKeyPort_Xon","On") ; X-on/X-off flow control enabled ;Serial Port Configuration Global $hMT8801COMPort Global $iAPortNo = _g0gcd_IniFile("[C]MT8801Port_Number","1","Config") ;Overwritten by _ACOMM() Global $iAPortBaud = _g0gcd_IniFile("[C]MT8801Port_BaudRate","9600") Global $iAPortParity = _g0gcd_IniFile("[C]MT8801Port_ParityBit","None") Global $iAPortByteSize = _g0gcd_IniFile("[C]MT8801Port_ByteSize","8") Global $iAPortStopBits = _g0gcd_IniFile("[C]MT8801Port_StopBits","One") Global $iAPortFlowXon = _g0gcd_IniFile("[C]MT8801Port_Xon","On") ; X-on/X-off flow control enabled Global $sCommand Global $sErr ;Any of the following terminates RX listening Global $Timeout = _g0gcd_IniFile("[O]MT8801Comm_TimeOut",10000) ; 10sec timeout before RX returns Global $Length = _g0gcd_IniFile("[O]MT8801Comm_MaxLen",200) ; 200characters before RX returns Global $EOL = @LF; _g0gcd_IniFile("[O]MT8801Port_EOL",@LF) ; End Of Line before RX returns Global $sResult = "" ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #EndRegion Set_Global_Variables ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ;Dev ;Test Code goes here ;Global $aOne = [[1,2],[3,4],[5,6]] ;_ArrayDisplay ($aOne) ;msgbox(0,"1",_ArrayToString($aOne)) ; Returns "0|1|2|3" ;Global $_HIDE = $GUI_DISABLE + $GUI_HIDE ;Global $Testy = $_Hide ;msgbox(0,"String?", IsString($testy)) ;Exit;If required ;End Dev ___Main___() Exit ;============================================================================================================================== #Region Top Level Process ;============================================================================================================================== ;#cs ; #FUNCTION# ================================================================================================================== ; Name...........: ___Main___ ; Description ...: ; Syntax.........: ___Main___() ; Parameters ....: ; ; ; Return values .: ; Author ........: John Powers (g0gcd) ; Modified.......: 10/07/23 ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: ; ============================================================================================================================= Func ___Main___(); Marker for SCITE Jump use ;Notes ;_Log($LogTab & "___Main___: Started.", $dBugLog) ;Global variables used ;$dBugLog, ;Declare local variables ;Local $___Main___ ;Populate local configurable variables ;Initialise local variables ;Local configuration ;Procedure ................................................................................................................ ;#include <_Anritsu_Helper_Program_Functions.au3> ;Program Functions ;#include <_Anritsu_Helper_Test_Sequences.au3> ;Test Sequences ;#include <_Anritsu_Helper_Analyser_Functions.au3> ;Analyser functions FileDelete ($sLogFilename) _Log($ScriptName & " Starting", True, ">", $sLogFilename) ;============================================================================================================================== ; PART ONE - Startup ;============================================================================================================================== ;****************************************************************************************************************************** ;Step 1 - Setup up Control Container ;****************************************************************************************************************************** _CreateMainPanel() ;****************************************************************************************************************************** ;Step 2 - Connect Analyser ;****************************************************************************************************************************** ; Try connection to Analyser using previous settings If _AConnect() OR $dBug_NoAnalyser Then $MT8801_ENABLED = True GUICtrlSetData($hAStatusMessage, "MT8801 Connected") GUICtrlSetColor($hAStatusMessage, $COLOR_GREEN) GUICtrlSetData($hRun, "No Radio Selected") GUICtrlSetState($hRun, $GUI_DISABLE + $GUI_SHOW) Else $MT8801_ENABLED = False GUICtrlSetData($hAStatusMessage, "Manually Connect") GUICtrlSetColor($hAStatusMessage, $COLOR_RED) GUICtrlSetData($hRun, "Connect Analyser") GUICtrlSetState($hRun, $GUI_ENABLE + $GUI_SHOW) Endif ;Check for defined radios ; Extract available definitions (i.e. Section Names] from .ini file Local $SectionNames = IniReadSectionNames($sIniFilename) if @error Then ;No file/sections exist! ;Return False Else For $ptr = 1 to $SectionNames[0] If StringLeft($SectionNames[$ptr],10) = "RadioSpec_" Then $sItems &= StringMid($SectionNames[$ptr],11) & "|" EndIf Next Endif If StringRight($sItems,1)="|" Then StringTrimRight($sItems,1) ; Add in selection of 'Compliance' and 'Performance' tests ; Populate list box GUICtrlSetData($hRTypeList, $sItems) _GUICtrlListBox_SetSel($hRTypeList, 0) ; Set position 1 (which is the 2nd in list) as default ;****************************************************************************************************************************** ;Step 3 - Main Loop ;****************************************************************************************************************************** While NOT ($bSHUTDOWN) ;_Panel_ProcessButtons() If $bTESTING_ENABLED Then _RunNextTest() ;If $bKill_press Then _KillApp() ; Needs immediate action - see _WM_COMMAND() ;If $bRun_press Then _RunNextTest(0) ; Needs immediate action - see _WM_COMMAND() ;If $bPause_press Then _PauseTests() ; Needs immediate action - see _WM_COMMAND() ;If $bStop_press Then _StopTests() ; Needs immediate action - see _WM_COMMAND() ;If $bResume_press Then _ResumeTests() ; Needs immediate action - see _WM_COMMAND() If $bRTypeSelect_press Then _Load_Radio() Sleep(100) WEnd ;Reset Analyser... _g0gcd_IniTidy($sIniFilename) GUIDelete($hGUI) FileDelete($ScriptFullPath & ".run") msgbox(0,"EXIT","Loop exited",2) ; FileWrite($sResultFile, _g0gcd_IniFile("[R]ReportFooter","","Reporting",$sIniFilename) ; IF tests have been carried out! ;_Log($LogTab & "___Main___: Completed.", $dBugLog) ;Return $___Main___ EndFunc ;==>___Main___ ;#ce ;============================================================================================================================== ; PART TWO - Support functions ;============================================================================================================================== ;#cs ; #FUNCTION# ================================================================================================================== ; Name...........: _WM_COMMAND ; Description ...: Extract the key press from the GUI Message and perform essential interlocking before setting control flag ; Syntax.........: _WM_COMMAND() ; Parameters ....: $hWnd, unknown ; $Msg, unknown ; $wParam, bit encoded information aboout which key is pressed ; $lParam, unknown ; Return value ..: $GUI_RUNDEFMSG, see notes ; Author ........: John Powers (g0gcd) ; Modified.......: 10/07/23 ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: ; ============================================================================================================================= Func _WM_COMMAND($hWnd, $Msg, $wParam, $lParam) ; temporary location. After development, move to / replace _WM_COMMANDX() #forceref $hWnd, $Msg, $lParam ;Notes ;Used for quick responses, i.e signalling a button push and locking conflicting operations ;Unlocks for other buttons at the end of the associated procedure ;NEEDS TO BE FAST ; For info, all 4 parameters must be passed to, and $GUI_RUNDEFMSG passed back, for the function to work ; Processes a GUI message (key click) into a (short) procedure ;_Log($LogTab & "_WM_COMMAND: Started.", $dBugLog) ;Global variables used ;$dBugLog, ;Declare local variables ;Local $_WM_COMMAND ;Populate local configurable variables ;Initialise local variables ;Local configuration ;Procedure ................................................................................................................ Switch BitAND($wParam, 0x0000FFFF) Case $hKill $bKill_press = True _KillApp() Case $hRun $bRun_press = True $bTESTING_ENABLED = True _SetCtrl($hRun, $_HIDE) _SetCtrl($hPause, $_FULL) _SetCtrl($hResume, $_HIDE) _SetCtrl($hRestart, $_HIDE) _SetCtrl($hStop, $_HIDE) _SetCtrl($hKill, $_SHOW) _SetCtrl($aPanel[$cPStat][$cMessage], "Tests Running") _RunNextTest(0) Case $hPause $bPause_press = True $bTESTING_ENABLED = False _SetCtrl($hRun, $_HIDE) _SetCtrl($hPause, $_HIDE) _SetCtrl($hResume, $_FULL) _SetCtrl($hRestart, $_FULL) _SetCtrl($hStop, $_FULL) _SetCtrl($hKill, $_SHOW) _SetCtrl($aPanel[$cPStat][$cMessage], "Tests Paused") Case $hResume $bResume_press = True $bTESTING_ENABLED = True _SetCtrl($hRun, $_HIDE) _SetCtrl($hPause, $_FULL) _SetCtrl($hResume, $_HIDE) _SetCtrl($hRestart, $_HIDE) _SetCtrl($hStop, $_HIDE) _SetCtrl($hKill, $_SHOW) _SetCtrl($aPanel[$cPStat][$cMessage], "Tests Running") Case $hRestart $bRestart_press = True $bTESTING_ENABLED = True _SetCtrl($hRun, $_HIDE) _SetCtrl($hPause, $_FULL) _SetCtrl($hResume, $_HIDE) _SetCtrl($hRestart, $_HIDE) _SetCtrl($hStop, $_HIDE) _SetCtrl($hKill, $_SHOW) _SetCtrl($aPanel[$cPStat][$cMessage], "Tests Running") _RunNextTest(0) ;Reset test sequence pointer Case $hStop $bStop_press = True $bTESTING_ENABLED = False _SetCtrl($hRun, $_FULL) _SetCtrl($hPause, $_HIDE) _SetCtrl($hResume, $_HIDE) _SetCtrl($hRestart, $_HIDE) _SetCtrl($hStop, $_HIDE) _SetCtrl($hKill, $_SHOW) _SetCtrl($aPanel[$cPStat][$cMessage], " ") ;GUICtrlSetData($hRun, "Tests Aborted") _StopTests() Case $hRTypeSelect $bRTypeSelect_press = True _SetCtrl($hAResultsList,"Test Results") Case $aPanel[$cAPAdB][$cConfirm] ; GUICtrlSetData($aPanel[$cAPAdB][$cTitle], "Set Radio to") ; GUICtrlSetData($aPanel[$cAPAdB][$cMessage], $sCurrentTestBandFreq) ; GUICtrlSetState($aPanel[$cAPAdB][$cConfirm], $GUI_ENABLE + $GUI_SHOW) GUICtrlSetData($hRun, "Test " & $sRadio_Type) GUICtrlSetState($hRun, $GUI_ENABLE + $GUI_SHOW) GUICtrlSetData($aPanel[$cAPAdB][$cConfirm], $cOK) GUICtrlSetBkColor($aPanel[$cAPAdB][$cConfirm], $COLOR_GREEN) $aPanel[$cAPAdB][$cButton] = 0 ; 0= Confirmed Case $aPanel[$cRFreq][$cConfirm] GUICtrlSetData($aPanel[$cRFreq][$cTitle], "Frequency") ; GUICtrlSetData($aPanel[$cRFreq][$cMessage], $sCurrentTestBandFreq) ; GUICtrlSetState($aPanel[$cRFreq][$cConfirm], $GUI_ENABLE + $GUI_SHOW) GUICtrlSetData($aPanel[$cRFreq][$cConfirm], $cOK) GUICtrlSetBkColor($aPanel[$cRFreq][$cConfirm], $COLOR_GREEN) $aPanel[$cRFreq][$cButton] = 0 ; 0= Confirmed Case $aPanel[$cRMode][$cConfirm] GUICtrlSetData($aPanel[$cRMode][$cTitle], "Mode") ; GUICtrlSetData($aPanel[$cRMode][$cMessage], $sCurrentTestBandMode) ; GUICtrlSetState($aPanel[$cRMode][$cConfirm], $GUI_ENABLE + $GUI_SHOW) GUICtrlSetData($aPanel[$cRMode][$cConfirm], $cOK) GUICtrlSetBkColor($aPanel[$cRMode][$cConfirm], $COLOR_GREEN) $aPanel[$cRMode][$cButton] = 0 ; 0= Confirmed Case $aPanel[$cRAnt1][$cConfirm] GUICtrlSetData($aPanel[$cRAnt1][$cConfirm], $cOK) GUICtrlSetBkColor($aPanel[$cRAnt1][$cConfirm], $COLOR_GREEN) $aPanel[$cRAnt1][$cButton] = 0 ; 0= Confirmed ; $aPanel[$cRAnt0][$cButton] = 0 ; 0= Confirmed $sRAntInUse = $sAnt1 Case $aPanel[$cRAnt2][$cConfirm] GUICtrlSetData($aPanel[$cRAnt2][$cConfirm], $cOK) GUICtrlSetBkColor($aPanel[$cRAnt2][$cConfirm], $COLOR_GREEN) $aPanel[$cRAnt2][$cButton] = 0 ; 0= Confirmed $sRAntInUse = $sAnt2 Case $aPanel[$cRAnt3][$cConfirm] GUICtrlSetData($aPanel[$cRAnt3][$cConfirm], $cOK) GUICtrlSetBkColor($aPanel[$cRAnt3][$cConfirm], $COLOR_GREEN) $aPanel[$cRAnt3][$cButton] = 0 ; 0= Confirmed $sRAntInUse = $sAnt3 Case $aPanel[$cRAnt4][$cConfirm] GUICtrlSetData($aPanel[$cRAnt4][$cConfirm], $cOK) GUICtrlSetBkColor($aPanel[$cRAnt4][$cConfirm], $COLOR_GREEN) $aPanel[$cRAnt4][$cButton] = 0 ; 0= Confirmed $sRAntInUse = $sAnt4 EndSwitch ;_Log($LogTab & "_WM_COMMAND: Completed.", $dBugLog) Return $GUI_RUNDEFMSG EndFunc ;==>_WM_COMMAND ;#ce ;------------------------------------------------------------------------------------------------------------------------------ #cs ; #FUNCTION# ================================================================================================================== ; Name...........: _RestartTests ; Description ...: ; Syntax.........: _RestartTests() ; Parameters ....: ; ; ; Return values .: ; Author ........: John Powers (g0gcd) ; Modified.......: 10/07/23 ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: ; ============================================================================================================================= Func _RestartTests() ;Notes ;_Log($LogTab & "_RestartTests: Started.", $dBugLog) ;Global variables used ;$dBugLog, ;Declare local variables ;Local $_RestartTests ;Populate local configurable variables ;Initialise local variables ;Local configuration ;Procedure ................................................................................................................ _RunNextTest(0) ;_Log($LogTab & "_RestartTests: Completed.", $dBugLog) ;Return $_RestartTests EndFunc ;==>_RestartTests #ce ;------------------------------------------------------------------------------------------------------------------------------ #cs ; #FUNCTION# ================================================================================================================== ; Name...........: _PauseTests ; Description ...: ; Syntax.........: _PauseTests() ; Parameters ....: ; ; ; Return values .: ; Author ........: John Powers (g0gcd) ; Modified.......: 10/07/23 ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: ; ============================================================================================================================= Func _PauseTests() ;Notes ;_Log($LogTab & "_PauseTests: Started.", $dBugLog) ;Global variables used ;$dBugLog, ;Declare local variables ;Local $_PauseTests ;Populate local configurable variables ;Initialise local variables ;Local configuration ;Procedure ................................................................................................................ $bPause_press = False $bTESTING_ENABLED = False _SetCtrl($hRun, $_HIDE) _SetCtrl($hPause, $_HIDE) _SetCtrl($hResume, $_FULL) _SetCtrl($hRestart, $_FULL) _SetCtrl($hStop, $_FULL) _SetCtrl($hKill, $_SHOW) _SetCtrl($aPanel[$cPStat][$cMessage], "Tests Paused") #cs GUICtrlSetState($hRun, $GUI_DISABLE + $GUI_SHOW) GUICtrlSetState($hPause, $GUI_DISABLE + $GUI_HIDE) GUICtrlSetState($hResume, $GUI_ENABLE + $GUI_SHOW) GUICtrlSetState($hRestart, $GUI_ENABLE + $GUI_SHOW) GUICtrlSetState($hStop, $GUI_ENABLE + $GUI_SHOW) GUICtrlSetState($hKill, $GUI_DISABLE + $GUI_SHOW) GUICtrlSetData($hRun, "Tests Paused") _WriteResultToScreen("Tests Paused") $bTESTING_ENABLED = False #ce ;_Log($LogTab & "_PauseTests: Completed.", $dBugLog) ;Return $_PauseTests EndFunc ;==>_PauseTests #ce ;------------------------------------------------------------------------------------------------------------------------------ #cs ; #FUNCTION# ================================================================================================================== ; Name...........: _ResumeTests ; Description ...: ; Syntax.........: _ResumeTests() ; Parameters ....: ; ; ; Return values .: ; Author ........: John Powers (g0gcd) ; Modified.......: 10/07/23 ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: ; ============================================================================================================================= Func _ResumeTests() ;Notes ;_Log($LogTab & "_ResumeTests: Started.", $dBugLog) ;Global variables used ;$dBugLog, ;Declare local variables ;Local $_ResumeTests ;Populate local configurable variables ;Initialise local variables ;Local configuration ;Procedure ................................................................................................................ $bResume_press = False $bTESTING_ENABLED = True GUICtrlSetState($hRun, $GUI_DISABLE + $GUI_SHOW) GUICtrlSetState($hPause, $GUI_ENABLE + $GUI_SHOW) GUICtrlSetState($hResume, $GUI_DISABLE + $GUI_HIDE) GUICtrlSetState($hRestart, $GUI_DISABLE + $GUI_HIDE) GUICtrlSetState($hStop, $GUI_DISABLE + $GUI_HIDE) GUICtrlSetState($hKill, $GUI_DISABLE + $GUI_SHOW) ; GUICtrlSetData($hRun, "Running Tests") ; _WriteResultToScreen("Tests Resumed") Sleep(500) ;_Log($LogTab & "_ResumeTests: Completed.", $dBugLog) ;Return $_ResumeTests EndFunc ;==>_ResumeTests #ce ;------------------------------------------------------------------------------------------------------------------------------ ;#cs ; #FUNCTION# ================================================================================================================== ; Name...........: _StopTests ; Description ...: ; Syntax.........: _StopTests() ; Parameters ....: ; ; ; Return values .: ; Author ........: John Powers (g0gcd) ; Modified.......: 10/07/23 ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: ; ============================================================================================================================= Func _StopTests($StopMode = "Stop" ) ;Notes ;_Log($LogTab & "_StopTests: Started.", $dBugLog) ;Global variables used ;$dBugLog, ;Declare local variables ;Local $_StopTests ;Populate local configurable variables ;Initialise local variables ;Local configuration ;Procedure ................................................................................................................ _Set_GUICtrlInitialState() ; GUICtrlSetState($aPanel[$cRMode][$cConfirm], $GUI_DISABLE + $GUI_HIDE) ; GUICtrlSetState($aPanel[$cRAnt1][$cConfirm], $GUI_DISABLE + $GUI_HIDE) _SetCtrl($hAPAdBSelectMessage, $_FULL) _SetCtrl($hRun, "Start Tests") If $StopMode = "Stop" Then _WriteResultToScreen("Tests Aborted") _SetCtrl($aPanel[$cPStat][$cMessage], "Testing Aborted") Else _WriteResultToScreen("Tests Ended") _SetCtrl($aPanel[$cPStat][$cMessage], "Testing Completed") _RunNextTest(0) _SetCtrl($hRun, "Test " & $sRadio_Type) ; ?? _SetCtrl($hRun, $_FULL) ; ?? EndIf $aPanel[$cRFreq][$cButton] = 0 $aPanel[$cRMode][$cButton] = 0 ;$sTestList = "X01XX02XX03XX04XX05XX06XX07XX08XX09X" $sTestList = $sFullTestList GUICtrlSetData($hAFrequencyMessage, "n/a") GUICtrlSetData($aPanel[$cFProg][$cMessage], 0) GUICtrlSetData($aPanel[$cRFreq][$cTitle], "Frequency") GUICtrlSetData($aPanel[$cRFreq][$cMessage], "--------") GUICtrlSetData($aPanel[$cRFreq][$cConfirm], "#") GUICtrlSetBkColor($aPanel[$cRFreq][$cConfirm], $COLOR_WHITE) ; GUICtrlSetData($aPanel[$cRMode][$cTitle], "Mode") ; GUICtrlSetData($aPanel[$cRMode][$cMessage], "---") ; GUICtrlSetData($aPanel[$cRMode][$cConfirm], "") ; GUICtrlSetBkColor($aPanel[$cRMode][$cConfirm], $COLOR_RED) #cs _Panel_SetStatus($cFProg, $cAll, "", $cHide) _Panel_SetStatus($cRFreq, $cAll, "", $cHide) _Panel_SetStatus($cRMode, $cAll, "", $cHide) _Panel_SetStatus($cRAnt1, $cAll, "", $cHide) _Panel_SetStatus($cRAnt2, $cAll, "", $cHide) _Panel_SetStatus($cRAnt3, $cAll, "", $cHide) _Panel_SetStatus($cRAnt4, $cAll, "", $cHide) GUICtrlSetState($aPanel[$cRFreq][$cConfirm], $GUI_HIDE); but this is re-enabled GUICtrlSetState($aPanel[$cRMode][$cConfirm], $GUI_HIDE) #ce GUISetBkColor(0xF0F0F0) ; GUICtrlSetBkColor($aPanel[$cRFreq][$cConfirm],0xF0F0F0) GUICtrlSetState($aPanel[$cPMask][$cMessage], $GUI_ENABLE + $GUI_SHOW) ; _Set_GUICtrlInitialState() ; GUICtrlDelete ($aPanel[$cRFreq][$cConfirm]) ; $aPanel[$cRFreq][$cConfirm] = GUICtrlCreateLabel("", $aCol[10], $aRow[23], $aW[1], $aH[1], $cCentered) ; GUICtrlSetColor($aPanel[$cRFreq][$cConfirm], $COLOR_WHITE) ; GUICtrlSetBkColor($aPanel[$cRFreq][$cConfirm], $COLOR_RED) ;GUICtrlSetData($aPanel[$cRFreq][$cConfirm],"#") ; ;_Log($LogTab & "_StopTests: Completed.", $dBugLog) ;Return $_StopTests EndFunc ;==>_StopTests ;#ce ;------------------------------------------------------------------------------------------------------------------------------ ;#cs ; #FUNCTION# ================================================================================================================== ; Name...........: _KillApp ; Description ...: ; Syntax.........: _KillApp() ; Parameters ....: ; ; ; Return values .: ; Author ........: John Powers (g0gcd) ; Modified.......: 10/07/23 ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: ; ============================================================================================================================= Func _KillApp() ;Notes ;_Log($LogTab & "_KillApp: Started.", $dBugLog) ;Global variables used ;$dBugLog, ;Declare local variables ;Local $_KillApp ;Populate local configurable variables ;Initialise local variables ;Local configuration ;Procedure ................................................................................................................ $bKill_press = False $bSHUTDOWN = True ;_Log($LogTab & "_KillApp: Completed.", $dBugLog) ;Return $_KillApp EndFunc ;==>_KillApp ;#ce ;------------------------------------------------------------------------------------------------------------------------------ ;#cs ; #FUNCTION# ================================================================================================================== ; Name...........: _RunNextTest ; Description ...: ; Syntax.........: _RunNextTest() ; Parameters ....: ; ; ; Return values .: ; Author ........: John Powers (g0gcd) ; Modified.......: 10/07/23 ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: ; ============================================================================================================================= Func _RunNextTest($StartAt = -1) ;Notes ;Need to work on the concept of no parameter meaning run next test and 0 meaning reset the pointer to first test ; recognising that array starts first test at $array[1] ;_Log($LogTab & "_RunNextTest: Started.", $dBugLog) ;Global variables used ;$dBugLog, ;Declare local variables ;Local $_RunNextTest Local $ThisTest ;Populate local configurable variables ;Initialise local variables Local Static $Test = 0 ;Local configuration ;Procedure ................................................................................................................ #cs $bRun_press = False $bTESTING_ENABLED = True _SetCtrl($hRun, $_HIDE) _SetCtrl($hPause, $_FULL) _SetCtrl($hResume, $_HIDE) _SetCtrl($hRestart, $_HIDE) _SetCtrl($hStop, $_HIDE) _SetCtrl($hKill, $_SHOW) _SetCtrl($aPanel[$cPStat][$cMessage], "Tests Running") ; _RunNextTest(0) #ce If $StartAt = -1 Then $ThisTest = $Test + 1 If $Test = 0 Then GUICtrlSetData($hAResultsList, "Test Results") ; Reset results window at start of first test ;Lift the mask over the radio controls ;Set Running message? EndIf _WriteResultToScreen("_RunNextTest (" & $aFullTestList[$ThisTest][0] & ")"); debug, shows the 4ch test code ;INSERT TEST PROCEDURE HERE; _RunSingleTest($ThisTest); rename to '_Run_Test()' or move code into this gap ;End of test Sleep(1000) $Test += 1 If $Test >= $aFullTestList[0][0] Then ; check for end of test sequence $bTESTING_ENABLED = False; End of run; _StopTests()? or write tests completed to window?; Set $bTESTING_COMPLETED flag? _StopTests("Ended") _SetCtrl($aPanel[$cPStat][$cMessage]," ") Endif Else $Test = $StartAt; Restart test position only $sRAntInUse = "-" Endif ;_Log($LogTab & "_RunNextTest: Completed.", $dBugLog) ;Return $_RunNextTest EndFunc ;==>_RunNextTest ;#ce ; <----------------------- ^v Merge these two ^v -----------------------------------------------------------------------------> ;------------------------------------------------------------------------------------------------------------------------------ ;#cs ; #FUNCTION# ================================================================================================================== ; Name...........: _RunSingleTest ; Description ...: ; Syntax.........: _RunSingleTest($iCurrentTestCounter) ; Parameters ....: $iCurrentTestCounter ; Return values .: ; Author ........: John Powers (g0gcd) ; Modified.......: 11/07/23 ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: ; ============================================================================================================================= Func _RunSingleTest($iCurrentTestCounter) ;Notes ;Antenna (and similar) checks ; Separate ini section for band to antenna ; when starting tests, request which antenna is in use for the band (if there are options) ; when changing band, check that selected antenna is in the list of options and validate that it's still in use ; if not in the list, request which antenna is in use (if there are options) ;If Ant contains one option: ; Light up that setting ; If ant in use = option then auto confirm and continue ; If not then request check and wait for confirm. Then continue ;If Ant contains more than one option: ; If ant in use = any of the options then ; Light up that option ; Request check and wait for confirm. Then continue ; If any other option is clicked, select that, change ant in use and continue ; If not then request check and wait for confirm. Then continue _Log($LogTab & "_RunSingleTest: Started.", $dBugLog) ;Global variables used ;Declare local variables Local $_RunSingleTest Local $iRow Local $bEscape Local $sCurrentTestCode Local $sCurrentTestModeName Local $sCurrentTestTypeName Local $sCurrentTestBandName Local $sCurrentTestBandFreq Local $sMsgTmp #forceref $_RunSingleTest ;Populate local configurable variables ;Initialise local variables ;Local configuration ;Procedure ................................................................................................................ GUICtrlSetState($aPanel[$cPMask][$cMessage], $GUI_DISABLE + $GUI_HIDE); remove mask ; GUICtrlSetState($hRun, $GUI_DISABLE + $GUI_HIDE); Set controls? ; GUICtrlSetState($hPause, $GUI_ENABLE + $GUI_SHOW) ; GUICtrlSetState($hResume, $GUI_DISABLE + $GUI_HIDE) ; GUICtrlSetState($hRestart, $GUI_DISABLE + $GUI_HIDE) ; GUICtrlSetState($hStop, $GUI_DISABLE + $GUI_HIDE) ; GUICtrlSetState($hKill, $GUI_DISABLE + $GUI_SHOW) ;; GUICtrlSetState($hAPAdBSelect, $GUI_ENABLE + $GUI_SHOW) _Panel_SetStatus($cFProg, $cAll, "", $cFull) _Panel_SetStatus($cRFreq, $cAll, "", $cFull) _Panel_SetStatus($cRMode, $cAll, "", $cFull) ;; GUICtrlSetData($hAResultsList, "Test Results") ;If Required - depends on previous Analyser settings ; _AInitSystem($sMT8801_RFPort) ; Initialise Analyser (again) but only once per test session ;Set common AF, RX and TX parameters (_AInitAnalog) ;(Set specifics in each MEAS screen) ; $sRAntInUse = "-"; Reset the Radio Antenna Port in use to "None"; Set when selecting Radio? ; Also Mode and Frequency in use? ; And any other controls? ;If StringLen ($sTestList) > 0 Then ; or SaFullTestList [test][parameter], test 1 to test ($aFullTestList[0][0] ; For $iCurrentTestCounter = 1 To $aFullTestList[0][0] ; only executes if there are tests defined ;Extract test code $sCurrentTestCode = $aFullTestList[$iCurrentTestCounter][0] ;Stringleft($sTestList,4) ;$sTestList = StringReplace($sTestList,$sCurrentTestCode,""); after test? ;Extract elements of test Local $sCurrentTestMode = StringMid($sCurrentTestCode,1,1) ; Possibly split in $aFullTestList, and .ini file, to separate columns Local $sCurrentTestType = StringMid($sCurrentTestCode,2,2) Local $sCurrentTestBand = StringMid($sCurrentTestCode,4,1) Local $sCurrentTestAnt = $aFullTestList[$iCurrentTestCounter][1] ;Enrich elements ; Local $iRow ;Enrich Mode Name $sCurrentTestModeName = $sCurrentTestMode $iRow = _ArraySearch($aSpecific_Modes, "\" & $sCurrentTestMode) If $iRow > -1 Then $sCurrentTestModeName = $aSpecific_Modes[$iRow][1] ;Enrich Test Name $sCurrentTestTypeName = $sCurrentTestType $iRow = _ArraySearch($aSpecific_Tests, $sCurrentTestType) If $iRow > -1 Then $sCurrentTestTypeName = $aSpecific_Tests[$iRow][1] ;Enrich Band Name and Band Centre Frequency $sCurrentTestBandName = "" $sCurrentTestBandFreq = "" $iRow = _ArraySearch($aSpecific_Bands, "\" & $sCurrentTestBand,0,0,0,1,1,0); Search only in Col0 If $iRow > -1 Then $sCurrentTestBandName = StringSplit($aSpecific_Bands[$iRow][1],"#")[1] If $iRow > -1 Then $sCurrentTestBandFreq = StringSplit($aSpecific_Bands[$iRow][1],"#")[2] ;Confirm Radio Frequency If $sCurrentTestBandFreq <> $sRFreqInUse Then ; Await radio tuning ;If $DEVICE_ENABLED Then ;use CAT control ;Else _SetCtrl($aPanel[$cRFreq][$cTitle], "Set Radio to") _SetCtrl($aPanel[$cRFreq][$cMessage], $sCurrentTestBandFreq) _SetCtrl($aPanel[$cRFreq][$cConfirm],$cUnConf) $aPanel[$cRFreq][$cButton] = 1 ; False, NOK, Unconfirmed _Log($LogTab & "_RunSingleTest: Mode queried.", $dBugLog) ;EndIf Endif ;Confirm Radio Mode If $sCurrentTestModeName <> $sRModeInUse Then ; Await radio setting ;If $DEVICE_ENABLED Then ;use CAT control ;Else _SetCtrl($aPanel[$cRMode][$cTitle], "Set Radio to") _SetCtrl($aPanel[$cRMode][$cMessage], $sCurrentTestModeName) _SetCtrl($aPanel[$cRMode][$cConfirm],$cUnConf) $aPanel[$cRMode][$cButton] = 1 ; False, NOK, Unconfirmed _Log($LogTab & "_RunSingleTest: Mode queried.", $dBugLog) ;EndIf Endif ;Confirm Antenna settings ;$sCurrentTestAnt ; from test definition ; _Panel_SetStatus($cRAnt1, $cAll, "", $cFull) ; _SetCtrl($aPanel[$cRAnt1][$cTitle], ", Length " & StringLen($sCurrentTestAnt)) ; Sleep(5000) Switch StringLen($sCurrentTestAnt) Case 0; No antenna specified.... Pick up error and deal with it..... ;$Ant1="Not Available"; ?? ;_SetCtrl($aPanel[$cRAnt1][$cTitle],"Antenna Port"); ?? _Panel_SetStatus($cRAnt1, $cAll, "", $cHide) ;$Ant2="Not Available"; ?? _Panel_SetStatus($cRAnt2, $cAll, "", $cHide) ;$Ant3="Not Available"; ?? _Panel_SetStatus($cRAnt3, $cAll, "", $cHide) ;$Ant4="Not Available"; ?? _Panel_SetStatus($cRAnt4, $cAll, "", $cHide) Case 1; One antenna specified $sAnt1=$sCurrentTestAnt; $sAnt1=StringMid($sCurrentTestAnt,1,1); Actually $sAnt1=$sCurrentTestAnt _Panel_SetStatus($cRAnt1, $cAll, "", $cFull) _SetCtrl($aPanel[$cRAnt1][$cTitle],"Antenna Port") _SetCtrl($aPanel[$cRAnt1][$cMessage], $sAnt1) $iRow = _ArraySearch($aSpecific_Ports, "\" & $sAnt1) If $iRow > -1 Then _SetCtrl($aPanel[$cRAnt1][$cMessage], $aSpecific_Ports[$iRow][1]) If $iCurrentTestCounter > 1 Then If $sRAntInUse = $sAnt1 Then ; auto confirm and continue ; _SetCtrl($aPanel[$cRAnt1][$cConfirm], $cConf) ; $aPanel[$cRAnt1][$cButton] = 0 Else _SetCtrl($aPanel[$cRAnt1][$cConfirm], $cUnConf) $aPanel[$cRAnt1][$cButton] = 0 EndIf Else EndIf #cs If $sRAntInUse = $sAnt1 Then ; auto confirm and continue ; msgbox(0,$AntInUse & " in use", "Auto confirm " & $AntsAvailable) _SetCtrl($aPanel[$cRAnt1][$cConfirm], $cConf) $aPanel[$cRAnt1][$cButton] = 0 ; $AntInUse = $AntsAvailable Else ; msgbox(0,$AntInUse & " in use", "Query / confirm " & $AntsAvailable) ; $AntInUse = $AntsAvailable ; Endif ; $sAnt1=StringMid($sCurrentTestAnt,1,1) ; _Panel_SetStatus($cRAnt1, $cAll, "", $cFull) ; _SetCtrl($aPanel[$cRAnt1][$cTitle],"Antenna Port") ; _SetCtrl($aPanel[$cRAnt1][$cMessage], $sAnt1) ; $iRow = _ArraySearch($aSpecific_Ports, "\" & $sAnt1) ; If $iRow > -1 Then _SetCtrl($aPanel[$cRAnt1][$cMessage], $aSpecific_Ports[$iRow][1]) ; If $sRAntInUse = $sAnt1 AND $iCurrentTestCounter > 1 Then ; auto confirm and continue _SetCtrl($aPanel[$cRAnt1][$cConfirm], $cConf) $aPanel[$cRAnt1][$cButton] = 0 Else _SetCtrl($aPanel[$cRAnt1][$cConfirm], $cUnConf) $aPanel[$cRAnt1][$cButton] = 1 #ce EndIf ;$Ant2="Not Available"; ?? _Panel_SetStatus($cRAnt2, $cAll, "", $cHide) ;$Ant3="Not Available"; ?? _Panel_SetStatus($cRAnt3, $cAll, "", $cHide) ;$Ant4="Not Available"; ?? _Panel_SetStatus($cRAnt4, $cAll, "", $cHide) Case 2; Two antennas available ; ;$Ant1=StringMid($Anst,1,1) ; _SetCtrl($aPanel[$cRAnt1][$cTitle],"Antenna Ports") $sAnt2=StringMid($sCurrentTestAnt,2,1) _Panel_SetStatus($cRAnt2, $cAll, "", $cFull) ;_SetCtrl($aPanel[$cRAnt2][$cTitle],"") _SetCtrl($aPanel[$cRAnt2][$cMessage], $sAnt2) $iRow = _ArraySearch($aSpecific_Ports, "\" & $sAnt2) If $iRow > -1 Then _SetCtrl($aPanel[$cRAnt2][$cMessage], $aSpecific_Ports[$iRow][1]) If $sRAntInUse = $sAnt2 AND $iCurrentTestCounter > 1 Then ; auto confirm and continue _SetCtrl($aPanel[$cRAnt2][$cConfirm], $cConf) $aPanel[$cRAnt2][$cButton] = 0 Else _SetCtrl($aPanel[$cRAnt2][$cConfirm], $cUnConf) $aPanel[$cRAnt2][$cButton] = 1 EndIf ; GUICtrlSetState($aPanel[$cRAnt1][$cTitle], $GUI_ENABLE + $GUI_SHOW);$GUI_HIDE) ; GUICtrlSetState($aPanel[$cRAnt1][$cMessage], $GUI_ENABLE + $GUI_SHOW);$GUI_HIDE) ; GUICtrlSetData($aPanel[$cRAnt1][$cMessage], StringMid($sCurrentTestAnt,1,1)) ; GUICtrlSetState($aPanel[$cRAnt1][$cConfirm], $GUI_ENABLE + $GUI_SHOW);$GUI_HIDE) ;$Ant2=StringMid($Ant,2,1) $sAnt1=StringMid($sCurrentTestAnt,1,1) _Panel_SetStatus($cRAnt1, $cAll, "", $cFull) _SetCtrl($aPanel[$cRAnt1][$cTitle],"Antenna Port") _SetCtrl($aPanel[$cRAnt1][$cMessage], $sAnt1) $iRow = _ArraySearch($aSpecific_Ports, "\" & $sAnt1) If $iRow > -1 Then _SetCtrl($aPanel[$cRAnt1][$cMessage], $aSpecific_Ports[$iRow][1]) If $sRAntInUse = $sAnt1 AND $iCurrentTestCounter > 1 Then ; auto confirm and continue _SetCtrl($aPanel[$cRAnt1][$cConfirm], $cConf) $aPanel[$cRAnt1][$cButton] = 0 Else _SetCtrl($aPanel[$cRAnt1][$cConfirm], $cUnConf) $aPanel[$cRAnt1][$cButton] = 1 EndIf ; GUICtrlSetState($aPanel[$cRAnt2][$cTitle], $GUI_ENABLE + $GUI_SHOW);$GUI_HIDE) ; GUICtrlSetState($aPanel[$cRAnt2][$cMessage], $GUI_ENABLE + $GUI_SHOW);$GUI_HIDE) ; GUICtrlSetData($aPanel[$cRAnt2][$cMessage], StringMid($sCurrentTestAnt,2,1)) ; GUICtrlSetState($aPanel[$cRAnt2][$cConfirm], $GUI_ENABLE + $GUI_SHOW);$GUI_HIDE) ;$Ant3="Not Available"; ?? _Panel_SetStatus($cRAnt3, $cAll, "", $cHide) ;$Ant4="Not Available"; ?? _Panel_SetStatus($cRAnt4, $cAll, "", $cHide) ; For $y = 1 to 2 ; If StringMid($AntsAvailable,$y,1) = $AntInUse Then ; msgbox(0,$AntInUse & " in use", "Query / confirm " & StringMid($AntsAvailable,$y,1)) ; $AntInUse = StringMid($AntsAvailable,$y,1) ; Else ; msgbox(0,$AntInUse & " in use", "Available " & StringMid($AntsAvailable,$y,1)) ; ;$AntInUse = StringMid($AntsAvailable,$y,1) ; Endif ; ; ; Next Case 3 ;$Ant1=StringMid($Ant,1,1) _SetCtrl($aPanel[$cRAnt1][$cTitle],"Antenna Ports") GUICtrlSetState($aPanel[$cRAnt1][$cTitle], $GUI_ENABLE + $GUI_SHOW);$GUI_HIDE) GUICtrlSetState($aPanel[$cRAnt1][$cMessage], $GUI_ENABLE + $GUI_SHOW);$GUI_HIDE) GUICtrlSetData($aPanel[$cRAnt1][$cMessage], StringMid($sCurrentTestAnt,1,1)) GUICtrlSetState($aPanel[$cRAnt1][$cConfirm], $GUI_ENABLE + $GUI_SHOW);$GUI_HIDE) ;$Ant2=StringMid($Ant,2,1) GUICtrlSetState($aPanel[$cRAnt2][$cTitle], $GUI_ENABLE + $GUI_SHOW);$GUI_HIDE) GUICtrlSetState($aPanel[$cRAnt2][$cMessage], $GUI_ENABLE + $GUI_SHOW);$GUI_HIDE) GUICtrlSetData($aPanel[$cRAnt2][$cMessage], StringMid($sCurrentTestAnt,2,1)) GUICtrlSetState($aPanel[$cRAnt2][$cConfirm], $GUI_ENABLE + $GUI_SHOW);$GUI_HIDE) ;$Ant3=StringMid($Ant,3,1) GUICtrlSetState($aPanel[$cRAnt3][$cTitle], $GUI_ENABLE + $GUI_SHOW);$GUI_HIDE) GUICtrlSetState($aPanel[$cRAnt3][$cMessage], $GUI_ENABLE + $GUI_SHOW);$GUI_HIDE) GUICtrlSetData($aPanel[$cRAnt3][$cMessage], StringMid($sCurrentTestAnt,3,1)) GUICtrlSetState($aPanel[$cRAnt3][$cConfirm], $GUI_ENABLE + $GUI_SHOW);$GUI_HIDE) ;$Ant4="Not Available"; ?? _Panel_SetStatus($cRAnt4, $cAll, "", $cHide) Case 4 ;$Ant1=StringMid($Ant,1,1) _SetCtrl($aPanel[$cRAnt1][$cTitle],"Antenna Ports") GUICtrlSetState($aPanel[$cRAnt1][$cTitle], $GUI_ENABLE + $GUI_SHOW);$GUI_HIDE) GUICtrlSetState($aPanel[$cRAnt1][$cMessage], $GUI_ENABLE + $GUI_SHOW);$GUI_HIDE) GUICtrlSetData($aPanel[$cRAnt1][$cMessage], StringMid($sCurrentTestAnt,1,1)) GUICtrlSetState($aPanel[$cRAnt1][$cConfirm], $GUI_ENABLE + $GUI_SHOW);$GUI_HIDE) ;$Ant2=StringMid($Ant,2,1) GUICtrlSetState($aPanel[$cRAnt2][$cTitle], $GUI_ENABLE + $GUI_SHOW);$GUI_HIDE) GUICtrlSetState($aPanel[$cRAnt2][$cMessage], $GUI_ENABLE + $GUI_SHOW);$GUI_HIDE) GUICtrlSetData($aPanel[$cRAnt2][$cMessage], StringMid($sCurrentTestAnt,2,1)) GUICtrlSetState($aPanel[$cRAnt2][$cConfirm], $GUI_ENABLE + $GUI_SHOW);$GUI_HIDE) ;$Ant3=StringMid($Ant,3,1) GUICtrlSetState($aPanel[$cRAnt3][$cTitle], $GUI_ENABLE + $GUI_SHOW);$GUI_HIDE) GUICtrlSetState($aPanel[$cRAnt3][$cMessage], $GUI_ENABLE + $GUI_SHOW);$GUI_HIDE) GUICtrlSetData($aPanel[$cRAnt3][$cMessage], StringMid($sCurrentTestAnt,3,1)) GUICtrlSetState($aPanel[$cRAnt3][$cConfirm], $GUI_ENABLE + $GUI_SHOW);$GUI_HIDE) ;$Ant4=StringMid($Ant,4,1) GUICtrlSetState($aPanel[$cRAnt4][$cTitle], $GUI_ENABLE + $GUI_SHOW);$GUI_HIDE) GUICtrlSetState($aPanel[$cRAnt4][$cMessage], $GUI_ENABLE + $GUI_SHOW);$GUI_HIDE) GUICtrlSetData($aPanel[$cRAnt4][$cMessage], StringMid($sCurrentTestAnt,4,1)) GUICtrlSetState($aPanel[$cRAnt4][$cConfirm], $GUI_ENABLE + $GUI_SHOW);$GUI_HIDE) EndSwitch ; Now we're displaying the antennas, and only the available antennas, on the GUI ;Now what.. #cs If $sCurrentTestModeName <> $sRModeInUse Then ; Await radio setting ;If $DEVICE_ENABLED Then ;use CAT control ;Else GUICtrlSetData($aPanel[$cRMode][$cTitle], "Set Radio to") GUICtrlSetData($aPanel[$cRMode][$cMessage], $sCurrentTestModeName) GUICtrlSetData($aPanel[$cRMode][$cConfirm], "") GUICtrlSetBkColor($aPanel[$cRMode][$cConfirm], $COLOR_RED) $aPanel[$cRMode][$cButton] = 1 ;EndIf #ce Endif ;Wait for all actions to be attended to $bEscape = False $sMsgTmp = GUICtrlRead($aPanel[$cPStat][$cMessage]) While $aPanel[$cAPAdB][$cButton] + $aPanel[$cRFreq][$cButton] + $aPanel[$cRMode][$cButton] + _ $aPanel[$cRAnt1][$cButton] + $aPanel[$cRAnt2][$cButton] > 0 ;? Logic for antenna selection? Sleep(1000) _SetCtrl($aPanel[$cPStat][$cMessage],"Awaiting confirmation of changes to radio settings") If $bStop_press = True Then $bEscape = True ExitLoop Endif ; Handle pause press WEnd _SetCtrl($aPanel[$cPStat][$cMessage],$sMsgTmp) If NOT ($bEscape) Then ;Route test type to specific functions Sleep(2500) $sResult = "n/a" _AInitAnalog($sCurrentTestBandFreq, $sCurrentTestBandFreq) Switch StringMid($sCurrentTestCode,2,2) Case "03"; 12dB SINAD ; Set common AF, RX and TX parameters (ALOG) and write to .ini file for reporting, if required? _AInitAnalog($sCurrentTestBandFreq, $sCurrentTestBandFreq) ;(Set specifics in each MEAS screen) and write to .ini file for reporting, if required? ;Set Antenna and other controls $sResult = RX_Test_SN(12, -130 + $PAdBValue, $sCurrentTestMode) - $PAdBValue Case "07"; RX 6dB Low ; Set common AF, RX and TX parameters (ALOG) and write to .ini file for reporting, if required? _AInitAnalog($sCurrentTestBandFreq, $sCurrentTestBandFreq) ;(Set specifics in each MEAS screen) and write to .ini file for reporting, if required? ;Set Antenna and other controls $sResult = RX_Test_BW("lo", $sCurrentTestBandFreq * 1E6, -115, 14) Case "08"; RX 6dB High ; Set common AF, RX and TX parameters (ALOG) and write to .ini file for reporting, if required? _AInitAnalog($sCurrentTestBandFreq, $sCurrentTestBandFreq) ;(Set specifics in each MEAS screen) and write to .ini file for reporting, if required? ;Set Antenna and other controls $sResult = RX_Test_BW("hi", $sCurrentTestBandFreq * 1E6, -115, 14) EndSwitch $sRFreqInUse = $sCurrentTestBandFreq $sRModeInUse = $sCurrentTestModeName ;$sRAntInUse = $sCurrentTestAnt _WriteResultToScreen($sCurrentTestBandName & " " & $sCurrentTestModeName & " " & $sCurrentTestTypeName & ", Completed. [" & $sResult & "dBm]") FileWrite($sResultFile, "Test " & $sCurrentTestCode & ", Completed. [" & $sResult & "]" & @CRLF) GUICtrlSetData($aPanel[$cFProg][$cMessage], (($iTestCount-(StringLen($sTestList)/4))/$iTestCount)*100) ; Next ;; Else ; _Set_GUICtrlInitialState() ; _StopTests("Ended") ; gives misleading message , i.e. Aborted ;; Endif EndIf _Log($LogTab & "_RunSingleTest: Completed.", $dBugLog) ;Return $_RunSingleTest EndFunc ;==>_RunSingleTest ;#ce ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #EndRegion Top Level Process ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ;============================================================================================================================== #Region Program Functions Func ___Program_Functions___(); Marker for SCITE Jump use EndFunc ;============================================================================================================================== ; #INDEX# ======================================================================================================================= ; Name ..........: _Anritsu_Helper_Program_Functions.au3 ; Title .........: Program Functions ; Description ...: Functions used for program management ; Version Date ..: 2023-07-05 ; AutoIt Version : 3.3.14.5 ; Link ..........: ; Tag(s) ........: ; Author(s) .....: G0GCD ; Dll(s) ........: ; Error handling : tba ; =============================================================================================================================== ;#include-once ;#include "_Anritsu_Helper_Constants.au3" ;#include "_Anritsu_Helper_Analyser_Functions.au3" ;;#include "_Anritsu_Helper_Program_Functions.au3" ; This file! ;#include "_Anritsu_Helper_Test_Sequences.au3" ;#NoAutoIT3Execute ;#AutoIt3Wrapper_Au3Check_Parameters=-q -d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w- 7 ; _Load_Radio() ; _Log($Message, $Write2Log = True, $Separator = ">", $sLogFilename = "") ; _Set_GUICtrlLayoutGrid(ByRef $aAnchor, ByRef $aSize, $iStep, $iMargin, $iGutter, $iConstraint) ; ;#cs ; #FUNCTION# ================================================================================================================== ; Name...........: _CreateMainPanel ; Description ...: ; Syntax.........: _CreateMainPanel() ; Parameters ....: ; ; ; Return values .: ; Author ........: John Powers (g0gcd) ; Modified.......: 10/07/23 ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: ; ============================================================================================================================= Func _CreateMainPanel() ;Notes ;Use this to configure and name panel items _Log($LogTab & "_CreateMainPanel: Started.", $dBugLog) ;Global variables used ;$dBugLog, ;Declare local variables ;Local $_CreateMainPanel ;Populate local configurable variables ;Initialise local variables ;Local configuration ;Procedure ................................................................................................................ Opt("GUIOnEventMode", 1) ;Define GUI .............................................................................................................................................. $hGUI = GUICreate("MT8801C Controller", $iGUI_Width, $iGUI_Height, $iGUI_Left, $iGUI_Top) ;Basic Panel ;Define Main GUI layout .................................................................................................................................. ; $Main = GUICtrlCreateTab(8, 8, 425, 400) ; Tab within panel, for expansion if required ; $MainTab = GUICtrlCreateTabItem("Main") ; -"- ; $Checkbox1 = GUICtrlCreateCheckbox("", 40, 112, 97, 17) ; Checkbox within panel, for expansion if required $hTitle = GUICtrlCreateLabel ($sTitle_Caption, $aCol[1], $aRow[1]-45, $aW[55], $aH[3]/2, $SS_CENTER);, exStyle = -1]]]] ) GUICtrlSetFont ($hTitle, $iTitle_Caption_FontSize, $FW_BOLD, $GUI_FONTNORMAL, "", $CLEARTYPE_QUALITY) ;Define Loop control buttons ............................................................................................................................. $hRun = GUICtrlCreateButton("No Radio Selected", $aCol[1], $aRow[20], $aW[4], $aH[1]) ; Controls Test Run/Pause/Resume and initial Connect and Load functions $hPause = GUICtrlCreateButton("Pause", $aCol[1], $aRow[20], $aW[4], $aH[1]) ; PAUSE, sits on top of $hRun when enabled $hResume = GUICtrlCreateButton("Resume", $aCol[1], $aRow[20], $aW[4], $aH[1]) ; RESUME, sits on top of $hRun when enabled $hRestart = GUICtrlCreateButton("Restart Tests", $aCol[6], $aRow[20], $aW[4], $aH[1]) ; RESTART, next to $hRun when paused $hStop = GUICtrlCreateButton("Stop Tests", $aCol[11], $aRow[20], $aW[4], $aH[1]) ; STOP, next to $hRestart when paused $hKill = GUICtrlCreateButton("Close Program", $aCol[53], $aRow[23], $aW[4], $aH[1]) ; EXIT program ;Define Reporting/Progress buttons ....................................................................................................................... $aPanel[$cFProg][$cTitle] = 0; No title for Progress reporting bar $aPanel[$cFProg][$cMessage] = GUICtrlCreateProgress($aCol[14], $aRow[13], $aW[19], $aH[1]) $aPanel[$cFProg][$cConfirm] = GUICtrlCreateLabel("Progress",$aCol[35], $aRow[13], $aW[3], $aH[1], $cCentered) ;Define Analyser Status indicators ....................................................................................................................... $hAStatusTitle = GUICtrlCreateLabel("Analyser Status", $aCol[14], $aRow[3], $aW[6], $aH[1]) GUICtrlSetFont($hAStatusTitle, "", $FW_BOLD, $GUI_FONTNORMAL, "", $CLEARTYPE_QUALITY) $hAStatusMessage = GUICtrlCreateButton("Connecting", $aCol[28], $aRow[3], $aW[4], $aH[1]) GUICtrlSetColor($hAStatusMessage, $COLOR_RED) $hAFrequencyTitle = GUICtrlCreateLabel("Frequency", $aCol[14], $aRow[5], $aW[6], $aH[1]) $hAFrequencyMessage = GUICtrlCreateLabel("n/a", $aCol[18], $aRow[5], $aW[9], $aH[1]) $hAOLVLTitle = GUICtrlCreateLabel("Output Level", $aCol[28], $aRow[5], $aW[6], $aH[1]) $hAOLVLMessage = GUICtrlCreateLabel("OFF", $aCol[32], $aRow[5], $aW[9], $aH[1]) $hASINADTitle = GUICtrlCreateLabel("SINAD", $aCol[14], $aRow[6], $aW[6], $aH[1]) $hASINADMessage = GUICtrlCreateLabel("n/a", $aCol[18], $aRow[6], $aW[9], $aH[1]) $hARFPortTitle = GUICtrlCreateLabel("RF Connector", $aCol[28], $aRow[6], $aW[6], $aH[1]) $hARFPortMessage = GUICtrlCreateLabel("n/a", $aCol[32], $aRow[6], $aW[9], $aH[1]) ;Define Protection Attenuator controls .................................................................................................................... $hAPAdBSelectTitle = GUICtrlCreateLabel ("Protection Attenuator Value", $aCol[1], $aRow[15], $aW[6], $aH[1], $cCentered) $hAPAdBSelectMessage = GUICtrlCreateCombo("", $aCol[8], $aRow[15], $aW[3], $aH[3], $CBS_DROPDOWN) GUICtrlSetData($hAPAdBSelectMessage, $APAdBAvailableValues, $APAdBLastUsed) $aPanel[$cAPAdB][$cTitle] = 0; No title for protection attenuator message $aPanel[$cAPAdB][$cMessage] = GUICtrlCreateLabel("", $aCol[14], $aRow[15], $aW[19], $aH[1], $cLefted) $aPanel[$cAPAdB][$cConfirm] = GUICtrlCreateLabel("", $aCol[35], $aRow[15], $aW[1], $aH[1], $cCentered) GUICtrlSetColor($aPanel[$cAPAdB][$cConfirm], $COLOR_WHITE) ;GUICtrlSetBkColor($aPanel[$cAPAdB][$cConfirm], $COLOR_RED) $aPanel[$cAPAdB][$cButton] = 1; = Not confirmed ;Define Radio selection controls ......................................................................................................................... $hRTypeList = GUICtrlCreateList("", $aCol[1], $aRow[3], $aW[10], $aH[10], $iRTypeList_Style) ;List of radios $hRTypeSelect = GUICtrlCreateButton($sRTypeSelect_Caption, $aCol[5], $aRow[13], $aW[3], $aH[1]) ;Select Radio from list ;Define Radio Frequency controls ......................................................................................................................... $aPanel[$cRFreq][$cTitle] = GUICtrlCreateLabel ("Frequency", $aCol[1], $aRow[23], $aW[6], $aH[1],$cLefted) $aPanel[$cRFreq][$cMessage] = GUICtrlCreateLabel("--------", $aCol[4], $aRow[23], $aW[6], $aH[1], $cLefted) $aPanel[$cRFreq][$cConfirm] = GUICtrlCreateLabel("", $aCol[10], $aRow[23], $aW[1], $aH[1], $cCentered) GUICtrlSetColor($aPanel[$cRFreq][$cConfirm], $COLOR_WHITE) GUICtrlSetBkColor($aPanel[$cRFreq][$cConfirm], $COLOR_RED) $aPanel[$cRFreq][$cButton] = 1; = Not confirmed ;Define Radio Mode controls .............................................................................................................................. $aPanel[$cRMode][$cTitle] = GUICtrlCreateLabel ("Mode", $aCol[1], $aRow[24], $aW[6], $aH[1],$cLefted) $aPanel[$cRMode][$cMessage] = GUICtrlCreateLabel("---", $aCol[4], $aRow[24], $aW[6], $aH[1], $cLefted) $aPanel[$cRMode][$cConfirm] = GUICtrlCreateLabel("", $aCol[10], $aRow[24], $aW[1], $aH[1], $cCentered) GUICtrlSetColor($aPanel[$cRMode][$cConfirm], $COLOR_WHITE) GUICtrlSetBkColor($aPanel[$cRMode][$cConfirm], $COLOR_RED) $aPanel[$cRMode][$cButton] = 1; = Not confirmed ;Define Radio Antena Port 1 controls ..................................................................................................................... $aPanel[$cRAnt1][$cTitle] = GUICtrlCreateLabel("Antenna Port", $aCol[38], $aRow[23], $aW[3], $aH[1], $cLefted) $aPanel[$cRAnt1][$cMessage] = GUICtrlCreateLabel("", $aCol[42], $aRow[23], $aW[2], $aH[1], $cLefted) $aPanel[$cRAnt1][$cConfirm] = GUICtrlCreateLabel("", $aCol[44], $aRow[23], $aW[1], $aH[1], $cCentered) GUICtrlSetColor( $aPanel[$cRAnt1][$cConfirm], $COLOR_WHITE) GUICtrlSetBkColor($aPanel[$cRAnt1][$cConfirm], $COLOR_WHITE) $aPanel[$cRAnt1][$cButton] = 1; = Not confirmed ;Define Radio Antena Port 2 controls ..................................................................................................................... $aPanel[$cRAnt2][$cTitle] = GUICtrlCreateLabel("", $aCol[38], $aRow[24], $aW[3], $aH[1], $cLefted) $aPanel[$cRAnt2][$cMessage] = GUICtrlCreateLabel("", $aCol[42], $aRow[24], $aW[2], $aH[1], $cLefted) $aPanel[$cRAnt2][$cConfirm] = GUICtrlCreateLabel("", $aCol[44], $aRow[24], $aW[1], $aH[1], $cCentered) GUICtrlSetColor( $aPanel[$cRAnt2][$cConfirm], $COLOR_WHITE) GUICtrlSetBkColor($aPanel[$cRAnt2][$cConfirm], $COLOR_WHITE) $aPanel[$cRAnt2][$cButton] = 1; = Not confirmed ;Define Radio Antena Port 3 controls ..................................................................................................................... $aPanel[$cRAnt3][$cTitle] = GUICtrlCreateLabel("", $aCol[46], $aRow[23], $aW[3], $aH[1], $cLefted) $aPanel[$cRAnt3][$cMessage] = GUICtrlCreateLabel("", $aCol[48], $aRow[23], $aW[2], $aH[1], $cLefted) $aPanel[$cRAnt3][$cConfirm] = GUICtrlCreateLabel("", $aCol[50], $aRow[23], $aW[1], $aH[1], $cCentered) GUICtrlSetColor( $aPanel[$cRAnt3][$cConfirm], $COLOR_WHITE) GUICtrlSetBkColor($aPanel[$cRAnt3][$cConfirm], $COLOR_WHITE) $aPanel[$cRAnt3][$cButton] = 1; = Not confirmed ;Define Radio Antena Port 4 controls ..................................................................................................................... $aPanel[$cRAnt4][$cTitle] = GUICtrlCreateLabel("", $aCol[46], $aRow[24], $aW[3], $aH[1], $cLefted) $aPanel[$cRAnt4][$cMessage] = GUICtrlCreateLabel("", $aCol[48], $aRow[24], $aW[2], $aH[1], $cLefted) $aPanel[$cRAnt4][$cConfirm] = GUICtrlCreateLabel("", $aCol[50], $aRow[24], $aW[1], $aH[1], $cCentered) GUICtrlSetColor( $aPanel[$cRAnt4][$cConfirm], $COLOR_WHITE) GUICtrlSetBkColor($aPanel[$cRAnt4][$cConfirm], $COLOR_WHITE) $aPanel[$cRAnt4][$cButton] = 1; = Not confirmed ;Define Results panel .................................................................................................................................... $hAResultsList = GUICtrlCreateEdit("Test Results", $aCol[38], $aRow[3], $aW[19], $aH[19], BitOr($GUI_SS_DEFAULT_EDIT, $ES_READONLY)) ;Define Results panel .................................................................................................................................... $aPanel[$cPMask][$cMessage] = GUICtrlCreateLabel("", $aCol[1], $aRow[23], $aW[52], $aH[3]) $aPanel[$cPStat][$cTitle] = 0; No title for process message box $aPanel[$cPStat][$cMessage] = GUICtrlCreateLabel("", $aCol[14], $aRow[17], $aW[19], $aH[1], $cLefted) $aPanel[$cPStat][$cConfirm] = 0; No confirm for process message box ;Starting state ========================================================================================================================================== _Set_GUICtrlInitialState() GUIRegisterMsg($WM_COMMAND, "_WM_COMMAND") ; Process button press GUISetState(@SW_SHOW) ; Last thing of all _Log($LogTab & "_CreateMainPanel: Completed.", $dBugLog) ;Return $_CreateMainPanel EndFunc ;==>_CreateMainPanel ;#ce ;------------------------------------------------------------------------------------------------------------------------------ #cs ; #FUNCTION# ================================================================================================================== ; Name...........: _Panel_ProcessButtons ; Description ...: ; Syntax.........: _Panel_ProcessButtons() ; Parameters ....: ; ; ; Return values .: ; Author ........: John Powers (g0gcd) ; Modified.......: 10/07/23 ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: ; ============================================================================================================================= Func _Panel_ProcessButtons() ; temporary location. After development, move to / replace _Panel_ProcessButtonsX(), or main procedure loop ;Notes ;Used to process procedures called by button presses. Procedures must clear button presses ;Unlocks for other buttons at the end of the associated procedure ;LOCKS GUI WHILST PROCEDURES ARE RUNNING ;Notes ;_Log($LogTab & "_Panel_ProcessButtons: Started.", $dBugLog) ;Global variables used ;$dBugLog, ;Declare local variables ;Local $_Panel_ProcessButtons ;Populate local configurable variables ;Initialise local variables ;Local configuration ;Procedure ................................................................................................................ If $bTESTING_ENABLED Then _RunNextTest() ;If $bKill_press Then _KillApp() ;If $bRun_press Then StartThis() ; Needs immediate action - se _WM_COMMAND() ;If $bPause_press Then _PauseTests() ; Needs immediate action - se _WM_COMMAND() If $bStop_press Then _StopTests() If $bResume_press Then _ResumeTests() If $bRTypeSelect_press Then _Load_Radio() ;_Log($LogTab & "_Panel_ProcessButtons: Completed.", $dBugLog) ;Return $_Panel_ProcessButtons EndFunc ;==>_Panel_ProcessButtons #ce ;------------------------------------------------------------------------------------------------------------------------------ ;#cs ; #FUNCTION# ================================================================================================================== ; Name...........: _Load_Radio ; Description ...: ; Syntax.........: _Load_Radio() ; Parameters ....: ; ; ; Return values .: ; Author ........: John Powers (g0gcd) ; Modified.......: 10/07/23 ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: ; ============================================================================================================================= Func _Load_Radio() ;Notes ;_Log($LogTab & "_Load_Radio: Started.", $dBugLog) ;Global variables used ;$dBugLog, ;Declare local variables ;Local $_Load_Radio Local $aTmp Local $aResult Local $sFill Local $sMaxTXPower Local $iMaxPower Local $APAdBMin ;Populate local configurable variables ;Initialise local variables ;Local configuration ;Procedure ................................................................................................................ ;$iRTypeSelect_button = 0 $bRTypeSelect_press = False $aSelectedItems = _GUICtrlListBox_GetSelItemsText($hRTypeList) ; Read the selected item characteristics to an array $sRadio_Type = $aSelectedItems[1] ; Pick only the first item (if multiples were selected) ;Create Report file for this Radio / test run DirCreate(@ScriptDir & "\Reports") $sResultFile = @ScriptDir & "\Reports\" & $sRadio_Type & ".txt" FileDelete($sResultFile) FileWrite($sResultFile, _g0gcd_IniFile("[R]ReportHeader", "", "Reporting", $sIniFilename) & @CRLF) ;Extract an array of all of the tests specified for this radio ; Global $aFullTestList[1][3] $sFullTestList = ""; string version - older approach, still used for reset/restart $iTestCount = 0 $aResult = IniReadSection($sIniFilename,"RadioSpec_" & $sRadio_Type); Should reset the list For $iTests = 1 to $aResult[0][0]; handle error where no enries are found If StringInStr($aResult[$iTests][0],"Test") >= 1 Then ;Older approach - string of tests $sFullTestList &= StringLeft($aResult[$iTests][1],4) ;Newer version - array of tests and control settings $aTmp = StringSplit($aResult[$iTests][1], ",") If $aTmp[0] = 1 Then $sFill = $aTmp[1] & "| | " ; Only test code, e.g. [F03C][][] If $aTmp[0] = 2 Then $sFill = $aTmp[1] & "|" & $aTmp[2] & "| " ; Test code and antennas available for this test, e.g. [F03C][FR][] If $aTmp[0] > 2 Then $sFill = $aTmp[1] & "|" & $aTmp[2] & "|" & $aTmp[3] ; Test code, antennas and spec, e.g. [F03C][FR][0.2] _ArrayAdd ($aFullTestList, $sFill) $iTestCount += 1 Endif Next $sTestList = $sFullTestList ;Old method - list of tests only $aFullTestList[0][0] = $iTestCount ;New method - array of tests/antennas/specification (controls?) GUICtrlSetData($aPanel[$cFProg][$cConfirm], $iTestCount & " Tests") ;insert start freq/mode conditions for radio? ;extract first test ; populate freq message box, set confirm to qy ; populate mode message box, set confirm to qy ;Select suitable port for radio ; For implex, i.e. transmitter or receiver only, use Half Duplex with filtered test list. $sMT8801_RFPort = _g0gcd_IniFile("[R]Duplex", "NotFound", "RadioSpec_" & $sRadio_Type, $sIniFilename) If StringUpper(StringLeft($sMT8801_RFPort,1))="F" Then ; Full duplex = Aux ports _g0gcd_IniFile("[O]Duplex", "Full", "RadioSpec_" & $sRadio_Type, $sIniFilename) $sMT8801_RFPort = "AUX" Else ; Half Duplex = Main port _g0gcd_IniFile("[R]Duplex", "Half", "RadioSpec_" & $sRadio_Type, $sIniFilename) $sMT8801_RFPort = "MAIN" EndIf GUICtrlSetData($hARFPortMessage, $sMT8801_RFPort) ;Handle creation of protection attenuator value $sMaxTXPower=_g0gcd_IniFile("[R]MaxTXPower","NotFound","RadioSpec_" & $sRadio_Type,$sIniFilename) If $sMaxTXPower = "NotFound" Then $sMaxTXPower = "100W" ; Extract power / convert to dB, work out minimum attentuation $iMaxPower = Number(StringRegExpReplace($sMaxTXPower, "\D", "")) $APAdBMin=Round((10* log($iMaxPower)/log(10))); minimum attenuation level required in dB $APAdBMin += 5 ; 5dB extra for good luck / headroom ; Adjust the available values to only permit appropriate ones $aTmp = StringSplit($APAdBAvailableValues, "|", $STR_NOCOUNT) For $pTmp = UBound($aTmp) - 1 to 0 step -1 If Number(StringRegExpReplace($aTmp[$pTmp], "\D", "")) < $APAdBMin Then _ArrayDelete($aTmp,$pTmp) Endif Next $APAdBAvailableValues = "|" & _ArrayToString($aTmp); Leading "|" to clear existing list contents ; Set up the display GUICtrlSetData($aPanel[$cAPAdB][$cMessage],"Insert >" & $APAdBMin & "dB (>" & $iMaxPower & "W) protection attentuator between the " & _ $sRadio_Type & " and the Analyser " & $sMT8801_RFPort & " connector") GUICtrlSetData($hAPAdBSelectMessage, $APAdBAvailableValues, $APAdBLastUsed) GUICtrlSetState($hAPAdBSelectMessage, $GUI_ENABLE + $GUI_SHOW) GUICtrlSetData($aPanel[$cAPAdB][$cConfirm], $cQY) ; } GUICtrlSetBkColor($aPanel[$cAPAdB][$cConfirm], $COLOR_RED) ; } _Panel_SetStatus()? $aPanel[$cAPAdB][$cButton] = 1 ; } ;GUICtrlSetData($hRun, "Test " & $sRadio_Type) GUICtrlSetData($hRun, "Confirm Attenuator") GUICtrlSetState($hRun, $GUI_DISABLE + $GUI_SHOW) GUICtrlSetState($hPause, $GUI_DISABLE + $GUI_HIDE) GUICtrlSetState($hResume, $GUI_DISABLE + $GUI_HIDE) GUICtrlSetState($hRestart, $GUI_DISABLE + $GUI_HIDE) GUICtrlSetState($hStop, $GUI_DISABLE + $GUI_HIDE) GUICtrlSetState($hKill, $GUI_ENABLE + $GUI_SHOW) ;GUICtrlSetState($hRun, $GUI_ENABLE + $GUI_SHOW) _Log($LogTab & $sRadio_Type & " selected") ;_Log($LogTab & "_Load_Radio: Completed.", $dBugLog) ;Return $_Load_Radio EndFunc ;==>_Load_Radio ;#ce ;------------------------------------------------------------------------------------------------------------------------------ ;#cs ; #FUNCTION# ================================================================================================================== ; Name...........: _Log ; Description ...: Redirects a call to a library function. Used so that a shorter function name can be used ; Syntax.........: _Log($Message, $Write2Log = True, $Separator = ">", $sLogFilename = "") ; Parameters ....: $Message, Text to be logged ; $Write2Log, True to write to log, no action if false ; $Separator, character separating timestamp from message ; $sLogFilename, name of the logfile ; Return values .: None ; Author ........: John Powers (g0gcd) ; Modified.......: 20/06/23 ; Remarks .......: Logfile is static. Messages are stored in memory until a logfile is defined. The cache is then written to ; file. Next call to the function writes to the same logfile. ; Related .......: ; Link ..........: ; Example .......: ; ============================================================================================================================= Func _Log($Message, $Write2Log = True, $Separator = ">", $sLogFilename = "") ;Notes ;_Log($LogTab & "_Log: Started.", $dBugLog) ; Warning - potential infinite recursive loop! ;Global variables used ;$dBugLog ;Populate local configurable variables ;Initialise local variables ;Procedure ................................................................................................................ _g0gcd_Log($Message, $Write2Log, $Separator, $sLogFilename) ;_Log($LogTab & "_Log: Completed.", $dBugLog) EndFunc ;==>_Log ;#ce ;------------------------------------------------------------------------------------------------------------------------------ ;#cs ; #FUNCTION# ================================================================================================================== ; Name...........: _Panel_SetStatus ; Description ...: ; Syntax.........: _Panel_SetStatus() ; Parameters ....: ; ; ; Return values .: ; Author ........: John Powers (g0gcd) ; Modified.......: 10/07/23 ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: ; ============================================================================================================================= Func _Panel_SetStatus($pGroup, $pControl = $cAll, $sMessage = "", $sSetting = $cFull) #forceref $sMessage ;Notes ;_Log($LogTab & "_Panel_SetStatus: Started.", $dBugLog) ;Global variables used ;$dBugLog, ;Declare local variables Local $_Panel_SetStatus ;Populate local configurable variables ;Initialise local variables ;Local configuration ;Procedure ................................................................................................................ ;_Log($LogTab & "_Panel_SetStatus: Group='" & $pGroup & "', Control='" & $pControl & "', Message='" & $cAll & "', Setting='" & $sSetting & "'") #cs Switch StringLeft(StringLower($sSetting),2) Case "ok" GUICtrlSetData($aPanel[$pGroup][$pControl], $cOK) GUICtrlSetBkColor($aPanel[$pGroup][$pControl], $COLOR_GREEN) $_Panel_SetStatus = 0 Case "qy" GUICtrlSetData($aPanel[$pGroup][$pControl], $cQY) GUICtrlSetBkColor($aPanel[$pGroup][$pControl], $COLOR_RED) $_Panel_SetStatus = 1 Case "na" If $pControl = $cAll Then GUICtrlSetState($aPanel[$pGroup][$cTitle], $GUI_DISABLE + $GUI_SHOW);$GUI_HIDE) ;GUICtrlSetData($aPanel[$pGroup][$cTitle], "") ;GUICtrlSetBkColor($aPanel[$pGroup][$cTitle], $COLOR_WHITE) GUICtrlSetState($aPanel[$pGroup][$cMessage], $GUI_DISABLE + $GUI_SHOW);$GUI_HIDE) ;GUICtrlSetData($aPanel[$pGroup][$cMessage], "") ;GUICtrlSetBkColor($aPanel[$pGroup][$cMessage], $COLOR_WHITE) GUICtrlSetState($aPanel[$pGroup][$cConfirm], $GUI_DISABLE + $GUI_SHOW);$GUI_HIDE) GUICtrlSetData($aPanel[$pGroup][$cConfirm], "") GUICtrlSetBkColor($aPanel[$pGroup][$cConfirm], $COLOR_WHITE) Else GUICtrlSetState($aPanel[$pGroup][$pControl], $GUI_DISABLE + $GUI_SHOW);$GUI_HIDE) GUICtrlSetData($aPanel[$pGroup][$pControl], "") GUICtrlSetBkColor($aPanel[$pGroup][$pControl], $COLOR_WHITE) Endif $_Panel_SetStatus = 0 #ce EndSwitch Switch $sSetting Case $cHide If $pControl = $cAll Then ; Hide all three controls but leave contents intact GUICtrlSetState($aPanel[$pGroup][$cTitle], $GUI_DISABLE + $GUI_HIDE) ; GUICtrlSetState($aPanel[$pGroup][$cTitle], $GUI_DISABLE + $GUI_SHOW);$GUI_HIDE); debug ;GUICtrlSetData($aPanel[$pGroup][$cTitle], "") ;GUICtrlSetBkColor($aPanel[$pGroup][$cTitle], $COLOR_WHITE) GUICtrlSetState($aPanel[$pGroup][$cMessage], $GUI_DISABLE + $GUI_HIDE) ; GUICtrlSetState($aPanel[$pGroup][$cMessage], $GUI_DISABLE + $GUI_SHOW);$GUI_HIDE); debug ;GUICtrlSetData($aPanel[$pGroup][$cMessage], "") ;GUICtrlSetBkColor($aPanel[$pGroup][$cMessage], $COLOR_WHITE) GUICtrlSetState($aPanel[$pGroup][$cConfirm], $GUI_DISABLE + $GUI_HIDE) ; GUICtrlSetState($aPanel[$pGroup][$cConfirm], $GUI_DISABLE + $GUI_SHOW);$GUI_HIDE); debug GUICtrlSetData($aPanel[$pGroup][$cConfirm], "") GUICtrlSetBkColor($aPanel[$pGroup][$cConfirm], $COLOR_WHITE) Else GUICtrlSetState($aPanel[$pGroup][$pControl], $GUI_DISABLE + $GUI_HIDE) ; GUICtrlSetState($aPanel[$pGroup][$pControl], $GUI_DISABLE + $GUI_SHOW);$GUI_HIDE); debug GUICtrlSetData($aPanel[$pGroup][$pControl], "") GUICtrlSetBkColor($aPanel[$pGroup][$pControl], $COLOR_WHITE) Endif Case $cShow If $pControl = $cAll Then ; Show only all three controls but leave contents intact GUICtrlSetState($aPanel[$pGroup][$cTitle], $GUI_DISABLE + $GUI_SHOW) ;GUICtrlSetData($aPanel[$pGroup][$cTitle], "") ;GUICtrlSetBkColor($aPanel[$pGroup][$cTitle], $COLOR_WHITE) GUICtrlSetState($aPanel[$pGroup][$cMessage], $GUI_DISABLE + $GUI_SHOW) ;GUICtrlSetData($aPanel[$pGroup][$cMessage], "") ;GUICtrlSetBkColor($aPanel[$pGroup][$cMessage], $COLOR_WHITE) GUICtrlSetState($aPanel[$pGroup][$cConfirm], $GUI_DISABLE + $GUI_SHOW) ;GUICtrlSetData($aPanel[$pGroup][$cConfirm], "") ;GUICtrlSetBkColor($aPanel[$pGroup][$cConfirm], $COLOR_WHITE) Else GUICtrlSetState($aPanel[$pGroup][$pControl], $GUI_DISABLE + $GUI_SHOW) ;GUICtrlSetData($aPanel[$pGroup][$pControl], "") ;GUICtrlSetBkColor($aPanel[$pGroup][$pControl], $COLOR_WHITE) Endif Case $cFull If $pControl = $cAll Then ; Enable all three controls but leave contents intact GUICtrlSetState($aPanel[$pGroup][$cTitle], $GUI_ENABLE + $GUI_SHOW) ;GUICtrlSetData($aPanel[$pGroup][$cTitle], "") ;GUICtrlSetBkColor($aPanel[$pGroup][$cTitle], $COLOR_WHITE) GUICtrlSetState($aPanel[$pGroup][$cMessage], $GUI_ENABLE + $GUI_SHOW) ;GUICtrlSetData($aPanel[$pGroup][$cMessage], "") ;GUICtrlSetBkColor($aPanel[$pGroup][$cMessage], $COLOR_WHITE) GUICtrlSetState($aPanel[$pGroup][$cConfirm], $GUI_ENABLE + $GUI_SHOW) ;GUICtrlSetData($aPanel[$pGroup][$cConfirm], "") ;GUICtrlSetBkColor($aPanel[$pGroup][$cConfirm], $COLOR_WHITE) Else GUICtrlSetState($aPanel[$pGroup][$pControl], $GUI_ENABLE + $GUI_SHOW) ;GUICtrlSetData($aPanel[$pGroup][$pControl], "") ;GUICtrlSetBkColor($aPanel[$pGroup][$pControl], $COLOR_WHITE) Endif EndSwitch $_Panel_SetStatus = 0; Status of Confirm button. 0 = confirmed or not available ;_Log($LogTab & "_Panel_SetStatus: Completed.", $dBugLog) Return $_Panel_SetStatus EndFunc ;==>_Panel_SetStatus ;#ce ;------------------------------------------------------------------------------------------------------------------------------ ;#cs ; #FUNCTION# ================================================================================================================== ; Name...........: _SetCtrl ; Description ...: Sets a GUICtrlState, or GUICtrlData based on the parameters ; Syntax.........: _SetCtrl($hRun, $cHide) OR _SetCtrl($hRun, "Message") ; Parameters ....: $hCtrl, Handle to the control to be manipulated ; $_MSG, parameter to be actioned ; Return values .: TBA ; Author ........: John Powers (g0gcd) ; Modified.......: 11/07/23 ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: ; ============================================================================================================================= Func _SetCtrl($hCtrl, $_MSG) ;Notes ;_Log($LogTab & "_SetCtrl: Started.", $dBugLog) ;Global variables used ;$dBugLog, ;Declare local variables ;Local $_SetCtrl ;Populate local configurable variables ;Initialise local variables ;Local configuration ;Procedure ................................................................................................................ If IsString($_MSG) Then ; process a text message GUICtrlSetData($hCtrl, $_MSG) Else ; process a system message Switch $_MSG Case $cConf ; set control to Confirmed GUICtrlSetState($hCtrl, $_FULL) GUICtrlSetData($hCtrl, $cOK) GUICtrlSetBkColor($hCtrl, $COLOR_GREEN) Case $cAvailable ; set control to Available Option GUICtrlSetState($hCtrl, $_FULL) GUICtrlSetData($hCtrl, "") GUICtrlSetBkColor($hCtrl, $COLOR_WHITE) Case $cUnConf ; set control to Unconfirmed GUICtrlSetState($hCtrl, $_FULL) GUICtrlSetData($hCtrl, $cQY) GUICtrlSetBkColor($hCtrl, $COLOR_RED) Case Else ; otherwise is a raw GUI command GUICtrlSetState($hCtrl, $_MSG) EndSwitch Endif ;_Log($LogTab & "_SetCtrl: Completed.", $dBugLog) ;Return $_SetCtrl EndFunc ;==>_SetCtrl ;#ce ;------------------------------------------------------------------------------------------------------------------------------ ;#cs ; #FUNCTION# ================================================================================================================== ; Name...........: _Set_GUICtrlLayoutGrid ; Description ...: Populates a grid of L,T,W,H for based on the panel size, for laying out GUI controls ; Syntax.........: _Set_GUICtrlLayoutGrid(ByRef $aAnchor, ByRef $aSize, $iStep, $iMargin, $iGutter, $iConstraint) ; Parameters ....: ByRef $aAnchor, Left or Top of cell ; ByRef $aSize, Width or Height of cell ; $iStep, Increment of Cell Left, Top ; $iMargin, Offset of Cell Left, Top ; $iGutter, Gap between cells ; $iConstraint, Maximum width or height of array ; Return values .: None ; Author ........: John Powers (g0gcd) ; Modified.......: 30/06/23 ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: ; ============================================================================================================================= Func _Set_GUICtrlLayoutGrid(ByRef $aAnchor, ByRef $aSize, $iStep, $iMargin, $iGutter, $iConstraint) ;Notes ;_Log($LogTab & "_Set_GUICtrlLayoutGrid: Started.", $dBugLog) ;Global variables used ;$dBugLog, ;Declare local variables ;Local $_Set_GUICtrlLayoutGrid ;Populate local configurable variables ;Initialise local variables Local $iMaxCol = 0 Local $iIncrement = $iMargin ;Procedure ................................................................................................................ _ArrayAdd ($aAnchor,0); Reserve space for array size _ArrayAdd ($aSize,0) While $iIncrement + $iStep <= $iConstraint _ArrayAdd ($aAnchor, $iIncrement) _ArrayAdd ($aSize, (($iMaxCol+1) * $iStep) - $iGutter) $iIncrement += $iStep $iMaxCol += 1 Wend $aAnchor[0] = $iMaxCol $aSize[0] = $iMaxCol ;_Log($LogTab & "_Set_GUICtrlLayoutGrid: Completed.", $dBugLog) ;Return $_Set_GUICtrlLayoutGrid EndFunc ;==>_Set_GUICtrlLayoutGrid ;#ce ;------------------------------------------------------------------------------------------------------------------------------ ;#cs ; #FUNCTION# ================================================================================================================== ; Name...........: _Set_GUICtrlInitialState ; Description ...: ; Syntax.........: _Set_GUICtrlInitialState() ; Parameters ....: ; ; ; Return values .: ; Author ........: John Powers (g0gcd) ; Modified.......: 10/07/23 ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: ; ============================================================================================================================= Func _Set_GUICtrlInitialState() ;Notes ;_Log($LogTab & "_Set_GUICtrlInitialState: Started.", $dBugLog) ;Global variables used ;$dBugLog, ;Declare local variables ;Local $_Set_GUICtrlInitialState ;Populate local configurable variables ;Initialise local variables ;Local configuration ;Procedure ................................................................................................................ $bRun_press = False $bPause_press = False $bResume_press = False $bRestart_press = False $bStop_press = False $bTESTING_ENABLED = False _SetCtrl($hRun, $_SHOW) _SetCtrl($hPause, $_HIDE) _SetCtrl($hResume, $_HIDE) _SetCtrl($hRestart, $_HIDE) _SetCtrl($hStop, $_HIDE) _SetCtrl($hKill, $_FULL) _Panel_SetStatus($cFProg, $cAll, "", $cHide) _Panel_SetStatus($cRFreq, $cAll, "", $cHide) _Panel_SetStatus($cRMode, $cAll, "", $cHide) _Panel_SetStatus($cRAnt1, $cAll, "", $cHide) _Panel_SetStatus($cRAnt2, $cAll, "", $cHide) _Panel_SetStatus($cRAnt3, $cAll, "", $cHide) _Panel_SetStatus($cRAnt4, $cAll, "", $cHide) _SetCtrl($aPanel[$cPMask][$cMessage], $_FULL);HIDE);$_FULL) _SetCtrl($aPanel[$cPStat][$cMessage], $_FULL) ; _SetCtrl($aPanel[$cRAnt1][$cConfirm], $_HIDE);FULL); redundant? ;_Log($LogTab & "_Set_GUICtrlInitialState: Completed.", $dBugLog) ;Return $_Set_GUICtrlInitialState EndFunc ;==>_Set_GUICtrlInitialState ;#ce ;------------------------------------------------------------------------------------------------------------------------------ ;#cs ;#cs ; #FUNCTION# ================================================================================================================== ; Name...........: _WriteResultToScreen ; Description ...: ; Syntax.........: _WriteResultToScreen() ; Parameters ....: ; ; ; Return values .: ; Author ........: John Powers (g0gcd) ; Modified.......: 10/07/23 ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: ; ============================================================================================================================= Func _WriteResultToScreen($text) ;Notes ;_Log($LogTab & "_WriteResultToScreen: Started.", $dBugLog) ;Global variables used ;$dBugLog, ;Declare local variables ;Local $_WriteResultToScreen ;Populate local configurable variables ;Initialise local variables ;Local configuration ;Procedure ................................................................................................................ Local $iEnd = StringLen(GUICtrlRead($hAResultsList)) _GUICtrlEdit_SetSel($hAResultsList, $iEnd, $iEnd) _GUICtrlEdit_Scroll($hAResultsList, $SB_SCROLLCARET) Local $Time = @Hour & ":" & @MIN & ":" & @SEC & " " GUICtrlSetData($hAResultsList, @CRLF & $Time & $text, 1) _Log($LogTab & $Time & $text, 1) ; FileWrite($sResultFile,$Time & $text) ;_Log($LogTab & "_WriteResultToScreen: Completed.", $dBugLog) ;Return $_WriteResultToScreen EndFunc ;==>_WriteResultToScreen ;#ce ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #EndRegion Program Functions ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ;============================================================================================================================== #Region Analyser Functions Func ___Analyser_Functions___(); Marker for SCITE Jump use EndFunc ;============================================================================================================================== ; #INDEX# ======================================================================================================================= ; Name ..........: _Anritsu_Helper_Analyser_Functions.au3 ; Title .........: Analyser Functions ; Description ...: Functions related to the control of, and communication with, the connected analyser ; Version Date ..: 2023-07-05 ; AutoIt Version : 3.3.14.5 ; Link ..........: ; Tag(s) ........: ; Author(s) .....: G0GCD ; Dll(s) ........: ; Error handling : tba ; =============================================================================================================================== ;#include-once ;#include "_Anritsu_Helper_Constants.au3" ;;#include "_Anritsu_Helper_Analyser_Functions.au3" ; This file! ;#include "_Anritsu_Helper_Program_Functions.au3" ;#include "_Anritsu_Helper_Test_Sequences.au3" ;#NoAutoIT3Execute ;#AutoIt3Wrapper_Au3Check_Parameters=-q -d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w- 7 ; _AInitAnalog($Ftx = 100000000, $Frx = 100000000) ; _AInitSystem($sMT8801_RFPort);$hMT8801COMPort, $Timeout, $Length, $EOL) ; _A_Say($sCommand, $iDelay = -1, $hMT8801COMPort = "") ;------------------------------------------------------------------------------------------------------------------------------ ;#cs ; #FUNCTION# ================================================================================================================== ; Name...........: _ACOMM ; Description ...: ; Syntax.........: _ACOMM() ; Parameters ....: None ; Return values .: String containing instrument ID, if successful ; Author ........: John Powers (g0gcd) ; Modified.......: 21/06/23 ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: ; ============================================================================================================================= Func _ACOMM() ;Notes ;_Log($LogTab & $LogTab & "_ACOMM: Started.", $dBugLog) ;Global variables used ;$dBugLog, ;Declare local variables Local $_ACOMM ;Populate local configurable variables ;Initialise local variables ;Procedure ................................................................................................................ ;Restart USB _Log($LogTab & "Resetting USB", $dBugLog) msgbox(0, "Initialise", "Please:" & @CRLF & _ "1 - Unplug the USB to Serial Adaptor" & @CRLF & _ "2 - Power up the instrument" & @CRLF & _ "3 - Wait for the instrument home screen" & @CRLF & _ "4 - Press Local to ensure 'Local' mode (Remote indicator is unlit)" & @CRLF & _ "5 - THEN click OK to continue") ; Post instructions for MT8801 setup; ;Instrument Setup ;[Interface] Connect to controller > RS232 ;[RS232] Baud Rate > 9600bps ;[RS232] Parity > Off ;[RS232] Data Bit > 8Bits ;[RS232] Stop Bit > 1bit Sleep(2000) Local $BeforePortsList = _COM_ListPorts() ; Consider replacing with _CommAPI_GetPorts() msgbox(0, "Initialise", "Please reconnect the USB to Serial Adaptor" & @CRLF & _ "THEN click OK to continue") Sleep(2000) Local $AfterPortsList = _COM_ListPorts() For $nPort = UBound($AfterPortsList)-1 to 0 step -1 ; $AfterPortsList[0] carries the number of ports - should be one more then $Before... If _ArraySearch($BeforePortsList,$AfterportsList[$nPort]) = -1 Then $iAPortNo = StringReplace($AfterPortsList[$nPort],"COM","") $nPort = -1 EndIf Next RunWait ("Devcon restart USB\ROOT*", @tempdir, @sw_hide) sleep(1000) ;Reset analyser and extract ID to confirm operation _Log($LogTab & "Opening COM Port", $dBugLog) Local $sICOMPortMode = _CommAPI_CreateModeString($iAPortNo, $iAPortBaud, $iAPortParity, $iAPortByteSize, $iAPortStopBits, $iAPortFlowXon) If @error then msgbox(0, "Error", "Setting $COMPortMode") $hMT8801COMPort = _CommAPI_OpenPort($sICOMPortMode) ; Is GLOBAL ! If @error Then msgbox(0, "Error", "Setting $COMPort") ; Needs proper error handling ;msgbox(0, "Port", "Setting:" & $iAPortNo & ", with: " & $hMT8801COMPort) _Log($LogTab & "Clearing COM Port", $dBugLog) _CommAPI_ClearCommError($hMT8801COMPort) ;If @error Then Return SetError(@error, @ScriptLineNumber) _Log($LogTab & "Purging COM Port", $dBugLog) _CommAPI_PurgeComm($hMT8801COMPort) ;If @error Then Return SetError(@error, @ScriptLineNumber) _Log($LogTab & "Initialising Anritsu communications", $dBugLog) $sResult = _A_Say("INI", 2000, $hMT8801COMPort) ;If @error Then Return SetError(@error, @ScriptLineNumber) If StringInstr($sResult, "Error") > 0 Then msgbox(0, "Error", $sResult); Needs proper error handling _A_Say("*IDN?") $sResult = _CommAPI_ReceiveString($hMT8801COMPort, $Timeout, $Length, $EOL) ;If @error Then Return SetError(@error, @ScriptLineNumber, $sResult) _Log($LogTab & "*IDN=" & $sResult, $dBugLog) If StringInStr($sResult, "Anritsu") > 0 Then ; Now find the InstanceID, knowing the COMPort number Local $aResult = _CommAPI_GetPorts(2, True, True) Local $row = _ArraySearch($aResult, $iAPortNo, 0, 0, 0, 1, 1, 1) If $row = -1 then ;error _g0gcd_IniFile("[O]InstanceID","NotFound","Config") Else ;$InstanceID = $aResult[$row][3] _g0gcd_IniFile("[O]MT8801Port_Number",$iAPortNo,"Config") _g0gcd_IniFile("[O]MT8801Port_InstanceID",$aResult[$row][3],"Config") EndIf Endif $_ACOMM = StringReplace($sResult,",0,0","") ;_Log($LogTab & "_ACOMM: Completed.", $dBugLog) Return $_ACOMM EndFunc ;==>_ACOMM ;#ce ;------------------------------------------------------------------------------------------------------------------------------ ;#cs ; #FUNCTION# ================================================================================================================== ; Name...........: _AConnect ; Description ...: ; Syntax.........: _AConnect() ; Parameters ....: None ; Return values .: True if Analyser is connected succesfully, false if unsuccessful ; Author ........: John Powers (g0gcd) ; Modified.......: 21/06/23 ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: $bResult = _AConnect() ; ============================================================================================================================= Func _AConnect() ;Notes ;_Log($LogTab & "_AConnect: Started.", $dBugLog) ;Global variables used ;$dBugLog, ;Declare local variables Local $_AConnect Local $aResult Local $Item Local $prg Local $sSearchKey Local $row ;Populate local configurable variables Local $iAPortInstanceID = _g0gcd_IniFile("[R]MT8801Port_InstanceID","", "Config", $sIniFilename) ;[R] returns "NotFound" if no Key and "" if Key with no value ;Initialise local variables ;Procedure ................................................................................................................ $_AConnect = False ; Have we a stored PortID? If $iAPortInstanceID <> "" AND $iAPortInstanceID <> "NotFound" then ; registered in the program ;msgbox(0,"Saved Serial Device ID", "Found: " & $iAPortInstanceID) $aResult = _CommAPI_GetPorts(2, True, True) $Item = _ArraySearch($aResult,$iAPortInstanceID) If $Item = -1 Then ; includes a replugged unit because it changes its ID ;msgbox(0,"Instrument Connection","Last used port is no longer available") Return False else $sSearchKey = StringLeft($iAPortInstanceID, StringInStr($iAPortInstanceID, "&") -1) & "*" ;msgbox(0,"Instrument Connection", "ShortKey:" & $sSearchKey) ;$prg = "Devcon help > """ & @ScriptDir & "\Devcon help.txt""" ;runwait(@comspec & " /c " & $prg, "", @SW_HIDE) ;;sleep(1000) $prg = "Devcon restart @""" & $sSearchKey & """"; > """ & @ScriptDir & "\PortTest1.txt""" runwait(@comspec & " /c " & $prg, "", @SW_HIDE) ;sleep(1000) $prg = "Devcon DISABLE @""" & $sSearchKey & """"; > """ & @ScriptDir & "\PortTest2.txt""" runwait(@comspec & " /c " & $prg, "", @SW_HIDE) ;sleep(1000) $prg = "Devcon ENABLE @""" & $sSearchKey & """"; > """ & @ScriptDir & "\PortTest3.txt""" runwait(@comspec & " /c " & $prg, "", @SW_HIDE) ;sleep(1000) ;Reset analyser and extract ID to confirm operation _Log($LogTab & "Opening COM Port", $dBugLog) Local $sMT8801COMPortMode = _CommAPI_CreateModeString($iAPortNo, $iAPortBaud, $iAPortParity, $iAPortByteSize, $iAPortStopBits, $iAPortFlowXon) If @error then msgbox(0, "Error", "Setting $COMPortMode") $hMT8801COMPort = _CommAPI_OpenPort($sMT8801COMPortMode); Is GLOBAL ! If @error Then msgbox(0, "Error", "Setting $COMPort") ; Needs proper error handling ;msgbox(0, "Port", "Setting:" & $iAPortNo & ", with: " & $hMT8801COMPort) _Log($LogTab & "Clearing COM Port", $dBugLog) _CommAPI_ClearCommError($hMT8801COMPort) ;If @error Then Return SetError(@error, @ScriptLineNumber) _Log($LogTab & "Purging COM Port", $dBugLog) _CommAPI_PurgeComm($hMT8801COMPort) ;If @error Then Return SetError(@error, @ScriptLineNumber) _Log($LogTab & "Initialising Anritsu communications", $dBugLog) $sResult = _A_Say("INI", 2000, $hMT8801COMPort) ;If @error Then Return SetError(@error, @ScriptLineNumber) _A_Say("*IDN?") $sResult = _CommAPI_ReceiveString($hMT8801COMPort, $Timeout, $Length, $EOL) ;If @error Then Return SetError(@error, @ScriptLineNumber, $sResult) _Log($LogTab & "*IDN=" & $sResult, $dBugLog) If StringInStr($sResult, "Anritsu") > 0 Then; success ; Now find the InstanceID, knowing the COMPort number $aResult = _CommAPI_GetPorts(2, True, True) $row = _ArraySearch($aResult, $iAPortNo, 0, 0, 0, 1, 1, 1) If $row = -1 then ;error ;_g0gcd_IniFile("[O]InstanceID","NotFound","Config") Else ;$InstanceID = $aResult[$row][3] _g0gcd_IniFile("[O]MT8801Port_Number",$iAPortNo,"Config") _g0gcd_IniFile("[O]MT8801Port_InstanceID",$aResult[$row][3],"Config") _AInitSystem("MAIN") $_AConnect = True EndIf EndIf endif Else ; no PortID saved ;msgbox(0,"Saved Serial Device ID", "None Found") ; $_AConnect = False Endif ;_Log($LogTab & $LogTab & "_AConnect: Completed.", $dBugLog) Return $_AConnect EndFunc ;-->_AConnect ;#ce ;------------------------------------------------------------------------------------------------------------------------------ ;#cs ; #FUNCTION# ================================================================================================================== ; Name...........: _AInitAnalog() ; Description ...: Sets the parameters on the ANALOG Common Parameters screen ; Syntax.........: _AInitAnalog($Ftx, $Frx) ; Parameters ....: $Ftx, Transmitter frequency, in MHz, default = 100.000MHz ; $Frx, Receiver frequency, in MHz, default = 100.000MHz ; Return values .: None ; Author ........: John Powers (g0gcd) ; Modified.......: 05/07/23 ; Remarks .......: See function comments for parameter settings ; Related .......: ; Link ..........: ; Example .......: ; ============================================================================================================================= Func _AInitAnalog($Ftx = 100, $Frx = 100) ;Notes ;_Log($LogTab & "_AInitAnalog: Started.", $dBugLog) ;Global variables used ;$dBugLog, ;Declare local variables Local $_AInitAnalog #forceref $_AInitAnalog ;Populate local configurable variables ;Initialise local variables ;Procedure ................................................................................................................ _A_Say("PNLMD ANALOG", 50) ; Set correct screen for input of ANALOG Common Parameters _A_Say("MEAS SETCOM") ; Initiate setting of common parameters ;CHAN n _A_Say("TXFREQ " & Int($Ftx & 1E6)) ; TX Frequency set to function parameter _A_Say("RXFREQ " & Int($Frx & 1E6)) ; RX Frequency set to function parameter ;CHANSPC f ;RFLVL 0 ;PRNG 40 _A_Say("OLVL -133") ; Signal Generator set to lowest output level ;ARNG 30 _A_Say("AIMP 100K") ; Audio channel input impedance set to high (100kOhms) _A_Say("AOIMP 600") ; Audio channel output impedance set to high (600Ohms) ;_Log($LogTab & "_AInitAnalog: Completed.", $dBugLog) ;Return $_AInitAnalog EndFunc ;==>_AInitAnalog ; Setting TX Measurement Parameters, when required... ; msgbox(0, "TX Measure Section", "Execute TXMEAS specific settings") ; Return ;TX MEASURE CONFIG ITEMS ;MEAS SETTX ;UCAL ;PMTH POW ;RFMM RF ;RRNG 4K ;RHPF OFF ;RLPF OFF ;RDEMP OFF ;RSQL OFF ;ARNG 4 ;STRG NORM ;VAVG OFF ;AVR n ; ...... etc ;#ce ;;------------------------------------------------------------------------------------------------------------------------------ ;#cs ; #FUNCTION# ================================================================================================================== ; Name...........: _AInitSystem() ; Description ...: Redirects a call to a library function. Used so that a shorter function name can be used ; Syntax.........: _AInitSystem($sMT8801_RFPort) ; Parameters ....: None ; Return values .: String containing instrument ID, if successful ; Author ........: John Powers (g0gcd) ; Modified.......: 21/06/23 ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: ; ============================================================================================================================= Func _AInitSystem($sMT8801_RFPort);$hMT8801COMPort, $Timeout, $Length, $EOL) ;Notes _Log($LogTab & "_AInitSystem: Started.", $dBugLog) ;Global variables used ;$dBugLog, ;Declare local variables Local $_AInitSystem ;Populate local configurable variables ;Initialise local variables ;Procedure ................................................................................................................ GUICtrlSetData($hAFrequencyMessage, "Standby") GUICtrlSetData($hAOLVLMessage, "Standby") GUICtrlSetData($hASINADMessage, "Standby") _A_Say("PNLMD SYSTEM", 0) ;REF 10MHZ _A_Say("RFINOUT " & $sMT8801_RFPort); MAIN") ;DISPL ON ;TTL USER ;TITLE xxx ; not setting title $_AInitSystem = "TBA";_($Result) = A_Say("TITLE?"); to read user configured title ;DATEMODE DMY _A_Say("DATE " & Stringmid(@YEAR,3,2) & "," & @MON & "," & @MDAY, 200) _A_Say("TIME " & @HOUR & "," & @MIN & "," & @SEC, 200) ;ALARM ON ;TRM 0 ;BAUD 9600 ;PRTY OFF ;DTAB 8 ;STPB 1 ;TOUT xxx ;DELM 0 ;PMOD 11 ;COLORPTN USERCOLOR ; may use this to reset the selected display characteristics. Need to extract them first ;COPYCOLOR COLOR4 ;COLORDEF n,r,g,b _g0gcd_IniFile("[O]MT8801Title", $_AInitSystem) _Log($LogTab & "_AInitSystem: System Title=" & $_AInitSystem, $dBugLog) _g0gcd_IniFile("[O]MT8801RFPort", $sMT8801_RFPort) _Log($LogTab & "_AInitSystem: Selected RF Port=", $sMT8801_RFPort) GUICtrlSetData($hAFrequencyMessage, "Standby") _Log($LogTab & "_AInitSystem: Completed.", $dBugLog) ;Return $_AInitSystem EndFunc ;==>_AInitSystem ;#ce ;------------------------------------------------------------------------------------------------------------------------------ ;#cs ; #FUNCTION# ================================================================================================================== ; Name...........: _A_Say ; Description ...: Sends the given command string via an open Serial Communication channel ; Syntax.........: _A_Say($sCommand, $iDelay, $hMT8801COMPort) ; Parameters ....: $sCommand = Command string (without terminator) ; $iDelay = milliseconds to wait after sending command (sticky - missing value uses last used) ; $hMT8801COMPort = Handle to opne serial channel (sticky - missing value uses last used) ; Return values .: None ; Author ........: John Powers (g0gcd) ; Modified.......: 19/06/23 ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: _A_Say("SetTX") ; ============================================================================================================================= Func _A_Say($sCommand, $iDelay = -1, $hMT8801COMPort = "") ;Notes ;_Log($LogTab & "_A_Say: Started.", $dBugLog) ;Global variables used ;$dBugLog, ;Declare local variables Local $_A_Say Local $aCommand ;Populate local configurable variables ;Initialise local variables Static $Last_iDelay = 2000 Static $Last_hICOMPort = "" ;Local configuration ;Procedure ................................................................................................................ If $iDelay <> -1 Then $Last_iDelay = $iDelay If $hMT8801COMPort <> "" Then $Last_hICOMPort = $hMT8801COMPort _Log("_A_Say: Command='" & $sCommand & "'") $sCommand = StringStripWS($sCommand,3); Take out any leading or trailing WS $sCommand = StringReplace($sCommand, @CRLF, "") & @LF; Strip CR from line ending $aCommand = StringSplit($sCommand," ") ;Send Command _CommAPI_TransmitString($Last_hICOMPort, $sCommand) If @error Then Return "Error" & @error ; need better error processing than this... ;Expect a reply? If StringRight($sCommand,1) = "?" Then; this is a query; an answer is expected Sleep($Last_iDelay) $_A_Say = _CommAPI_ReceiveString($hMT8801COMPort, $Timeout, $Length, $EOL) If @error Then Return "Error" & @error ; need better error processing than this... _Log("_A_Say: Reply='" & $_A_Say & "'") ;Display request on dashboard ; Not used because averages are being reported in the test functions ; $aCommand = StringSplit($sCommand," ") ; If $aCommand[0] > 0 Then ; Switch StringUpper($aCommand[1]) ; Case "SINAD?" ; GUICtrlSetData($hAOLVLMessage, $aCommand[2] & " dB") ; Case "RXFREQ" ; GUICtrlSetData($hAFrequencyMessage, $aCommand[2] & " Hz") ; EndSwitch ; Endif Sleep($Last_iDelay) Else ;This is a command; no answer expected ;Display request on dashboard ; $aCommand = StringSplit($sCommand," ") If $aCommand[0] > 0 Then ; REVIEW whether this is the correct place to add units for diaplay Switch StringUpper($aCommand[1]) Case "OLVL" GUICtrlSetData($hAOLVLMessage, $aCommand[2] & " dBm") Case "RXFREQ" GUICtrlSetData($hAFrequencyMessage, $aCommand[2] & " Hz") EndSwitch Endif $_A_Say = "OK" Sleep($Last_iDelay) EndIf ;_Log($LogTab & "_A_Say: Completed.", $dBugLog) Return $_A_Say EndFunc ;==>_A_Say ;#ce ;------------------------------------------------------------------------------------------------------------------------------ ;#cs ; =============================================================================================================================== ; Function Name: _COM_ListPorts() ; Description: Creates a list of the existing COM ports ; Parameters: (none) ; Returns: on success returns an array of strings ; on error (no com ports existing) returns -1 ; Note: The array contains e.g. "COM1", "COM2", up to "COM256" ; See also _ComGetPortNames($sComPort = "") returns an array of ports and names ; =============================================================================================================================== Func _COM_ListPorts() Local $regKey = 'HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\SERIALCOMM' Local $regVal = '' Local $regDat = '' Local $comPortList[0] For $i = 1 To 256 $regVal = RegEnumVal($regKey, $i) If @error Then ExitLoop $regDat = RegRead($regKey, $regVal) If @error Then ExitLoop ReDim $comPortList[$i] $comPortList[$i - 1] = $regDat Next If UBound($comPortList) = 0 Then Return SetError(0, 1, -1) ;_Log($LogTab & "_Inst_Ask: Completed.", $dBugLog) Return SetError(0, 2, $comPortList) EndFunc ;==>_COM_ListPorts ;#ce ;#cs ;Replace with ; #FUNCTION# ==================================================================================================================== ; Name ..........: _CommAPI_GetPorts ; Description ...: Get available ports ; Syntax ........: _CommAPI_GetPorts([$vFormat = 0[, $bFilter = True[, $bOnlyCOM = True]]]) ; Parameters ....: $vFormat - [in] Output format (see Modifications). Default: 0 ; $bFilter - [in] Filter out ports without port number (see Modifications). Default: true ; $bOnlyCOM - [in] Only get serial ports. Default: true ; Return values .: Success - A string or array with detected ports (empty string or empty array if no port detected) ; Failure - False ; @error - Line number where SetError called ; Author ........: ¿? ; Modified ......: 20230128 by Javier Perez (see modifications) ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== ;Modifications: ;- Added starting WMI Service when ObjGet returns error ;- Added output format parameter ($vFormat): ; = 0 (Integer, default) : returns an array (0-based) of integers with each value a port number. Ex: [3, 15] ; = 1 (Integer) : returns an array (0-based) of strings with each value with a port name. Ex: ['COM3', 'COM15'] ; = 2 (Integer) : returns a bidimensional array (0-based). The second dimension has the following elements: ; [0] : String. Port Name. ; [1] : Integer. Port number (for COM3: 3, for LPT1: 1, etc) ; [2] : String. Port type (COM or LPT). ; [3] : String. Hardware ID. ; [4] : String. Manufacturer. ; [5] : String. Description. ; = S (String) : returns a string with port names separated by S (it may be ',', @CRLF, etc). Ex: "COM3,COM15" ;- Added recognizing ports with no COM number assigned. This method also allow to detect LPT ports. * ;- Added $bFilter option to filter out ports without assigned number ;- Added $bOnlyCOM to filter out non COM ports (because of *) ;* : ; - when a port exist but doesn't has an assigned number, the function assign port number 0 and port name XXX0. ; - the detection of unassigned ports allow to detect anormal situations like when Prolific drivers ; detects a cloned USB/Serial interface. In this case, the driver doesn't assign a port number and ; port name has the string "THIS IS NOT PROLIFIC..." ;------------------------------------------------------------------------------------------------------------------------------ ;Notes ;_Log($LogTab & "_UploadOtherFile: Started.", $dBugLog) ;Global variables used ;$dBugLog, ;Declare local variables ;Populate local configurable variables ;Initialise local variables ;Local configuration ;Procedure ................................................................................................................ ;#ce ;------------------------------------------------------------------------------------------------------------------------------ ;#cs ; #FUNCTION# ================================================================================================================== ; Name...........: ConfirmPAdb ; Description ...: ; Syntax.........: ConfirmPAdb() ; Parameters ....: ; ; ; Return values .: ; Author ........: John Powers (g0gcd) ; Modified.......: 10/07/23 ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: ; ============================================================================================================================= Func ConfirmPAdb() ;Notes ;_Log($LogTab & "ConfirmPAdb: Started.", $dBugLog) ;Global variables used ;$dBugLog, ;Declare local variables ;Local $ConfirmPAdb Local $sSetting ;Populate local configurable variables ;Initialise local variables ;Local configuration ;Procedure ................................................................................................................ $sSetting = GUICtrlRead($hAPAdBSelectMessage) $PAdBValue = Number(StringRegExpReplace($sSetting, "\D", "")); extract only digits $sSetting = "Do not remove the " & $sSetting & " protection attenuator whilst the radio is connected to the Analyser." _g0gcd_IniFile("[O]ProtectionAttenuatorLastUsedValue", $PAdBValue & "dB", "Config") GUICtrlSetState($hAPAdBSelectMessage, $GUI_DISABLE + $GUI_SHOW) GUICtrlSetData($aPanel[$cAPAdB][$cMessage], $sSetting) GUICtrlSetData($aPanel[$cAPAdB][$cConfirm], $cOK) GUICtrlSetBkColor($aPanel[$cAPAdB][$cConfirm], $COLOR_GREEN) $aPanel[$cAPAdB][$cButton] = 0 ; = Confirmed GUICtrlSetState($hRun, $GUI_ENABLE + $GUI_SHOW) ;_Log($LogTab & "ConfirmPAdb: Completed.", $dBugLog) ;Return $ConfirmPAdb EndFunc ;==>ConfirmPAdb ;#ce ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #EndRegion Analyser Functions ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ;============================================================================================================================== #Region Radio Functions Func ___Radio_Functions___(); Marker for SCITE Jump use EndFunc ;============================================================================================================================== ;------------------------------------------------------------------------------------------------------------------------------ ;#cs ;#cs ; #FUNCTION# ================================================================================================================== ; Name...........: ConfirmFreq ; Description ...: ; Syntax.........: ConfirmFreq() ; Parameters ....: ; ; ; Return values .: ; Author ........: John Powers (g0gcd) ; Modified.......: 10/07/23 ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: ; ============================================================================================================================= Func ConfirmFreq() ;Notes ;_Log($LogTab & "ConfirmFreq: Started.", $dBugLog) ;Global variables used ;$dBugLog, ;Declare local variables ;Local $ConfirmFreq ;Populate local configurable variables ;Initialise local variables ;Local configuration ;Procedure ................................................................................................................ GUICtrlSetState($aPanel[$cRFreq][$cConfirm],$GUI_SHOW) GUICtrlSetData($aPanel[$cRFreq][$cTitle], "Frequency") GUICtrlSetData($aPanel[$cRFreq][$cConfirm], $cOK) GUICtrlSetBkColor($aPanel[$cRFreq][$cConfirm], $COLOR_GREEN) $aPanel[$cRFreq][$cButton] = 0 ;_Log($LogTab & "ConfirmFreq: Completed.", $dBugLog) ;Return $ConfirmFreq EndFunc ;==>ConfirmFreq ;#ce ;------------------------------------------------------------------------------------------------------------------------------ ;#cs ; #FUNCTION# ================================================================================================================== ; Name...........: ConfirmMode ; Description ...: ; Syntax.........: ConfirmMode() ; Parameters ....: ; ; ; Return values .: ; Author ........: John Powers (g0gcd) ; Modified.......: 10/07/23 ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: ; ============================================================================================================================= Func ConfirmMode() ;Notes ;_Log($LogTab & "ConfirmMode: Started.", $dBugLog) ;Global variables used ;$dBugLog, ;Declare local variables ;Local $ConfirmMode ;Populate local configurable variables ;Initialise local variables ;Local configuration ;Procedure ................................................................................................................ GUICtrlSetState($aPanel[$cRMode][$cConfirm],$GUI_SHOW) GUICtrlSetData($aPanel[$cRMode][$cTitle], "Mode") GUICtrlSetData($aPanel[$cRMode][$cConfirm], $cOK) GUICtrlSetBkColor($aPanel[$cRMode][$cConfirm], $COLOR_GREEN) $aPanel[$cRMode][$cButton] = 0 ;_Log($LogTab & "ConfirmMode: Completed.", $dBugLog) ;Return $ConfirmMode EndFunc ;==>ConfirmMode ;#ce ;------------------------------------------------------------------------------------------------------------------------------ ;#cs ; #FUNCTION# ================================================================================================================== ; Name...........: _R_Ask ; Description ...: Sends the given command string via an open Serial Communication channel ; Syntax.........: _R_Ask($sCommand, $iDelay, $hMT8801COMPort) ; Parameters ....: $sCommand = Command string (without terminator) ; $iDelay = milliseconds to wait after sending command (sticky - missing value uses last used) ; $hMT8801COMPort = Handle to opne serial channel (sticky - missing value uses last used) ; Return values .: None ; Author ........: John Powers (g0gcd) ; Modified.......: 19/06/23 ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: _R_Ask("SetTX") ; ============================================================================================================================= Func _R_Ask();$sCommand, $iDelay = -1, $hMT8801COMPort = "") ;Notes ;_Log($LogTab & "_R_Ask: Started.", $dBugLog) ;Global variables used ;$dBugLog, ;Declare local variables ;Local $_R_Ask ;Populate local configurable variables ;Initialise local variables ;Static $Last_iDelay = 2000 ;Static $Last_hICOMPort = "" ;Local configuration ;Procedure ................................................................................................................ #cs If $iDelay <> -1 Then $Last_iDelay = $iDelay If $hMT8801COMPort <> "" Then $Last_hICOMPort = $hMT8801COMPort _Log($LogTab & "_Inst_Ask: Command='" & $sCommand & "'", $dBugLog) $sCommand = StringReplace($sCommand, @CRLF, "") & @LF _CommAPI_TransmitString($Last_hICOMPort, $sCommand) If @error Then Return "Error" & @error Sleep($Last_iDelay) ;Return "OK" #ce ;_Log($LogTab & "_R_Ask: Completed.", $dBugLog) ;Return $_R_Ask EndFunc ;==>_R_Ask ;#ce ;------------------------------------------------------------------------------------------------------------------------------ ;#cs ; #FUNCTION# ================================================================================================================== ; Name...........: _R_Say ; Description ...: Sends the given command string via an open Serial Communication channel ; Syntax.........: _R_Say($sCommand, $iDelay, $hMT8801COMPort) ; Parameters ....: $sCommand = Command string (without terminator) ; $iDelay = milliseconds to wait after sending command (sticky - missing value uses last used) ; $hMT8801COMPort = Handle to opne serial channel (sticky - missing value uses last used) ; Return values .: None ; Author ........: John Powers (g0gcd) ; Modified.......: 19/06/23 ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: _R_Say("SetTX") ; ============================================================================================================================= Func _R_Say($Title, $sCommand);, $iDelay = -1, $hDeviceCOMPort = "") ;Notes _Log($LogTab & "_R_Say: Started.", $dBugLog) ;Global variables used ;$dBugLog, ;Declare local variables Local $_R_Say Local $sResult #forceref $_R_Say, $sResult ;Populate local configurable variables ;Initialise local variables ;Static $Last_iDelay = 2000 ;Static $Last_hICOMPort = "" ;Local configuration ;Procedure ................................................................................................................ ; If $iDelay <> -1 Then $Last_iDelay = $iDelay ; If $hMT8801COMPort <> "" Then $Last_hICOMPort = $hMT8801COMPort _Log($LogTab & "_R_Say: Command='" & $sCommand & "'", $dBugLog) ; $sCommand = StringReplace($sCommand, @CRLF, "") & @LF ; _CommAPI_TransmitString($Last_hICOMPort, $sCommand) ; If @error Then Return "Error" & @error $_R_Say = MsgBox(1, $Title, $sCommand) ; Sleep($Last_iDelay) ;_Log($LogTab & "_R_Say: Completed.", $dBugLog) Return $_R_Say EndFunc ;==>_R_Say ;#ce ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #EndRegion Radio Functions ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ;============================================================================================================================== #Region Test Sequences Func ___Test_Sequences___(); Marker for SCITE Jump use EndFunc ;============================================================================================================================== ; #INDEX# ======================================================================================================================= ; Name ..........: _Anritsu_Helper_Test_Sequences.au3 ; Title .........: Test Sequences ; Description ...: Scripts for the analyser to perform ; Version Date ..: 2023-07-05 ; AutoIt Version : 3.3.14.5 ; Link ..........: ; Tag(s) ........: ; Author(s) .....: G0GCD ; Dll(s) ........: ; Error handling : tba ; =============================================================================================================================== ;#include-once ;#include "_Anritsu_Helper_Constants.au3" ;#include "_Anritsu_Helper_Analyser_Functions.au3" ;#include "_Anritsu_Helper_Program_Functions.au3" ;;#include "_Anritsu_Helper_Test_Sequences.au3" ; This file! ;#NoAutoIT3Execute ;#AutoIt3Wrapper_Au3Check_Parameters=-q -d -w 1 -w 2 -w 3 -w- 4 -w 5 -w 6 -w- 7 ; RX_Test_SN($iTargetSINAD = 12, $iInitialdBm = -130, $sMode = "C") ; RX_Test_BW($sDirection, $iFCentre, $iInitialdBm, $iTargetSINAD) ; RX_Test_dVFO(); TBA ; RX_Test_BW(); TBA ; RX_Test_6dBhi(); TBA ; RX_Test_S1; TBA - uses SINAD to simulate S meter reading ; RX_Test_S5; TBA - uses SINAD to simulate S meter reading ; RX_Test_S9; TBA - uses SINAD to simulate S meter reading ;------------------------------------------------------------------------------------------------------------------------------ ;#cs ; #FUNCTION# ================================================================================================================== ; Name...........: RX_Test_S1 ; Description ...: ; Syntax.........: RX_Test_S1() ; Parameters ....: ; ; ; ; Return values .: ; Author ........: John Powers (g0gcd) ; Modified.......: 10/07/23 ; Remarks .......: ; ; Related .......: ; Link ..........: ; Example .......: ; ============================================================================================================================= Func RX_Test_S1() ;Notes ;_Log($LogTab & "RX_Test_S1: Started.", $dBugLog) ;Global variables used ;$dBugLog, ;Declare local variables ;Local $RX_Test_S1 ;Populate local configurable variables ;Initialise local variables ;Procedure ................................................................................................................ ;_Log($LogTab & "RX_Test_S1: Completed.", $dBugLog) ;Return $RX_Test_S1 EndFunc ;==>RX_Test_S1 ;#ce ;------------------------------------------------------------------------------------------------------------------------------ ;#cs ; #FUNCTION# ================================================================================================================== ; Name...........: RX_Test_S5 ; Description ...: ; Syntax.........: RX_Test_S5() ; Parameters ....: ; ; ; ; Return values .: ; Author ........: John Powers (g0gcd) ; Modified.......: 10/07/23 ; Remarks .......: ; ; Related .......: ; Link ..........: ; Example .......: ; ============================================================================================================================= Func RX_Test_S5() ;Notes ;_Log($LogTab & "RX_Test_S5: Started.", $dBugLog) ;Global variables used ;$dBugLog, ;Declare local variables ;Local $RX_Test_S5 ;Populate local configurable variables ;Initialise local variables ;Procedure ................................................................................................................ ;_Log($LogTab & "RX_Test_S5: Completed.", $dBugLog) ;Return $RX_Test_S5 EndFunc ;==>RX_Test_S5 ;#ce ;------------------------------------------------------------------------------------------------------------------------------ ;#cs ; #FUNCTION# ================================================================================================================== ; Name...........: RX_Test_S9 ; Description ...: ; Syntax.........: RX_Test_S9() ; Parameters ....: ; ; ; ; Return values .: ; Author ........: John Powers (g0gcd) ; Modified.......: 10/07/23 ; Remarks .......: ; ; Related .......: ; Link ..........: ; Example .......: ; ============================================================================================================================= Func RX_Test_S9() ;Notes ;_Log($LogTab & "RX_Test_S9: Started.", $dBugLog) ;Global variables used ;$dBugLog, ;Declare local variables ;Local $RX_Test_S9 ;Populate local configurable variables ;Initialise local variables ;Procedure ................................................................................................................ ;_Log($LogTab & "RX_Test_S9: Completed.", $dBugLog) ;Return $RX_Test_S9 EndFunc ;==>RX_Test_S9 ;#ce ;------------------------------------------------------------------------------------------------------------------------------ ;#cs ; #FUNCTION# ================================================================================================================== ; Name...........: RX_Test_6dBhi ; Description ...: ; Syntax.........: RX_Test_6dBhi() ; Parameters ....: ; ; ; ; Return values .: ; Author ........: John Powers (g0gcd) ; Modified.......: 10/07/23 ; Remarks .......: ; ; Related .......: ; Link ..........: ; Example .......: ; ============================================================================================================================= Func RX_Test_6dBhi() ;Notes ;_Log($LogTab & "RX_Test_6dBhi: Started.", $dBugLog) ;Global variables used ;$dBugLog, ;Declare local variables ;Local $RX_Test_6dBhi ;Populate local configurable variables ;Initialise local variables ;Procedure ................................................................................................................ ;_Log($LogTab & "RX_Test_6dBhi: Completed.", $dBugLog) ;Return $RX_Test_6dBhi EndFunc ;==>RX_Test_6dBhi ;#ce ;------------------------------------------------------------------------------------------------------------------------------ ;#cs ; #FUNCTION# ================================================================================================================== ; Name...........: RX_Test_BWx ; Description ...: ; Syntax.........: RX_Test_BWx() ; Parameters ....: ; ; ; ; Return values .: ; Author ........: John Powers (g0gcd) ; Modified.......: 10/07/23 ; Remarks .......: ; ; Related .......: ; Link ..........: ; Example .......: ; ============================================================================================================================= Func RX_Test_BWx() ;Notes ;_Log($LogTab & "RX_Test_BWx: Started.", $dBugLog) ;Global variables used ;$dBugLog, ;Declare local variables ;Local $RX_Test_BWx ;Populate local configurable variables ;Initialise local variables ;Procedure ................................................................................................................ ;_Log($LogTab & "RX_Test_BWx: Completed.", $dBugLog) ;Return $RX_Test_BWx EndFunc ;==>RX_Test_BWx ;#ce ;------------------------------------------------------------------------------------------------------------------------------ ;#cs ; #FUNCTION# ================================================================================================================== ; Name...........: RX_Test_dVFO ; Description ...: ; Syntax.........: RX_Test_dVFO() ; Parameters ....: ; ; ; ; Return values .: ; Author ........: John Powers (g0gcd) ; Modified.......: 10/07/23 ; Remarks .......: ; ; Related .......: ; Link ..........: ; Example .......: ; ============================================================================================================================= Func RX_Test_dVFO() ;Notes ;_Log($LogTab & "RX_Test_dVFO: Started.", $dBugLog) ;Global variables used ;$dBugLog, ;Declare local variables ;Local $RX_Test_dVFO ;Populate local configurable variables ;Initialise local variables ;Procedure ................................................................................................................ ;_Log($LogTab & "RX_Test_dVFO: Completed.", $dBugLog) ;Return $RX_Test_dVFO EndFunc ;==>RX_Test_dVFO ;#ce ;------------------------------------------------------------------------------------------------------------------------------ ;#cs ; #FUNCTION# ================================================================================================================== ; Name...........: RX_Test_SN ; Description ...: Drives the RF Level upwards from that supplied to achieve a specified SINAD level ; Syntax.........: RX_Test_SN($iTargetSINAD, $iInitialdBm) ; Parameters ....: $iTargetSINAD, SINAD level to reach ; $iInitialdBm, Starting RF level for test ; Return values .: Level (dBm) at which $iTargetSINAD is reached. ; Author ........: John Powers (g0gcd) ; Modified.......: 20/06/23 ; Remarks .......: ; Related .......: ; Link ..........:https://www.metoffice.gov.uk/hadobs/hadcet/data/download.html ; Example .......: ; ============================================================================================================================= Func RX_Test_SN($iTargetSINAD = 12, $iInitialdBm = -130, $sMode = "C") ;Notes ;Ensure SINAD is measured in dB ;Set appropriate Mod ;Trap for overrange _Log($LogTab & "RX_Test_SN: Started.", $dBugLog) ;Global variables used ;$dBugLog, ;Declare local variables Local $RX_Test_SN Static $sLastMode = "None" #forceref $RX_Test_SN, $sLastMode, $sMode ;Populate local configurable variables ;Initialise local variables Local $OutputLevel = $iInitialdBm; -130 Local $SINAD = 0 Local $Avg_SINAD = 0 Local $Step Local $Avg_Cycles = [ 1, 3, 6] ;Number of samples used for averaging SINAD measurements Local $Overshoot = [1.10, 0.97, 1.00] ;Over and undershoot required to move through Coarse, Medium and Fine searches ;Procedure ................................................................................................................ If $dBug_NoAnalyser Then Return $iInitialdBm + 9; dummy value to simulate test _A_Say("MEAS RX", 50) ; _A_Say("VAVG ON") ;Test averaging mode ; _A_Say("AVG 10") ;Set Deviation If $sMode <> $sLastMode Then $sLastMode = $sMode Switch $sMode Case "A" _A_Say("AFREQ1 1000") _A_Say("ADEV1 0") _A_Say("AOUT1 OFF") _A_Say("AFREQ2 1000") _A_Say("ADEV2 0") _A_Say("AOUT2 OFF") _A_Say("AOUTX OFF") Case "C" _A_Say("AFREQ1 1000") _A_Say("ADEV1 0") _A_Say("AOUT1 OFF") _A_Say("AFREQ2 1000") _A_Say("ADEV2 0") _A_Say("AOUT2 OFF") _A_Say("AOUTX OFF") Case "F" _A_Say("AFREQ1 1000") _A_Say("ADEV1 3125") _A_Say("AOUT1 ON") _A_Say("AFREQ2 1000") _A_Say("ADEV2 0") _A_Say("AOUT2 OFF") _A_Say("AOUTX OFF") Case "L" _A_Say("AFREQ1 1000") _A_Say("ADEV1 0") _A_Say("AOUT1 OFF") _A_Say("AFREQ2 1000") _A_Say("ADEV2 0") _A_Say("AOUT2 OFF") _A_Say("AOUTX OFF") Case "N" _A_Say("AFREQ1 1000") _A_Say("ADEV1 1563") _A_Say("AOUT1 ON") _A_Say("AFREQ2 1000") _A_Say("ADEV2 0") _A_Say("AOUT2 OFF") _A_Say("AOUTX OFF") Case "U" _A_Say("AFREQ1 1000") _A_Say("ADEV1 0") _A_Say("AOUT1 OFF") _A_Say("AFREQ2 1000") _A_Say("ADEV2 0") _A_Say("AOUT2 OFF") _A_Say("AOUTX OFF") Case "W" _A_Say("AFREQ1 1000") _A_Say("ADEV1 25000") _A_Say("AOUT1 ON") _A_Say("AFREQ2 1000") _A_Say("ADEV2 0") _A_Say("AOUT2 OFF") _A_Say("AOUTX OFF") EndSwitch Endif _A_Say("RRLVL ON", 50) $Step = 5 While $SINAD < ($iTargetSINAD * $Overshoot[0]) _A_Say("OLVL " & $OutputLevel,50) $Avg_SINAD = 0 For $pAverage = 1 to $Avg_Cycles[0] _A_Say("SWP",50) _A_Say("SINAD?",50) $sResult = _CommAPI_ReceiveString($hMT8801COMPort, $Timeout, $Length, $EOL) If $pAverage = 1 then $Avg_SINAD = $sResult $Avg_SINAD = (($Avg_SINAD * ($Avg_Cycles[0]-1)) + $sResult) / $Avg_Cycles[0] _Log("SINAD " & $pAverage & "=" & $Avg_SINAD, $dBugLog) Next $SINAD = $Avg_SINAD GUICtrlSetData($hASINADMessage, Round($Avg_SINAD,1) & " dB") _Log("SINAD=" & $SINAD & "dB, at " & $OutputLevel & "dBm", $dBugLog) $OutputLevel = Int(($OutputLevel + $Step)*10)/10 WEND ;$OutputLevel = Int(($OutputLevel - $Step)*10)/10 ;?? $Step = -1 While $SINAD > ($iTargetSINAD * $Overshoot[1]) _A_Say("OLVL " & $OutputLevel,50) $Avg_SINAD = 0 For $pAverage = 1 to $Avg_Cycles[1] _A_Say("SWP",50) _A_Say("SINAD?",50) $sResult = _CommAPI_ReceiveString($hMT8801COMPort, $Timeout, $Length, $EOL) If $pAverage = 1 then $Avg_SINAD = $sResult $Avg_SINAD = (($Avg_SINAD * ($Avg_Cycles[1]-1)) + $sResult) / $Avg_Cycles[1] ;_Log("SINAD " & $pAverage & "=" & $Avg_SINAD, $dBugLog) Next $SINAD = $Avg_SINAD GUICtrlSetData($hASINADMessage, Round($Avg_SINAD,1) & " dB") ;_Log("SINAD=" & $SINAD & "dB, at " & $OutputLevel & "dBm", $dBugLog) $OutputLevel = Int(($OutputLevel + $Step)*10)/10 WEND ;$OutputLevel = Int(($OutputLevel - $Step)*10)/10 ;?? $Step = 0.1 While $SINAD < ($iTargetSINAD * $Overshoot[2]) _A_Say("OLVL " & $OutputLevel,50) $Avg_SINAD = 0 For $pAverage = 1 to $Avg_Cycles[2] _A_Say("SWP",50) _A_Say("SINAD?",70) $sResult = _CommAPI_ReceiveString($hMT8801COMPort, $Timeout, $Length, $EOL) If $pAverage = 1 then $Avg_SINAD = $sResult ; GUICtrlSetData($hASINADMessage, $Avg_SINAD & " dB") ;_Log("SINAD " & $pAverage & "=" & $Avg_SINAD, $dBugLog) Next $SINAD = $Avg_SINAD GUICtrlSetData($hASINADMessage, Round($Avg_SINAD,1) & " dB") ;_Log("SINAD=" & $SINAD & "dB, at " & $OutputLevel & "dBm", $dBugLog) $OutputLevel = Int(($OutputLevel + $Step)*10)/10 WEND ;$OutputLevel = Int(($OutputLevel - $Step)*10)/10 ;?? $RX_Test_SN = Round($OutputLevel, 1) _A_Say("OLVL -133") _A_Say("MEAS RX", 200) _A_Say("RRLVL OFF") _A_Say("VAVG OFF") ;Test averaging mode _Log($LogTab & "RX_Test_SN: Completed.", $dBugLog) Return $RX_Test_SN EndFunc ;==>RX_Test_SN() ;#ce ;------------------------------------------------------------------------------------------------------------------------------ ;#cs ; #FUNCTION# ================================================================================================================== ; Name...........: RX_Test_BW ; Description ...: Drives the RF Frequency upwards/downwards from that supplied to achieve a specified SINAD level ; Syntax.........: RX_Test_BW($sDirection, $iFCentre, $iInitialdBm, $iTarget) ; Parameters ....: $sDirection ; $iFCentre ; $iInitialdBm ; $iTarget ; Return values .: Frequency ; Author ........: John Powers (g0gcd) ; Modified.......: 20/06/23 ; Remarks .......: Used for determining filter/bandwidth edges ; Related .......: ; Link ..........: ; Example .......: ;$F6lo = RX_Test_BW("lo", $BandCentreFrequency * 1E6, $SINAD20, 14) ; ============================================================================================================================= Func RX_Test_BW($sDirection, $iFCentre, $iInitialdBm, $iTargetSINAD) #forceref $sDirection, $iFCentre, $iInitialdBm, $iTargetSINAD ;Notes ;Relies on starting at a known RFLevel/SINAD, e.g. -115dBm 20dB SINAD at centre frequency ;Steps frequency hi/lo until the target SINAD is reached, usually 14dB (i.e. -6dB) ;Suggest keeping the lower level above 12dB SINAD to minimise the effects of weak signal _Log($LogTab & "RX_Test_BW: Started.", $dBugLog) ;Global variables used ;$dBugLog, ;Declare local variables Local $RX_Test_BW Local $Avg_SINAD Local $Step ;Populate local configurable variables ;Initialise local variables Local $OutputLevel = $iInitialdBm; -130 Local $Frx = $iFCentre Local $SINAD = $iTargetSINAD + 10 ;Local $Avg_Cycles = [3,4,5] Local $Avg_Cycles = [ 1, 3, 6] ;Number of samples used for averaging SINAD measurements Local $Overshoot = [1.10, 0.97, 1.00] ;Over and undershoot required to move through Coarse, Medium and Fine searches Local $pPtr = 1 ;Procedure ................................................................................................................ If StringLower($sDirection) = "lo" then $pPtr = -1 If $dBug_NoAnalyser Then Return $iFCentre + ($pPtr * 2500); dummy value to simulate test _A_Say("MEAS RX") _A_Say("RRLVL ON") _A_Say("OLVL " & $OutputLevel,50) $Step = 1000 While $SINAD > ($iTargetSINAD * $Overshoot[0]) _A_Say("RXFREQ " & $Frx) $Avg_SINAD = 0 For $pAverage = 1 to $Avg_Cycles[0] _A_Say("SWP",50) _A_Say("SINAD?",50) $sResult = _CommAPI_ReceiveString($hMT8801COMPort, $Timeout, $Length, $EOL) If $pAverage = 1 then $Avg_SINAD = $sResult $Avg_SINAD = (($Avg_SINAD * ($Avg_Cycles[0]-1)) + $sResult) / $Avg_Cycles[0] ;_Log("SINAD " & $pAverage & "=" & $Avg_SINAD, $dBugLog) Next $SINAD = $Avg_SINAD GUICtrlSetData($hASINADMessage, Round($Avg_SINAD,1) & " dB") ;_Log("SINAD=" & $SINAD & "dB, at " & ($Frx/1E6) & "MHz", $dBugLog) $Frx = $Frx + ($pPtr * $Step) WEND ;$Frx = $Frx + ($pPtr * $Step * -1) $Step = -100 While $SINAD < ($iTargetSINAD * $Overshoot[1]) _A_Say("RXFREQ " & $Frx) $Avg_SINAD = 0 For $pAverage = 1 to $Avg_Cycles[1] _A_Say("SWP",50) _A_Say("SINAD?",50) $sResult = _CommAPI_ReceiveString($hMT8801COMPort, $Timeout, $Length, $EOL) If $pAverage = 1 then $Avg_SINAD = $sResult $Avg_SINAD = (($Avg_SINAD * ($Avg_Cycles[1]-1)) + $sResult) / $Avg_Cycles[1] ;_Log("SINAD " & $pAverage & "=" & $Avg_SINAD, $dBugLog) Next $SINAD = $Avg_SINAD GUICtrlSetData($hASINADMessage, Round($Avg_SINAD,1) & " dB") ;_Log("SINAD=" & $SINAD & "dB, at " & ($Frx/1E6) & "MHz", $dBugLog) $Frx = $Frx + ($pPtr * $Step) WEND ;$Frx = $Frx + ($pPtr * $Step * -1) $Step = 10 While $SINAD > ($iTargetSINAD * $Overshoot[2]) _A_Say("RXFREQ " & $Frx) $Avg_SINAD = 0 For $pAverage = 1 to $Avg_Cycles[2] _A_Say("SWP",50) _A_Say("SINAD?",70) $sResult = _CommAPI_ReceiveString($hMT8801COMPort, $Timeout, $Length, $EOL) If $pAverage = 1 then $Avg_SINAD = $sResult $Avg_SINAD = (($Avg_SINAD * ($Avg_Cycles[2]-1)) + $sResult) / $Avg_Cycles[2] ;_Log("SINAD " & $pAverage & "=" & $Avg_SINAD, $dBugLog) Next $SINAD = $Avg_SINAD GUICtrlSetData($hASINADMessage, Round($Avg_SINAD,1) & " dB") ;_Log("SINAD=" & $SINAD & "dB, at " & ($Frx/1E6) & "MHz", $dBugLog) $Frx = $Frx + ($pPtr * $Step) WEND ;$Frx = $Frx + ($pPtr * $Step * -1) $RX_Test_BW = Round($Frx, -1) _A_Say("OLVL -133") _A_Say("MEAS RX", 200) _A_Say("RRLVL OFF") _Log($LogTab & "RX_Test_BW: Completed.", $dBugLog) Return $RX_Test_BW EndFunc ;==>RX_Test_BW ;#ce ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #EndRegion Test Sequences ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~