#include #include Global $supportbugfix = 1 Global $szDrive, $szDir, $szFName, $szExt ; dummi variables for function _PathSplit Global $toolname = "ODX for VAG" Global $workfolder = _PathFull(@ScriptDir & "\..\.."); go 2 levels up: ODX4VAG\\ Global $inifolder = @ScriptDir Global $logfile Global $logname = "\odx4vag.log" ; @ScriptName includes extension ".exe" ... Global $batchmode = False Global $ShowWindows = False ; GUI variables Global $gui_line_height = 20 Global $gui_line_space = 10 Global $gui_text_height = 14 Global $gui_col_width = 120 Global $gui_col_space = 10 Global $gui_max_line_no ; to be set by ini file evaluation of /supportbugfix Global $gui_max_col_no = 6 ; common array size for number of files Global $arrsiz = 50 Global $checksilent = False ; used for CheckFile() - silent mode needed in GUI ; ; bird call ; Global $birdjavaheap = "-Xmx512m" Global $birdjavaversionpaths = "" Global $birdjavaexe = "" Global $birdrootfolder = "" ;Global $birddotversion = False Global $birdtoolfolder = "" Global $batchargs = 9 Global $birdjar = "bin\bird.jar" Global $birdargs Global $odxdirectarguments[2*$arrsiz] $odxdirectarguments[0] = 0 ; ; bird libraries for ODX ; Global $odxjarfolder = "" Global $odxjars Global $odxjar_cnt = 0 Global $conffolder = "" ; ; bird libraries for index generation ; Global $indexlib = "" Global $DeliverCheck = True ; ; customer folder ; Global $custfolder = $workfolder & "\CustomerSupplied" Global $infolder = "" Global $outfolder = @TempDir ; preliminary setting until outfolder is specified by user Global $outfolder_new = "" Global $a2lpaths = "." Global $ccepaths = "." Global $cbpaths = "." Global $dcmpaths = "." Global $pdxsymbolics = "" Global $masterslavesysconst = "" Global $customerfiles = "" Global $customersymbolics = "" Global $customerargs = "" Global $customerpdx ; ; checker version ; Global $checkrootfolder, $checkversions[$arrsiz], $checkversion_cnt, $RunChecker[$arrsiz] ;, $checkversionIDs[$arrsiz] Global $checkerjavaversionpaths = "" Global $checkerjavaexe = "" Global $template = "" Global $templatefile = "" Global $a2lfile = "" Global $ccefile = "" Global $dcmfile = "" Global $cbfile = "" Global $odx4vagversion = "" Global $birdversion = "" Global $birdpaths = "" Global $libversion = "" Global $checkversion = "" Global $winzippaths = "" Global $winzippath = "" Global $errlogfile = "" ; ; bugfix mode ; Global $bugfixmode = $GUI_UNCHECKED Global $bugfixversion = "" Global $bugfixchange = "bugfix" Global $bugfixreason = "to be specified" ; release type by tool chain parameter: "SERIES" or "DEVELOPMENT" Global $releasetype = "" Global $progressID Global $progresslabelID Global $customerfilelist Global $customersymboliclist Global $customerarglist Global $customerfileselections Global $customerfileforbiddens Global $customerfiledefaults Global $customerfileforbiddendefaults Global $customerpaths Exit Main() Func CheckCustomerFolder() $checkrootfolder = $custfolder & "\VAX-Toolbox" $checkversions = FindFiles($checkrootfolder, "v*", False) $checkversion_cnt = $checkversions[0] ; $checkversionIDs[0] = $checkversion_cnt $RunChecker[0] = $checkversion_cnt For $cnt = 1 To $checkversion_cnt $RunChecker[$cnt] = False Next $customerfilelist = StringSplit($customerfiles, "|") $customersymboliclist = StringSplit($customersymbolics, "|") $customerarglist = StringSplit($customerargs, "|") If Not ($customerfilelist[0] = $customersymboliclist[0]) Or Not ($customerfilelist[0] = $customerarglist[0]) Then AbortMessage("ERROR", "number of /customerfiles, /customersymbolics and /customerargs not equal in initialization file") EndIf Local $custinicnt Local $custinifile Local $custinihandle Local $custiniline Local $custiniparts Local $custiniversions Local $custfile Local $localcustomerfileselections[$customerfilelist[0]+1] Local $localcustomerfileforbiddens[$customerfilelist[0]+1] Local $localcustomerfiledefaults[$customerfilelist[0]+1] Local $localcustomerfileforbiddendefaults[$customerfilelist[0]+1] Local $localcustomerpaths[$customerfilelist[0]+1] $localcustomerfileselections[0] = $customerfilelist[0] $localcustomerfileforbiddens[0] = $customerfilelist[0] $localcustomerfiledefaults[0] = $customerfilelist[0] $localcustomerfileforbiddendefaults[0] = $customerfilelist[0] $localcustomerpaths[0] = $customerfilelist[0] For $custinicnt = 1 To $customerfilelist[0] $custinifile = $custfolder & "\" & $customerfilelist[$custinicnt] & ".ini" $custinihandle = FileOpen($custinifile, 0) $localcustomerfileselections[$custinicnt] = "" $localcustomerfileforbiddens[$custinicnt] = "" If FileExists($custinifile) And $custinihandle > 0 Then While 1 $custiniline = FileReadLine($custinihandle) If @error = -1 Then FileClose($custinihandle) ExitLoop Else $custiniparts = StringSplit($custiniline,":") If Not ($custiniparts[0] = 2) Then AbortMessage("ERROR", "format error in initialization file:" & @LF & $custinifile & @LF & "at line:" & @LF & $custiniline) EndIf $custfile = $custfolder & "\" & $customerfilelist[$custinicnt] & "\" & $custiniparts[1] If Not FileExists($custfile) Then AbortMessage("ERROR", "customer file referred by initialization file" & @LF & $custinifile & @LF & "does not exist:" & @LF & $custfile) EndIf $custiniversions = "|" & $custiniparts[2] & "|" If StringInStr($custiniversions, ("|" & $odx4vagversion & "|"), 1) Then $localcustomerfileselections[$custinicnt] = $custiniparts[1] & "|" & $localcustomerfileselections[$custinicnt] $localcustomerfiledefaults[$custinicnt] = $custiniparts[1] Else $localcustomerfileforbiddens[$custinicnt] = $custiniparts[1] & "|" & $localcustomerfileforbiddens[$custinicnt] $localcustomerfileforbiddendefaults[$custinicnt] = $custiniparts[1] EndIf EndIf Wend Else AbortMessage("ERROR", "initialization file not found or not readable:" & @LF & $custinifile) EndIf Next $customerfileselections = $localcustomerfileselections $customerfileforbiddens = $localcustomerfileforbiddens $customerfiledefaults = $localcustomerfiledefaults $customerfileforbiddendefaults = $localcustomerfileforbiddendefaults $customerpaths = $localcustomerpaths Return EndFunc Func Main() If $CmdLine[0] = 0 Then $batchmode = False $releasetype = "DEVELOPMENT" ; default setting for interactive usage SetPrio() ; do not set prio to below normal for batch mode: leads to very long execution time in tool chain! Preparation() ; ; progress must be specified here to be used in ViewProgrss function ; GUICreate($toolname & " " & $odx4vagversion & ", BIRD " & $birdversion & ", Checker " & $checkversion & ", Library: " & $libversion & ", Template: " & $template, gui_width(), gui_height(),-1,-1,$WS_OVERLAPPEDWINDOW);BitOr($GUI_SS_DEFAULT_GUI,$WS_OVERLAPPEDWINDOW,$WS_MAXIMIZE)) $progressID = GUICtrlCreateProgress (gui_col(3), gui_line($gui_max_line_no), gui_col_width(2), $gui_line_height, $PBS_SMOOTH) GUICtrlSetState($progressID, $GUI_DISABLE) $progresslabelID = GUICtrlCreateLabel ("", gui_col(3), gui_line($gui_max_line_no)-$gui_line_height, gui_col_width(2), $gui_line_height) GUICtrlSetState($progresslabelID, $GUI_DISABLE) RunGui() Return 0 ; End of GUI mode ElseIf $CmdLine[0] = 1 Then Local $arg, $arglist, $argcnt, $cnt, $logfile_new, $rc $arg = $CmdLine[1] If $arg = "?" Then Message("USAGE", "Create ODX delivery container for VW-AUDI projects" & @LF & "Arguments: ? for help or 7 files/directories in ""..."" separated by '|'" & @LF & "1. admin data file for project" & @LF & "2. core configuration export file of project" & @LF & "3. a2l file of project" & @LF & "4. calibrationd data file of project (*.dcm or *.kon)" & @LF & "5. xv variant supplied by VAG" & @LF & "6. pdx container supplied by VAG" & @LF & "7. output directory") Return 0 EndIf $batchmode = True $releasetype = "SERIES" ; default setting for interactive usage Preparation() $arglist = StringSplit($arg, "|") $argcnt = $arglist[0] If $argcnt < $batchargs Then AbortMessage("USAGE", "Improper number of files specified: 9 required") EndIf If Not(($arglist[9] = "SERIES") Or ($arglist[9] = "DEVELOPMENT")) Then AbortMessage("USAGE", "Improper 9th argument value: must be SERIES or DEVELOPMENT") EndIf $cbfile = $arglist[1] $ccefile = $arglist[2] $a2lfile = $arglist[3] $dcmfile = $arglist[4] local $custargfile For $cnt = 1 To $customerarglist[0] $custargfile = RemovePath($arglist[$customerarglist[$cnt]]) CheckCustomerFile($cnt, $custargfile) $customerpaths[$cnt] = $custfolder & "\" & $customerfilelist[$cnt] & "\" & $custargfile Next $outfolder = $arglist[8] $releasetype = $arglist[9] If Not FileExists($outfolder) Then If DirCreate($outfolder) = 0 Then AbortMessage("ERROR", "Abortion: output folder cannot be created") EndIf EndIf $logfile_new = $outfolder & $logname If FileMove($logfile,$logfile_new,1) = 0 Then AbortMessage("ERROR", "Abortion: no write access to output folder") Else $logfile = $logfile_new EndIf For $cnt = ($batchargs + 1) To $argcnt If StringLeft($arglist[$cnt],1) = "-" Then ; direct ODX argument AddArg($arglist[$cnt]) Else Message("WARNING", "Improper additional argument will be ignored:" & @LF & $arglist[$cnt]) EndIf Next $birdargs = BirdArgs($birdversion) $checksilent = false If Not CheckFile($outfolder, "Output folder") Then AbortMessage("ERROR", "Abortion due to missing input files") EndIf If Not CheckInFiles() Then AbortMessage("ERROR", "Abortion due to missing input files") EndIf $DeliverCheck = True $ShowWindows = False $rc = ExecuteGeneration() ErrorExit() Return $rc Else ; End of Batch mode AbortMessage("ERROR", "Improper usage - specify none or 1 argument(s) (? for help)") EndIf EndFunc ;old: Func OnAutoItExit ( ) Func ErrorExit () If Not $logfile = "" Then If Not $errlogfile = "" Then Message("LOG", "log files:" & @LF & $logfile & @LF & $errlogfile) Else Message("LOG", "log file:" & @LF & $logfile) EndIf EndIf EndFunc Func Message ($class, $text) BatchMessage($class, $text) If $batchmode Then Else MsgBox(0, $toolname & " - " & $class, $text) EndIf Return EndFunc Func BatchMessage($class, $text) $newline = "/" ; to get it all in one line ... old: @CRLF & " " If FileWriteLine($logfile, $toolname & " - " & $class & ": " & $newline & StringReplace($text, @LF, $newline)) = 0 Then AbortMessage("ERROR", "no write accees to log file:" & @LF & $logfile) EndIf Return EndFunc Func AbortMessage($level, $text) Message($level, $text) ErrorExit() Exit 1 EndFunc Func ViewProgress($percent, $text="") If $text = "" Then BatchMessage("PROGRESS", $percent& "%") Else BatchMessage("PROGRESS", $percent & "% - " & $text) EndIf If Not $batchmode Then GUICtrlSetData ($progressID, $percent) GUICtrlSetData ($progresslabelID, $text) EndIf Return EndFunc Func CheckInFiles () Local $result = True Local $cnt For $cnt = 1 To $customerpaths[0] If Not CheckFile($customerpaths[$cnt], $customerfilelist[$cnt] & " file") Then $result = False EndIf Next If Not CheckFile($a2lfile, "A2L file") Then $result = False EndIf If Not CheckFile($ccefile, "Core configuration export file") Then $result = False EndIf If Not CheckFile($dcmfile, "DCM (calibration data) file") Then $result = False EndIf If Not CheckFile($cbfile, "Comm Param File") Then $result = False EndIf Return $result EndFunc Func CheckFile($file, $desc, $act = "") $result = FileExists($file) If ($checksilent = False) And ($result = 0) Then $text = $desc & " does not exist:" & @LF & $file If Not ($act = "") Then $text = $text & @LF & $act EndIf Message("ERROR", $text) EndIf Return $result EndFunc Func gui_text_line($gui_line_no) Return (($gui_line_height + $gui_line_space) * ($gui_line_no - 1)) + $gui_line_space + ($gui_line_height - $gui_text_height)/2 EndFunc Func gui_line($gui_line_no) Return (($gui_line_height + $gui_line_space) * ($gui_line_no - 1)) + $gui_line_space EndFunc Func gui_col($gui_col_no) Return (($gui_col_width + $gui_col_space) * ($gui_col_no - 1)) + $gui_col_space EndFunc Func gui_line_height($gui_line_no) Return (($gui_line_height + $gui_line_space) * ($gui_line_no - 1)) + $gui_line_height EndFunc Func gui_col_width($gui_col_no) Return (($gui_col_width + $gui_col_space) * ($gui_col_no - 1)) + $gui_col_width EndFunc Func gui_height() Return ($gui_line_height + $gui_line_space) * $gui_max_line_no + $gui_line_space EndFunc Func gui_width() Return ($gui_col_width + $gui_col_space) * $gui_max_col_no + $gui_col_space EndFunc Func gui_group_line($gui_line_no) Return gui_line($gui_line_no) - ($gui_line_space + $gui_line_height)/2 EndFunc Func gui_group_col($gui_col_no) Return gui_col($gui_col_no) - $gui_col_space/2 EndFunc Func gui_group_line_height($gui_line_no) Return gui_line_height($gui_line_no) + $gui_line_height/2 + $gui_line_space EndFunc Func gui_group_col_width($gui_col_no) Return gui_col_width($gui_col_no) + $gui_col_space EndFunc Func RunGui() ; ; selection of project specific files ; GUICtrlCreateGroup ("Project Files", gui_group_col(1), gui_group_line(2), gui_group_col_width($gui_max_col_no), gui_group_line_height(5)) $inID = GUICtrlCreateButton ("Project folder", gui_col(2), gui_line(2), gui_col_width(1), $gui_line_height);, -1, $WS_EX_ACCEPTFILES) $intextID = GUICtrlCreateInput ($infolder, gui_col(3), gui_line(2), gui_col_width($gui_max_col_no-2), $gui_line_height, BitOr($ES_OEMCONVERT,$ES_AUTOHSCROLL,$ES_READONLY)) $a2lID = GUICtrlCreateButton ("A2L File", gui_col(1), gui_line(3), gui_col_width(1), $gui_line_height);, -1, $WS_EX_ACCEPTFILES) $a2ltextID = GUICtrlCreateInput ("", gui_col(2), gui_line(3), gui_col_width($gui_max_col_no-1), $gui_line_height, BitOr($ES_OEMCONVERT,$ES_AUTOHSCROLL,$ES_READONLY)) $a2lfile = CheckFilePattern($infolder, $a2lpaths, "*.a2l") If Not ($a2lfile = "") Then GUICtrlSetColor($a2ltextID, 0x0000ff) EndIf GUICtrlSetData ( $a2ltextID, $a2lfile ) $cceID = GUICtrlCreateButton ("Core Export File", gui_col(1), gui_line(4), gui_col_width(1), $gui_line_height);, -1, $WS_EX_ACCEPTFILES) $ccetextID = GUICtrlCreateInput ("", gui_col(2), gui_line(4), gui_col_width($gui_max_col_no-1), $gui_line_height, BitOr($ES_OEMCONVERT,$ES_AUTOHSCROLL,$ES_READONLY)) $ccefile = CheckFilePattern($infolder, $ccepaths, "*merged*export*.xml") If Not ($ccefile = "") Then GUICtrlSetColor($ccetextID, 0x0000ff) EndIf GUICtrlSetData ( $ccetextID, $ccefile ) ; ; select cbdelivery_confdata ; $cbID = GUICtrlCreateButton ("Comm Param File", gui_col(1), gui_line(5), gui_col_width(1), $gui_line_height);, -1, $WS_EX_ACCEPTFILES) $cbtextID = GUICtrlCreateInput ("", gui_col(2), gui_line(5), gui_col_width($gui_max_col_no-1), $gui_line_height, BitOr($ES_OEMCONVERT,$ES_AUTOHSCROLL,$ES_READONLY)) $cbfile = CheckFilePattern($infolder, $cbpaths, "cbdelivery_CONFDATA.xml") If Not ($cbfile = "") Then GUICtrlSetColor($cbtextID, 0x0000ff) EndIf GUICtrlSetData ( $cbtextID, $cbfile ) ;fj $adminhelp = "Adapt at least the contents of following XML element specified below:" & @LF & @LF & "" & @LF & " " & @LF & " " & @LF & " " & @LF & " " & @LF & " " & @LF & " " & @LF & @LF & " : Attribute ID-REF shall refer to your person" & @LF & " (check if available in )" & @LF & " : must equal calibrated value of BasSvrAppl_EepODXFileVer_C" & @LF & " : shall be current date in format ""yyyy-mm-ddThh:mm:ss""" $dcmID = GUICtrlCreateButton ("Calibration Data File", gui_col(1), gui_line(6), gui_col_width(1), $gui_line_height);, -1, $WS_EX_ACCEPTFILES) $dcmtextID = GUICtrlCreateInput ("", gui_col(2), gui_line(6), gui_col_width($gui_max_col_no-1), $gui_line_height, BitOr($ES_OEMCONVERT,$ES_AUTOHSCROLL,$ES_READONLY)) $foundfile = CheckFilePattern($infolder, $dcmpaths, "*.dcm") If $foundfile = "" Then $cntfiles = 0 Else $cntfiles = 1 EndIf $foundmorefile = CheckFilePattern($infolder, $dcmpaths, "*.kon") If $foundmorefile = "" Then $cntmorefiles = 0 Else $cntmorefiles = 1 EndIf If ($cntfiles + $cntmorefiles) = 1 Then If $cntfiles = 1 Then $dcmfile = $foundfile GUICtrlSetColor($dcmtextID, 0x0000ff) ElseIf $cntmorefiles = 1 Then $dcmfile = $foundmorefile GUICtrlSetColor($dcmtextID, 0x0000ff) Endif Else $dcmfile = "" EndIf GUICtrlSetData ( $dcmtextID, $dcmfile ) ; ; selection of customer supplied files ; GUICtrlCreateGroup ("Customer Supplied Files", gui_group_col(1), gui_group_line(8), gui_group_col_width($gui_max_col_no), gui_group_line_height(6)) Local $custinicnt Local $custIDlist[$customerfilelist[0]+1] Local $custIDallowed[$customerfilelist[0]+1] Local $custIDforbidden[$customerfilelist[0]+1] $custIDlist[0] = $customerfilelist[0] $custIDallowed[0] = $customerfilelist[0] $custIDforbidden[0] = $customerfilelist[0] Local $custcolwidth = (gui_width() - $gui_col_space * ($customerfilelist[0] + 1))/ $customerfilelist[0] For $custinicnt = 1 To $customerfilelist[0] GUICtrlCreateLabel($customerfilelist[$custinicnt] & " file:", (($custcolwidth+$gui_col_space)*($custinicnt-1)+($gui_col_space)), gui_text_line(8), $custcolwidth, $gui_line_height) $custIDlist[$custinicnt] = GUICtrlCreateList("", (($custcolwidth+$gui_col_space)*($custinicnt-1)+($gui_col_space)), gui_line(9), $custcolwidth, gui_line_height(4), BitOr($WS_VSCROLL, $LBS_DISABLENOSCROLL,$LBS_NOTIFY)) GUICtrlSetData($custIDlist[$custinicnt], $customerfileselections[$custinicnt], $customerfiledefaults[$custinicnt]) ; GUICtrlSetData($custIDlist[$custinicnt], $customerfileselections[$custinicnt], $customerfiledefaults[$custinicnt]) ; GUICtrlSetData($custIDlist[$custinicnt], $customerfiledefaults[$custinicnt], Default) If Not ($customerfileforbiddens[$custinicnt] = "") Then $custIDallowed[$custinicnt] = GUICtrlCreateButton("Allowed " & $customerfilelist[$custinicnt], (($custcolwidth+$gui_col_space)*($custinicnt-1)+($gui_col_space)), gui_line(13), ($custcolwidth-$gui_col_space)/2, $gui_line_height) GUICtrlSetState($custIDallowed[$custinicnt], $GUI_DISABLE) $custIDforbidden[$custinicnt] = GUICtrlCreateButton("Forbidden " & $customerfilelist[$custinicnt], (($custcolwidth+$gui_col_space)*($custinicnt-1)+($gui_col_space)) + (($custcolwidth-$gui_col_space)/2 + $gui_col_space), gui_line(13), ($custcolwidth-$gui_col_space)/2, $gui_line_height) GUICtrlSetState($custIDforbidden[$custinicnt], $GUI_ENABLE) EndIf $custfilename = GUICtrlRead($custIDlist[$custinicnt]) $custfiletype = $customerfilelist[$custinicnt] $custfilepath = $custfolder & "\" & $custfiletype & "\" & $custfilename $customerpaths[$custinicnt] = $custfilepath Next If $supportbugfix = 1 Then GUICtrlCreateGroup ("Bugfix Information", gui_group_col(1), gui_group_line(15), gui_group_col_width($gui_max_col_no), gui_group_line_height(3)) $bugfixmodeID = GUICtrlCreateCheckbox("Bugfix", gui_col(1), gui_line(15), gui_col_width(1), $gui_line_height);, BitOR($BS_AUTOCHECKBOX,$BS_RIGHTBUTTON)) GUICtrlCreateLabel ("File Version:", gui_col(2), gui_text_line(15), gui_col_width(1), $gui_text_height) $bfvtextID = GUICtrlCreateInput ($bugfixversion, gui_col(3), gui_line(15), gui_col_width(1), $gui_line_height, BitOr($ES_OEMCONVERT,$ES_AUTOHSCROLL)) GUICtrlSetColor($bfvtextID, 0x0000ff) GUICtrlSetState ($bfvtextID, $GUI_DISABLE) GUICtrlCreateLabel ("Change:", gui_col(2), gui_text_line(16), gui_col_width(1), $gui_text_height) $bfmtextID = GUICtrlCreateInput ($bugfixchange, gui_col(3), gui_line(16), gui_col_width($gui_max_col_no-2), $gui_line_height, BitOr($ES_OEMCONVERT,$ES_AUTOHSCROLL)) GUICtrlSetColor($bfmtextID, 0x0000ff) GUICtrlSetState ($bfmtextID, $GUI_DISABLE) GUICtrlCreateLabel ("Reason:", gui_col(2), gui_text_line(17), gui_col_width(1), $gui_text_height) $bfrtextID = GUICtrlCreateInput ($bugfixreason, gui_col(3), gui_line(17), gui_col_width($gui_max_col_no-2), $gui_line_height, BitOr($ES_OEMCONVERT,$ES_AUTOHSCROLL)) GUICtrlSetColor($bfrtextID, 0x0000ff) GUICtrlSetState ($bfrtextID, $GUI_DISABLE) Else Local $bugfixmodeID, $bfvtextID, $bfmtextID, $bfrtextID EndIf ; GUICtrlCreateLabel ("VAX-Checker version", gui_col(1), gui_text_line(11), gui_col_width(1), $gui_text_height);, BitOr($GUI_SS_DEFAULT_LABEL,$SS_CENTER)) ; For $cnt = 1 To $checkversion_cnt ;GUICtrlCreateLabel ($checkversions[$cnt], gui_col(2+$cnt), gui_line(9), gui_col_width(0.5), $gui_line_height) ; $checkversionIDs[$cnt] = GUICtrlCreateCheckbox($checkversions[$cnt], gui_col(1+$cnt), gui_line(11), gui_col_width(1), $gui_line_height);, BitOR($BS_AUTOCHECKBOX,$BS_RIGHTBUTTON)) ; NEXT ; GUICtrlCreateLabel ("Deliver Checker Result", gui_col(1), gui_text_line(12), gui_col_width(1), $gui_text_height);, BitOr($GUI_SS_DEFAULT_LABEL,$SS_CENTER)) ; $DeliverCheckID = GUICtrlCreateCheckbox ( "", gui_col(2), gui_line(12), gui_col_width(1), $gui_line_height);, BitOR($BS_AUTOCHECKBOX,$BS_RIGHTBUTTON)) ; $DeliverCheck = True ; default ; ; output folder ; GUICtrlCreateGroup ("Control", gui_group_col(1), gui_group_line($gui_max_line_no-2), gui_group_col_width($gui_max_col_no), gui_group_line_height(3)) $outID = GUICtrlCreateButton ("Output folder", gui_col(2), gui_line($gui_max_line_no-2), gui_col_width(1), $gui_line_height);, -1, $WS_EX_ACCEPTFILES) $outtextID = GUICtrlCreateInput ($outfolder, gui_col(3), gui_line($gui_max_line_no-2), gui_col_width($gui_max_col_no-2), $gui_line_height, BitOr($ES_OEMCONVERT,$ES_AUTOHSCROLL,$ES_READONLY)) GUICtrlSetColor($outtextID, 0x0000ff) ; ; bird version ; ; Local $birdversionlabel = "BIRD version" ; If Not $birddotversion Then ; $search = FileFindFirstFile($birdrootfolder&"\?v*") ; Else ; $search = FileFindFirstFile($birdrootfolder&"\?.*") ; Endif ; If $search = -1 Then ; AbortMessage("ERROR", "No BIRD installation found at:" & @LF & $birdrootfolder) ; EndIf ; Local $birdversion_cnt = 0 ; Local $file, $version, $versionstr, $lastversion ; $versionstr = "" ; While Not @error ; $file = FileFindNextFile($search) ; If @error Then ExitLoop ; $version = GetVersion($file) ; $versionstr = $versionstr & "|" & $version ; $lastversion = $version ; $birdversion_cnt = $birdversion_cnt + 1 ; WEnd ; FileClose($search) ; GUICtrlCreateLabel ($birdversionlabel, gui_col(1), gui_line(14), gui_col_width(1), $gui_line_height, BitOr($GUI_SS_DEFAULT_LABEL,$SS_CENTER)) ; $BirdID = GUICtrlCreateList ( "", gui_col(1), gui_line(14)+$gui_text_height, gui_col_width(1), $gui_text_height * ($birdversion_cnt+1)) ; GUICtrlSetData($BirdID, $versionstr, $lastversion) ; GUICtrlSetState($BirdID, $GUI_ENABLE) ; ; last line: start button, progress, exit button ; $OkID = GUICtrlCreateButton ("Start", gui_col(1), gui_line($gui_max_line_no), gui_col_width(1), $gui_line_height) GUICtrlSetState($OkID,$GUI_DISABLE) $CancelID = GUICtrlCreateButton ("Exit", gui_col($gui_max_col_no), gui_line($gui_max_line_no), gui_col_width(1), $gui_line_height) GUISetState() ; display the GUI Do $msg = GUIGetMsg() If $msg > 0 Then ; Message("TEST", "$msg=<" & $msg & ">") ToolTip("") Select Case $msg = $inID $infolder_new = FileSelectFolder("project input folder", "", 1+2+4, $infolder) ; GUICtrlSetColor ( $intextID, 0x000000) If Not ($infolder_new = $infolder) Then $infolder = $infolder_new GUICtrlSetData ( $intextID, $infolder ) $a2lfile = CheckFilePattern($infolder, $a2lpaths, "*.a2l") If Not ($a2lfile = "") Then GUICtrlSetColor($a2ltextID, 0x0000ff) EndIf GUICtrlSetData ( $a2ltextID, $a2lfile ) $ccefile = CheckFilePattern($infolder, $ccepaths, "*merged*export*.xml") If Not ($ccefile = "") Then GUICtrlSetColor($ccetextID, 0x0000ff) EndIf GUICtrlSetData ( $ccetextID, $ccefile ) $cbfile = CheckFilePattern($infolder, $cbpaths, "cbdelivery_CONFDATA.xml") If Not ($cbfile = "") Then GUICtrlSetColor($cbtextID, 0x0000ff) EndIf GUICtrlSetData ( $cbtextID, $cbfile ) $foundfile = CheckFilePattern($infolder, $dcmpaths, "*.dcm") If $foundfile = "" Then $cntfiles = 0 Else $cntfiles = 1 EndIf $foundmorefile = CheckFilePattern($infolder, $dcmpaths, "*.kon") If $foundmorefile = "" Then $cntmorefiles = 0 Else $cntmorefiles = 1 EndIf If ($cntfiles + $cntmorefiles) = 1 Then If $cntfiles = 1 Then $dcmfile = $foundfile GUICtrlSetColor($dcmtextID, 0x0000ff) ElseIf $cntmorefiles = 1 Then $dcmfile = $foundmorefile GUICtrlSetColor($dcmtextID, 0x0000ff) Endif Else $dcmfile = "" EndIf GUICtrlSetData ( $dcmtextID, $dcmfile ) $outfolder = $infolder GUICtrlSetColor ( $outtextID, 0x0000ff) GUICtrlSetData ( $outtextID, $outfolder ) EndIf Case $msg = $intextID Case $msg = $outID $outfolder_new = FileSelectFolder("output folder", "", 1+2+4, $outfolder) GUICtrlSetColor ( $outtextID, 0x000000) If Not ($outfolder_new = $outfolder) Then $logfile_new = $outfolder_new & $logname If FileExists($outfolder) And FileExists($outfolder_new) And FileExists($logfile) Then If FileCopy($logfile,$logfile_new,9) = 0 Then Message("ERROR", "no write access to output directory " & @LF & $outfolder_new & @LF & "please select another one") GUICtrlSetColor ( $outtextID, 0xff0000) EndIf EndIf $outfolder = $outfolder_new $logfile = $logfile_new EndIF GUICtrlSetData ( $outtextID, $outfolder ) Case $msg = $outtextID Case $msg= $OkID GUICtrlSetState($OkID,$GUI_DISABLE) GUICtrlSetState($progressID, $GUI_ENABLE) GUICtrlSetState($progresslabelID, $GUI_ENABLE) If $bugfixmode = $GUI_CHECKED Then $bugfixhandle = FileOpen($outfolder & "\bugfix.xml",2) FileWriteLine($bugfixhandle, "") FileWriteLine($bugfixhandle, " " & $bugfixversion & "") FileWriteLine($bugfixhandle, " " & $bugfixchange & "") FileWriteLine($bugfixhandle, " " & $bugfixreason & "") FileWriteLine($bugfixhandle, "") FileClose($bugfixhandle) EndIf If Not (ExecuteGeneration() = 0) Then If FileExists($errlogfile) Then ShellExecuteWait("notepad", $errlogfile, $outfolder) EndIf EndIf GUICtrlSetState($progressID, $GUI_DISABLE) GUICtrlSetState($progresslabelID, $GUI_DISABLE) GUICtrlSetState($OkID,$GUI_ENABLE) Case $msg= $cbID ; ToolTip ( "Please look at following directories," & @LF & "(starting from project directory):" & @LF & StringReplace($cbpaths, "|" , @LF) , Default , Default , "Hint" , 1 ) $cbfile = FileOpenDialog("comm param file", $infolder, "comm param files (cbdelivery_CONFDATA.xml)", 1+2) ToolTip ( "" ) GUICtrlSetColor ( $cbtextID, 0x000000) GUICtrlSetData ( $cbtextID, $cbfile ) Case $msg= $cbtextID Case $msg= $CancelID Case $msg= $GUI_EVENT_CLOSE Case $msg= $a2lID ; ToolTip ( "Please look at following directories," & @LF & "(starting from project directory):" & @LF & StringReplace($a2lpaths, "|" , @LF) , Default , Default , "Hint" , 1 ) $a2lfile = FileOpenDialog("a2l file", $infolder, "a2l files (*.a2l)", 1+2) ToolTip ( "" ) GUICtrlSetColor ( $a2ltextID, 0x000000) GUICtrlSetData ( $a2ltextID, $a2lfile ) Case $msg= $a2ltextID Case $msg= $cceID ; ToolTip ( "Please look at following directories," & @LF & "(starting from project directory):" & @LF & StringReplace($ccepaths, "|" , @LF) , Default , Default , "Hint" , 1 ) $ccefile = FileOpenDialog("core config export file", $infolder, "cce files (*merged*export*.xml)", 1+2) ToolTip ( "" ) GUICtrlSetColor ( $ccetextID, 0x000000) GUICtrlSetData ( $ccetextID, $ccefile ) Case $msg= $ccetextID Case $msg= $dcmID ; ToolTip ( "Please look at following directories," & @LF & "(starting from project directory):" & @LF & StringReplace($dcmpaths, "|" , @LF) , Default , Default , "Hint" , 1 ) $dcmfile = FileOpenDialog("calibration data file", $infolder, "dcm files (*.dcm;*.kon)", 1+2) ToolTip ( "" ) GUICtrlSetColor ( $dcmtextID, 0x000000) GUICtrlSetData ( $dcmtextID, $dcmfile ) Case $msg= $dcmtextID Case $msg= $bugfixmodeID $bugfixmode = GUICtrlRead($bugfixmodeID) If $bugfixmode = $GUI_CHECKED Then ; ToolTip ( "Be careful: File Version will override calibrated value!" & @LF & "File Version format:" & @LF & " A (series release), S (??? release) or X (development release) followed by 5 digits" & @LF & " first 2 digit number for incompatible changes, last 3 digit number for compatible changes" & @LF & " for series release (A) please refer to release formular by VAG" & @LF & " for development release (X) increase numbers according to compatible/incompatible changes" & @LF & "additionally specify the change and reason for this bugfix!" , Default , Default , "Hint" , 1 ) GUICtrlSetState ($bfvtextID, $GUI_ENABLE) GUICtrlSetState ($bfmtextID, $GUI_ENABLE) GUICtrlSetState ($bfrtextID, $GUI_ENABLE) Else GUICtrlSetState ($bfvtextID, $GUI_DISABLE) GUICtrlSetState ($bfmtextID, $GUI_DISABLE) GUICtrlSetState ($bfrtextID, $GUI_DISABLE) EndIf Case $msg= $bfvtextID $bugfixversion = GUICtrlRead($bfvtextID) If Not CheckBugfixVersion($bugfixversion) Then Message("ERROR", "improper file version specified:" & @LF & "has to be A, S or X followed by 5 digits") GUICtrlSetColor ( $bfvtextID, 0xff0000) Else GUICtrlSetColor ( $bfvtextID, 0x000000) EndIf Case $msg= $bfmtextID GUICtrlSetColor ( $bfmtextID, 0x000000) $bugfixchange = GUICtrlRead($bfmtextID) Case $msg= $bfrtextID GUICtrlSetColor ( $bfrtextID, 0x000000) $bugfixreason = GUICtrlRead($bfrtextID) case Else ; generics for customer files Local $custfilename = "" Local $custfiletype = "" Local $custfilepath = "" For $custinicnt = 1 To $customerfilelist[0] Select Case $msg= $custIDlist[$custinicnt] $custfilename = GUICtrlRead($custIDlist[$custinicnt]) $custfiletype = $customerfilelist[$custinicnt] $custfilepath = $custfolder & "\" & $custfiletype & "\" & $custfilename $customerpaths[$custinicnt] = $custfilepath ; If Not ($customerfileforbiddens = "") Then ; If GUICtrlGetState($custIDallowed[$custinicnt]) = $GUI_DISABLE Then ; Message("WARNING", "selected " & $custfiletype & " file is not allowed for this version " & $odx4vagversion & ":" & @LF & $custfilename) ; EndIf ; EndIf Case $msg= $custIDallowed[$custinicnt] GUICtrlSetState($custIDallowed[$custinicnt], $GUI_DISABLE) GUICtrlSetState($custIDforbidden[$custinicnt], $GUI_ENABLE) GUICtrlSetColor($custIDlist[$custinicnt], 0x000000) GUICtrlSetData($custIDlist[$custinicnt], "") GUICtrlSetData($custIDlist[$custinicnt], $customerfileselections[$custinicnt], $customerfiledefaults[$custinicnt]) $custfilename = GUICtrlRead($custIDlist[$custinicnt]) $custfiletype = $customerfilelist[$custinicnt] $custfilepath = $custfolder & "\" & $custfiletype & "\" & $custfilename $customerpaths[$custinicnt] = $custfilepath ; If Not ($customerfileforbiddens = "") Then ; If GUICtrlGetState($custIDallowed[$custinicnt]) = $GUI_DISABLE Then ; Message("WARNING", "selected " & $custfiletype & " file is not allowed for this version " & $odx4vagversion & ":" & @LF & $custfilename) ; EndIf ; EndIf Case $msg= $custIDforbidden[$custinicnt] GUICtrlSetState($custIDforbidden[$custinicnt], $GUI_DISABLE) GUICtrlSetState($custIDallowed[$custinicnt], $GUI_ENABLE) GUICtrlSetColor($custIDlist[$custinicnt], 0xff0000) GUICtrlSetData($custIDlist[$custinicnt], "") GUICtrlSetData($custIDlist[$custinicnt], $customerfileforbiddens[$custinicnt], $customerfileforbiddendefaults[$custinicnt]) $custfilename = GUICtrlRead($custIDlist[$custinicnt]) $custfiletype = $customerfilelist[$custinicnt] $custfilepath = $custfolder & "\" & $custfiletype & "\" & $custfilename $customerpaths[$custinicnt] = $custfilepath ; If Not ($customerfileforbiddens = "") Then ; If GUICtrlGetState($custIDallowed[$custinicnt]) = $GUI_DISABLE Then ; Message("WARNING", "selected " & $custfiletype & " file is not allowed for this version " & $odx4vagversion & ":" & @LF & $custfilename) ; EndIf ; EndIf EndSelect Next ; Case $msg= $BirdID ; Case $msg = $DeliverCheckID ; If GUICtrlRead ($DeliverCheckID) = $GUI_CHECKED Then ; $DeliverCheck = True ; Else ; $DeliverCheck = False ; EndIf ; Case Else ; For $cnt = 1 To $checkversion_cnt ; If $msg = $checkversionIDs[$cnt] Then ; If GUICtrlRead ($checkversionIDs[$cnt]) = $GUI_CHECKED Then ; $RunChecker[$cnt] = true ; Else ; $RunChecker[$cnt] = false ; EndIf ; EndIf ; Next EndSelect ; $birdversion = GUICtrlRead($BirdID) ; $birdargs = BirdArgs($birdversion) $checksilent = True If CheckFile($outfolder, "Output folder") And CheckInFiles() And CheckBugfixVersion($bugfixversion) Then GUICtrlSetState ($OkID, $GUI_ENABLE) Else GUICtrlSetState ($OkID, $GUI_DISABLE) EndIf $checksilent = False EndIf Sleep(50) Until ($msg = $GUI_EVENT_CLOSE) OR ($msg = $CancelID) Return EndFunc Func CheckBugfixVersion($version) Local $check = True If $bugfixmode = $GUI_CHECKED Then If Not(StringLen($version) = 6) Or (StringRegExp(StringUpper($version), "[ASX][0-9][0-9][0-9][0-9][0-9]") = 0) Then $check = False EndIf EndIf Return $check EndFunc Func ExecuteGeneration() ; return 0 on success, other values indicate error $errlogfile = "" Local $cnt, $rc, $res, $show ; $message = "" ; For $cnt = 1 To $customerpaths[0] ; $message = $message & @LF & $customerpaths[$cnt] ; Next ; Message ("TEST", $message) ; Return 0 If $ShowWindows = true Then $show = @SW_SHOWDEFAULT ;@SW_MAXIMIZE Else $show = @SW_HIDE EndIf $res = FileCopy($conffolder & "\odx*.xsd", $outfolder & "\", 1) If NOT($res = 1) Then Message("ERROR", "odx schema files " & $conffolder & "\odx*.xsd not copied to " & $outfolder & "\") Return 1 EndIf ; ; copy pdx file to output folder and unzip odx files ; ViewProgress(0, "prepare input files") Local $pdxfile = $customerpaths[$customerpdx] Local $pdxdest = $outfolder & "\odx4vag_odxoutputfile.pdx" $res = FileCopy($pdxfile, $pdxdest, 1) If NOT($res = 1) Then Message("ERROR", "pdx file " & $pdxfile & " not copied to " & $pdxdest) Return 1 EndIf ViewProgress(2) Local $pdxtempfolder = $outfolder & "\pdx" If FileExists($pdxtempfolder) Then DirRemove($pdxtempfolder, 1) ; to ensure a clear directory If FileExists($pdxtempfolder) Then Message("ERROR", "previous temp pdx output folder could not be deleted: " & $pdxtempfolder) Return 1 EndIf EndIf DirCreate($pdxtempfolder) If NOT(FileExists($pdxtempfolder) = 1) Then Message("ERROR", "temp pdx output folder could not be created: " & $pdxtempfolder) Return 1 EndIf $rc = ShellExecuteWait($winzippath & "\wzunzip", """" & $pdxdest & """ """ & $pdxtempfolder & """ *.odx -o -yO", $workfolder, "open", $show) If NOT($rc = 0) Then Message("ERROR", "odx files not extracted from " & $pdxdest & " to " & $pdxtempfolder) Return 1 EndIf $rc = ShellExecuteWait($winzippath & "\wzunzip", """" & $pdxdest & """ """ & $pdxtempfolder & """ index.xml -o -yO", $workfolder, "open", $show) If NOT($rc = 0) Then Message("ERROR", "index.xml not extracted from " & $pdxdest & " to " & $pdxtempfolder) Return 1 EndIf ; ; start ODX and index file generation ; ViewProgress(5, "odx file generation (10' - be patient!)" ) Local $outfile, $birdlogfile, $cfgfile $outfile = $outfolder & "\odx4vag_odxoutputfile.odx" $birdlogfile = $outfolder & "\odx4vag_odxoutputfile.log" $cfgfile = $outfolder & "\odx4vag_odxoutputfile.cfg" $cfghandle = FileOpen($cfgfile, 2) If $cfghandle < 0 Then Message("ERROR", "bird argument file could not be created: " & @LF & $cfgfile) Return 1 EndIf For $cnt = 1 To $odxdirectarguments[0] FileWriteLine($cfghandle, $odxdirectarguments[$cnt]) Next FileWriteLine($cfghandle, "--template """ & $templatefile & """") FileWriteLine($cfghandle, "--data merged_corecfg_export,XML,""" & $ccefile & """") FileWriteLine($cfghandle, "--data dcm,DCM20,""" & $dcmfile & """") FileWriteLine($cfghandle, "--data a2l,ASAP2-MC,""" & $a2lfile & """") FileWriteLine($cfghandle, "--data cbdelivery_confdata,XML,""" & $cbfile & """") For $cnt = 1 To $customersymboliclist[0] FileWriteLine($cfghandle, "--data " & $customersymboliclist[$cnt] & ",XML,""" & $customerpaths[$cnt] & """") Next FileWriteLine($cfghandle, "--data version_xml,XML,""" & $conffolder & "\..\version.xml""") If $bugfixmode = $GUI_CHECKED Then FileWriteLine($cfghandle, "--data bugfix_xml,XML,""" & $outfolder & "\bugfix.xml""") EndIf ; assign odx files to symbolic names Local $assigned = False Local $symprefixes Local $cnt1, $cnt2, $cnt3 Local $symlen Local $filename Local $line Local $argument Local $masterslaveno Local $custodxfiles = FindFiles($pdxtempfolder, "*.odx", False) Local $custodxparts ; remove paths For $cnt1 = 1 To $custodxfiles[0] $custodxparts = StringSplit($custodxfiles[$cnt1], "\") $custodxfiles[$cnt1] = $custodxparts[$custodxparts[0]] Next Local $symassign = StringSplit($pdxsymbolics, "|") For $cnt1 = 1 To $symassign[0] $assigned = False $symparts = StringSplit($symassign[$cnt1],":") $symprefixes = StringSplit($symparts[2], "/") For $cnt2 = 1 To $symprefixes[0] $symlen = StringLen($symprefixes[$cnt2]) ; look for matching files For $cnt3 = 1 To $custodxfiles[0] If StringLeft($custodxfiles[$cnt3], $symlen) = $symprefixes[$cnt2] Then If $assigned = True Then ; Message("WARNING", "symbolic name """ & $symparts[1] & """ is already assigned" & @LF & "file will be ignored:" & $custodxfiles[$cnt3]) Else $argument = "--data " & $symparts[1] & ",XML,""" & $pdxtempfolder & "\" & $custodxfiles[$cnt3] & """" FileWriteLine($cfghandle, $argument) $assigned = True EndIf EndIf Next Next If $assigned = False Then Message("ERROR", "symbolic name """ & $symparts[1] & """ could not be assigned to a file with prefix(es):" & $symparts[2]) EndIf Next ;WriteDataFileArgs($cfghandle, $conffolder & "\correction", "*.xml") WriteDataFileArgs($cfghandle, $conffolder & "\correction", "*.odx") WriteDataFileArgs($cfghandle, $conffolder & "\mapping", "*.xml") FileWriteLine($cfghandle, "--suppress_input_validation") For $cnt = 1 To $odxjar_cnt FileWriteLine($cfghandle, "--library """ & $odxjarfolder & "\" & $odxjars[$cnt] & """") Next FileWriteLine($cfghandle, "--out """ & $outfile & """") ; FileWriteLine($cfghandle, "--suppress_output_validation") ; to be deleted ; FileWriteLine($cfghandle, "--max_output_validation_errors 0") ; to be inserted FileWriteLine($cfghandle, "-l """ & $birdlogfile & """") FileWriteLine($cfghandle, "-q") FileClose($cfghandle) FileDelete($outfile) $rc = ShellExecuteWait($birdjavaexe , BirdArgs($birdversion) & " -a """ & $cfgfile & """", $workfolder, "open", $show) If NOT ($rc = 0) Then If FileExists($birdlogfile) Then $errlogfile = $birdlogfile EndIf Message("ERROR", "odx file generation failed, error level: " & $rc & @LF & "please see end of log file for details") Return $rc ElseIf Not FileExists($outfile) Then If FileExists($birdlogfile) Then $errlogfile = $birdlogfile EndIf Message("ERROR", "odx file not generated: " & $outfile) Return 1 EndIf ViewProgress(56, "index file generation (1')" ) Local $indextemplatefile $indextemplatefile = $conffolder & "\template\Template_index.xml" $outfile = $outfolder & "\index.xml" $birdlogfile = $outfolder & "\index.log" $cfgfile = $outfolder & "\index.cfg" $cfghandle = FileOpen($cfgfile, 2) If $cfghandle < 0 Then Message("ERROR", "bird argument file could not be created: " & @LF & $cfgfile) Return 1 EndIf FileWriteLine($cfghandle, "--template """ & $indextemplatefile & """") FileWriteLine($cfghandle, "--data dcm,DCM20,""" & $dcmfile & """") FileWriteLine($cfghandle, "--data index,XML,""" & $outfolder & "\pdx\index.xml""") If $bugfixmode = $GUI_CHECKED Then FileWriteLine($cfghandle, "--data bugfix_xml,XML,""" & $outfolder & "\bugfix.xml""") EndIf FileWriteLine($cfghandle, "--suppress_input_validation") FileWriteLine($cfghandle, "--library """ & $indexlib & """") FileWriteLine($cfghandle, "--out """ & $outfile & """") ; FileWriteLine($cfghandle, "--suppress_output_validation") FileWriteLine($cfghandle, "-l """ & $birdlogfile & """") FileWriteLine($cfghandle, "-q") FileClose($cfghandle) FileDelete($outfile) $rc = ShellExecuteWait($birdjavaexe, BirdArgs($birdversion) & " -a """ & $cfgfile & """", $workfolder, "open", $show) If NOT ($rc = 0) Then If FileExists($birdlogfile) Then $errlogfile = $birdlogfile EndIf Message("ERROR", "index file generation failed, error level: " & $rc & @LF & "please see end of log file for details") Return $rc ElseIf Not FileExists($outfile) Then If FileExists($birdlogfile) Then $errlogfile = $birdlogfile EndIf Message("ERROR", "index file not generated: " & $outfile) Return 1 EndIf ViewProgress(66, "renaming files" ) DirRemove($pdxtempfolder, 1) ; remove odx schema Files FileDelete($outfolder & "\odx*.xsd") ;FJ ; FileDelete($libversionfile); delete, when version.xml is used in future!!! ; FileDelete($pdxversionfile) ;FJ ; ; parse generated index file for EV file name -> $evFile ; Local $evFile, $pdxname _PathSplit($pdxfile, $szDrive, $szDir, $pdxname, $szExt) $ifile = $outfolder & "\index.xml" $ihandle = FileOpen($ifile,0) If $ihandle = -1 Then Message("ERROR", "index file " & $ifile & " not found") Return 1 Else $found = 0 $iline = FileReadLine($ihandle) While (NOT @error) AND ($found = 0) $posStart = StringInStr($iline,">EV_",1) $posEnd = StringInStr($iline,".odx",1) If ($posStart > 0) AND ($posEnd > 0) Then $evFile = StringMid($iline,$posStart+1,($posEnd-$posStart-1)) $found = 1 Else $iline = FileReadLine($ihandle) EndIf Wend If @error Then Message("ERROR", "EV name not found in index file " & $ifile & @LF & "implementation error: check index file generation and analysis for consistency") Return 1 EndIf EndIf FileClose($ihandle) ViewProgress(68) ; ; rename files to final names ; Local $odxfinal = $outfolder & "\" & $evFile & ".odx" Local $logfinal = $outfolder & "\" & $evFile & ".log" Local $cfgfinal = $outfolder & "\" & $evFile & ".cfg" Local $pdxfinal = $outfolder & "\" & $pdxname & "_" & $evfile & ".pdx" Local $zipfinal = $outfolder & "\" & $pdxname & "_" & $evfile & ".zip" If FileMove($outfolder & "\odx4vag_odxoutputfile.odx", $odxfinal, 1) = 0 Then Message("ERROR", "output file " & $outfolder & "\odx4vag_odxoutputfile.odx" & " not renamed to " & $evFile) Return 1 EndIf If FileMove($outfolder & "\odx4vag_odxoutputfile.pdx", $pdxfinal, 1) = 0 Then Message("ERROR", "output file " & $outfolder & "\odx4vag_odxoutputfile.pdx" & " not renamed to " & $pdxname & "_" & $evfile) Return 1 EndIf ViewProgress(72, "check odx file (2')") ; ; update pdx file for checker ; $rc = ShellExecuteWait($winzippath & "\wzzip", """" & $pdxfinal & """ """ & $odxfinal & """ -u", $workfolder, "open", $show) If NOT($rc = 0) Then Message("ERROR", $odxfinal & " not zipped into " & $pdxfinal) Return $rc EndIf ViewProgress(74) $rc = ShellExecuteWait($winzippath & "\wzzip", """" & $pdxfinal & """ """ & $ifile & """ -u", $workfolder, "open", $show) If NOT($rc = 0) Then Message("ERROR", $ifile & " not zipped into " & $pdxfinal) Return $rc EndIf ViewProgress(76) $actProgress = 76 ; ; call checker and add result to pdx ; $rc_final = 0 $runcnt = 0 For $cnt = 1 To $checkversion_cnt If $RunChecker[$cnt] = True Then $runcnt = $runcnt + 1 EndIf Next If $runcnt > 0 Then Local $jarfiles Local $checkopts Local $jcnt Local $checkversionact $progress_step = (100 - $actProgress) / $runcnt For $cnt = 1 To $checkversion_cnt If $RunChecker[$cnt] = True Then $checkversionact = $checkversions[$cnt] ViewProgress($actProgress,"VAX-Checker " & $checkversionact) $checkfinal = $outfolder & "\" & $evFile & "_check_" & $checkversionact & ".html" $checkfolder = $checkrootfolder & "\" & $checkversionact $checkopts = "-cp vaxtoolbox.jar" $jarfiles = FindFiles($checkfolder & "\lib\endorsed", "*.jar", False) For $jcnt = 1 To $jarfiles[0] $checkopts = $checkopts & ";lib\endorsed\" & $jarfiles[$jcnt] Next $jarfiles = FindFiles($checkfolder & "\lib", "*.jar", False) For $jcnt = 1 To $jarfiles[0] $checkopts = $checkopts & ";lib\" & $jarfiles[$jcnt] Next $checkopts = $checkopts & " com.tsystems.checker.Checker -pdx """ & $pdxfinal & """ -odx """& $evFile & ".odx"" -result """ & $checkfinal & """ -de -html" ;Message("TEST", $checkopts & @LF & "-cp vaxtoolbox.jar;lib\endorsed\xalan.jar;lib\endorsed\xercesImpl.jar;lib\endorsed\xml-apis.jar;lib\endorsed\serializer.jar;lib\avalon-framework.jar;lib\batik.jar;lib\checkResult.jar;lib\diffResult.jar;lib\diffResultObj.jar;lib\dom4j-1.5.jar;lib\fop.jar;lib\jakarta-oro-2.0.6.jar;lib\jaxen-1.1-beta-2.jar;lib\jdom.jar;lib\jh.jar;lib\jlicman.jar;lib\jsr173_1.0_api.jar;lib\log4j-1.2.8.jar;lib\odx201.jar;lib\poi-2.5.1-final-20040804.jar;lib\projectData.jar;lib\ruleList.jar;lib\saxon8.jar;lib\xbean.jar;lib\xbean_xpath.jar;lib\xslbin_tx.jar;lib\xslbin_vax.jar com.tsystems.checker.Checker -pdx " & $pdxfinal & " -odx "& $evFile & ".odx -result " & $checkfinal & " -de -html") ;$rc = ShellExecuteWait("java", "-cp vaxtoolbox.jar;lib\endorsed\xalan.jar;lib\endorsed\xercesImpl.jar;lib\endorsed\xml-apis.jar;lib\endorsed\serializer.jar;lib\avalon-framework.jar;lib\batik.jar;lib\checkResult.jar;lib\diffResult.jar;lib\diffResultObj.jar;lib\dom4j-1.5.jar;lib\fop.jar;lib\jakarta-oro-2.0.6.jar;lib\jaxen-1.1-beta-2.jar;lib\jdom.jar;lib\jh.jar;lib\jlicman.jar;lib\jsr173_1.0_api.jar;lib\log4j-1.2.8.jar;lib\odx201.jar;lib\poi-2.5.1-final-20040804.jar;lib\projectData.jar;lib\ruleList.jar;lib\saxon8.jar;lib\xbean.jar;lib\xbean_xpath.jar;lib\xslbin_tx.jar;lib\xslbin_vax.jar com.tsystems.checker.Checker -pdx " & $pdxfinal & " -odx "& $evFile & ".odx -result " & $checkfinal & " -de -html", $checkfolder, "open", $show) $rc = ShellExecuteWait($checkerjavaexe, $checkopts, $checkfolder, "open", $show) If NOT($rc = 0) Then Message("ERROR", "VAX checker " & $checkversionact & " not run properly") $rc_final = $rc EndIf If $DeliverCheck Then $rc = ShellExecuteWait($winzippath & "\wzzip", """" & $zipfinal & """ """ & $checkfinal & """ -u", $workfolder, "open", $show ) If NOT($rc = 0) Then Message("ERROR", $checkfinal & " not zipped into " & $zipfinal) $rc_final = $rc EndIf EndIf $actProgress = $actProgress + $progress_step EndIf Next If $DeliverCheck Then $rc = ShellExecuteWait($winzippath & "\wzzip", """" & $zipfinal & """ """ & $pdxfinal & """ -u", $workfolder, "open", $show ) If NOT($rc = 0) Then Message("ERROR", $pdxfinal & " not zipped into " & $zipfinal) $rc_final = $rc EndIf EndIf Else If $DeliverCheck Then Message("ERROR", "no VAX checker version selected") EndIf EndIf ViewProgress(100, "finished") If $rc_final = 0 Then If $runcnt > 0 Then Message("SUCCESS", "result file created:" & @LF & $zipfinal) Else Message("SUCCESS", "result file created:" & @LF & $pdxfinal) EndIf EndIf Return $rc_final EndFunc Func FindLastFile($folder, $pattern) Local $allfiles = FindFiles($folder, $pattern, False) Local $retfile = "" Local $lasttime = "0" Local $cnt Local $time Local $file For $cnt = 1 To $allfiles[0] $file = $folder & "\" & $allfiles[$cnt] $time = FileGetTime($file, 0, 1) If $time > $lasttime Then $retfile = $file $lasttime = $time EndIf Next Return $retfile EndFunc Func FindFiles($folder, $pattern, $silent) Local $filearray[$arrsiz], $cnt, $file, $search $cnt = 0 $filearray[0] = 0 If Not FileExists($folder) Then If Not $silent Then Message("ERROR", "folder does not exist:" & @LF & $folder) EndIf Return $filearray EndIf $search = FileFindFirstFile($folder & "\" & $pattern) If $search = -1 Then If Not $silent Then Message("ERROR", "No " & $pattern & " files found in folder:" & @LF & $folder) EndIf Return $filearray EndIf While Not @error $cnt = $cnt + 1 If $cnt >= $arrsiz Then AbortMessage("ERROR", "More than " & $arrsiz & " " & $pattern & " files found in folder:" & @LF & $folder & @LF & "increase internal array size!") EndIf $file = FileFindNextFile($search) If @error Then ExitLoop $filearray[$cnt] = $file WEnd $filearray[0] = $cnt-1 FileClose($search) return $filearray EndFunc Func CreateBirdDataArgument ($folder, $file, $prefix) Local $parts, $ext, $split, $odxtype, $symbolic, $argument $argument = "" ; shall be ignored if not changed $parts = StringSplit($file,".") If $parts[0] < 2 Then Message("WARNING", "Improper file name " & $file & " detected: no extension found" & @LF & "file will be ignored:" & @LF & $folder & "\" & $file) Else $ext = $parts[$parts[0]] ; If $ext = "odx" Then If $prefix = "" Then $symbolic = StringLower($prefix & $parts[1]) ; up to the 1st "." for RB xml and odx files (file name = symbolic name) Else $split = StringSplit($parts[1],"_") $symbolic = StringLower($prefix & $split[1]) ; patch for comparams and new test pdx - must be changed in java lib If $split[1] = "CPS" Then $symbolic = StringLower($prefix & "diagcancomparamspec") EndIf EndIf ; $odxtype = $split[1] ; If $odxtype = "BV" Then ; $symbolic = "odx_bv" ; ElseIf $odxtype = "ES" Then ; $symbolic = "odx_es" ; ElseIf $odxtype = "PR" Then ; $symbolic = "odx_pr" ; ElseIf $odxtype = "XV" Then ; $symbolic = "xv" ; ElseIf $odxtype = "DiagCanComparamSpec" Then ; $symbolic = "comparam_ref" ; ElseIf $odxtype = "VI" Then ; $symbolic = "" ; AUDI vehicle interface shall be ignored ; ElseIf $odxtype = "FG" Then ; $symbolic = "" ; AUDI functional group shall be ignored ; Else ; $symbolic = $parts[1] ; up to the 1st "." for RB ODX files (file name = symbolic name) ; EndIf ; ElseIf $ext = "xml" Then ; $symbolic = StringLower($prefix & $parts[1]) ; up to the 1st "." for RB xml files (file name = symbolic name) ; Else ; $symbolic = "" ; shall be ignored ; EndIf ; If Not($symbolic = "") Then $argument = "--data " & $symbolic & ",XML,""" & $folder & "\" & $file & """" ; EndIf EndIf Return $argument EndFunc ; ; bird arguments from command line ; Func AddArg($arg) If $odxdirectarguments[0] >= (2*$arrsiz)-1 Then AbortMessage("ERROR", "argument array overflow" & @LF & "increase array size of odx argument array") EndIf $odxdirectarguments[0] = $odxdirectarguments[0] + 1 $odxdirectarguments[$odxdirectarguments[0]] = $arg Return EndFunc Func BirdArgs($version) Local $args, $nversion ; If Not $birddotversion Then ; $version = GetNVersion($version) ; EndIF Local $birdversfolder = $birdrootfolder & "\" & $version If Not FileExists($birdversfolder) Then $nversion = GetNVersion($version) $birdversfolder = $birdrootfolder & "\" & $nversion If Not FileExists($birdversfolder) Then AbortMessage("ERROR", "bird version not found:" & @LF & $version) EndIf EndIf $args = $birdjavaheap & " -jar """ & $birdversfolder & "\" & $birdjar & """" Return $args EndFunc Func GetNVersion($version) Return StringReplace(StringReplace($version, ".", "v", 1), ".", "_") EndFunc Func GetVersion($nversion) Return StringReplace(StringReplace($nversion, "v", ".", 1), "_", ".") EndFunc FUNC RunChecker($version) Local $cnt, $run = False For $cnt = 1 To $checkversion_cnt If $version = $checkversions[$cnt] Then $RunChecker[$cnt] = True $run = True EndIf Next If $run = False Then Message("ERROR", "VAX checker version " & $version & " is not available") EndIf Return EndFunc Func CheckEnvironment() If Not FileExists($birdjavaexe) Then AbortMessage("ERROR", "java executable for bird not found:" & @LF & $birdjavaexe) EndIf If Not FileExists($birdrootfolder) Then AbortMessage("ERROR", "bird installation root not found:" & @LF & $birdrootfolder) EndIf If $odxjar_cnt = 0 Then AbortMessage("ERROR", "jar libraries for ODX generation not found in folder:" & @LF & $odxjarfolder) EndIf If Not FileExists($indexlib) Then AbortMessage("ERROR", "jar library for index generation not found:" & @LF & $indexlib) EndIf Return EndFunc Func CheckBirdInstallation() ; 1st look for local installation, then for I, then for toolbase ;$birdpaths = ".\BIRD\Bird|\\si6245\k3_pc\Programme\K3Util\Freigabe\Tools\Bird|C:\toolbase\bird|\\bosch.com\dfsrb\DfsDE\LOC\Si\GS\SDE\Mx17\tme17_appl\Programme\Tools\Bird" Local $birdjavaversionpath = "" $birdtoolfolder = CheckPaths($workfolder, $birdpaths) If $birdtoolfolder = "" Then AbortMessage("ERROR", "No BIRD installation found at:" & @LF & StringReplace($birdpaths,"|",@LF) & @LF & "check ini file!") Else $birdjavaversionpath = CheckPaths($birdtoolfolder, $birdjavaversionpaths) $birdjavaexe = $birdjavaversionpath & "\bin\java.exe" If ($birdjavaversionpath = "") Or (Not FileExists($birdjavaexe)) Then AbortMessage("ERROR", "No Java installation for BIRD found at: " & @LF & StringReplace($birdjavaversionpaths,"|",@LF) & @LF & "check ini file!") EndIf EndIf $birdrootfolder = $birdtoolfolder ;Fn Local $birdpathlist = StringSplit($birdpaths,"|") ; Local $versionfound = False ; For $birdpathcnt = 1 To $birdpathlist[0] ; If StringLeft($birdpathlist[$birdpathcnt],1) = "." Then ; $birdtoolfolder = $workfolder & "\" & $birdpathlist[$birdpathcnt] ; StringRight($birdpathlist[$birdpathcnt],StringLen($birdpathlist[$birdpathcnt])-1) ; Else ; $birdtoolfolder = $birdpathlist[$birdpathcnt] ; EndIf ; If FileExists($birdtoolfolder) Then ; If FileExists($birdtoolfolder & "\java") Then ; $birdjavaexe = $birdtoolfolder & $javapath ; ElseIf FileExists($birdtoolfolder & "\..\java") Then ; $birdjavaexe = $birdtoolfolder & "\.." & $javapath ; Else ; AbortMessage("ERROR", "No JAVA installation found") ; EndIf ; If FileExists($birdjavaexe) Then ; $birdrootfolder = $birdtoolfolder ; $versionfound = True ; ExitLoop ; Else ; AbortMessage("ERROR", "JAVA version for BIRD not found" ) ; EndIf ; EndIf ; Next ; If Not $versionfound Then ; AbortMessage("ERROR", "No BIRD installation found") ; EndIf ;Fn $birdtoolfolder = $workfolder & "\BIRD\Bird" ; $birdjavaexe = $birdtoolfolder & "\Java\1.5.0_07\bin\java.exe" ; If FileExists($birdjavaexe) Then ; $birdrootfolder = $birdtoolfolder ; $birddotversion = False ; Else ; $birdtoolfolder = "\\si6245\k3_pc\Programme\K3Util\Freigabe\Tools\Bird" ; "\\bosch.com\dfsrb\DfsDE\LOC\Si\GS\SDE\Mx17\tme17_appl\Programme\Tools\Bird" ; $birdjavaexe = $birdtoolfolder & "\Java\1.5.0_07\bin\java.exe" ; If FileExists($birdjavaexe) Then ; $birdrootfolder = $birdtoolfolder ; $birddotversion = False ; Else ; $birdtoolfolder = "C:\toolbase\bird" ; $birdjavaexe = $birdtoolfolder & "\..\java\1.5.0_07\bin\java.exe" ; If FileExists($birdjavaexe) Then ; $birdrootfolder = $birdtoolfolder ; $birddotversion = True ; Else ; AbortMessage("ERROR", "No BIRD installation found") ; EndIf ; EndIf ; EndIf Return EndFunc Func CheckCheckerInstallation() ; must be called after CheckBirdInstallation becasue java path mightr be used If $checkerjavaversionpaths = "" Then ; if not specified in ini file use bird java $checkerjavaexe = $birdjavaexe Else $checkerjavaversionpath = CheckPaths($workfolder, $checkerjavaversionpaths) $checkerjavaexe = $checkerjavaversionpath & "\bin\java.exe" If Not FileExists($checkerjavaexe) Then Message("WARNING", "No Java installation for checker found at:" & @LF & StringReplace($checkerjavaversionpaths,"|",@LF) & @LF & "check ini file!" & @LF & "java version for bird will be used") Else $checkerjavaexe = $birdjavaexe EndIf EndIf Return EndFunc Func CheckBirdConfiguration() Local $birdcustfolder = $workfolder & "\" & $libversion $odxjarfolder = $birdcustfolder & "\_bin" If Not FileExists($odxjarfolder) Then Message("ERROR", "BIRD _bin folder does not exist:" & @LF & $odxjarfolder) EndIf $odxjars = FindFiles($odxjarfolder, "*.jar", False) $odxjar_cnt = $odxjars[0] $indexlib = $odxjarfolder & "\" & "Admin.jar" $conffolder = $birdcustfolder & "\_conf" If Not FileExists($conffolder) Then Message("ERROR", "BIRD _conf folder does not exist:" & @LF & $conffolder) EndIf Return EndFunc Func SetPrio() ; set process priority to "BELOW_NORMAL" Local $_procname = StringLeft(@ScriptName, 15) Local $_proclist = ProcessList($_procname) Local $_proccnt For $_proccnt = 1 To $_proclist[0][0] ; change process priority for all processes ... ProcessSetPriority($_proclist[$_proccnt][1], 1) ; 1 = BELOW_NORMAL Next Return EndFunc Func WriteDataFileArgs($filehandle, $rbdatafolder, $pattern) Local $rbdatafiles $rbdatafiles = FindFiles($rbdatafolder, $pattern, False) For $cnt = 1 To $rbdatafiles[0] $line = CreateBirdDataArgument ($rbdatafolder, $rbdatafiles[$cnt], "") If Not($line = "") Then FileWriteLine($filehandle, $line) EndIf Next Return EndFunc Func Preparation() $logfile = $outfolder & $logname If Not FileExists($custfolder) Then AbortMessage("ERROR", "customer folder does not exist:" & @LF & $custfolder) EndIf Global $inifile = $inifolder & "\odx4vag-actual.ini" If Not FileExists($inifile) Then AbortMessage("USAGE", "Initialization file not found:" & @LF & $inifile) EndIf $inihandle = FileOpen($inifile, 0) If $inihandle < 0 Then AbortMessage("USAGE", "Initialization file not readable" & @LF & $inifile) EndIf While 1 $line = FileReadLine($inihandle) If @error Then ExitLoop If StringLeft($line,1) = "-" Then ; direct ODX argument AddArg($line) ElseIf StringLeft($line,1) = "/" Then $parts = StringSplit($line,"=") If Not ($parts[0] = 2) Then Message("USAGE", "Improper format (number of ""="" must be 1) of init value - value will be ignored" & @LF & $line) Else $keyword = $parts[1] Select Case $keyword = "/odx4vagversion" $odx4vagversion = $parts[2] Case $keyword = "/template" $template = $parts[2] Case $keyword = "/birdversion" $birdversion = $parts[2] Case $keyword = "/birdpaths" $birdpaths = $parts[2] Case $keyword = "/birdjavaversionpaths" $birdjavaversionpaths = $parts[2] Case $keyword = "/libversion" $libversion = $parts[2] Case $keyword = "/checkerjavaversionpaths" $checkerjavaversionpaths = $parts[2] Case $keyword = "/checkversion" $checkversion = $parts[2] Case $keyword = "/winzippaths" $winzippaths = $parts[2] Case $keyword = "/a2lpaths" $a2lpaths = $parts[2] Case $keyword = "/ccepaths" $ccepaths = $parts[2] Case $keyword = "/cbpaths" $cbpaths = $parts[2] Case $keyword = "/dcmpaths" $dcmpaths = $parts[2] Case $keyword = "/pdxsymbolics" $pdxsymbolics = $parts[2] Case $keyword = "/masterslavesysconst" $masterslavesysconst = $parts[2] Case $keyword = "/customerfiles" $customerfiles = $parts[2] Case $keyword = "/customersymbolics" $customersymbolics = $parts[2] Case $keyword = "/customerargs" $customerargs = $parts[2] Case $keyword = "/customerpdx" $customerpdx = $parts[2] Case $keyword = "/supportbugfix" $supportbugfix = $parts[2] Case Else Message("USAGE", "Improper keyword """ & $keyword & """ of init value - value will be ignored" & @LF & $line) EndSelect EndIf Else Message("USAGE", "Improper format (start character must be ""/"" or ""-"") of argument - argument will be ignored" & @LF & $line) EndIf Wend ; If $supportbugfix = 1 Then Global $gui_max_line_no = 21 Else Global $gui_max_line_no = 17 EndIf $templatefile = $workfolder & "\"& $libversion & "\_conf\template\" & $template ;fj build path for template file If Not (FileExists($templatefile)) Then ;fj $templatefile = FindLastFile($conffolder & "\template", "Template_*.odx") AbortMessage("ERROR", "template file not found :" & $templatefile);fj EndIf $winzippath = CheckPaths($workfolder, $winzippaths) If ($winzippath = "") Or (Not FileExists($winzippath & "\wzzip.exe")) Or (Not FileExists($winzippath & "\wzunzip.exe")) Then AbortMessage("ERROR", "No WINZIP installation found at:" & @LF & StringReplace($winzippaths,"|",@LF) & @LF & "check ini file!") EndIf CheckCustomerFolder() CheckBirdInstallation() CheckCheckerInstallation() CheckBirdConfiguration() CheckEnvironment() RunChecker($checkversion) BatchMessage("VERSION", "BIRD:" & $birdversion & @LF & "Library:" & $libversion & @LF & "ODX4VAG:" & $odx4vagversion) Return EndFunc Func CheckFilePattern($base, $paths, $pattern) Local $pathlist = StringSplit($paths, "|") Local $cnt Local $first = "" Local $onepath Local $filelist For $cnt = 1 To $pathlist[0] $onepath = MakeAbsolutePath($base, $pathlist[$cnt]) $filelist = FindFiles($onepath, $pattern, True) If $filelist[0] > 0 Then ; exit if one or more files found If $filelist[0] = 1 Then ; valid return file only if unique match $first = $onepath & "\" & $filelist[1] EndIf ExitLoop EndIf Next Return $first EndFunc Func CheckPaths($base, $paths) Local $pathlist = StringSplit($paths, "|") Local $cnt Local $first = "" Local $onepath For $cnt = 1 To $pathlist[0] $onepath = MakeAbsolutePath($base, $pathlist[$cnt]) If FileExists($onepath) Then $first = $onepath ExitLoop EndIf Next Return $first EndFunc Func MakeAbsolutePath($base, $path) Local $abspath = $path If IsRelativePath($path) Then If StringLeft($path, 1) = "\" Then $abspath = $base & $path Else $abspath = $base & "\" & $path EndIf EndIf $abspath = _PathFull($abspath) Return $abspath EndFunc Func IsRelativePath($path) Local $rel = True If (StringLeft($path,2) = "\\") Or (StringMid($path,2,1) = ":") Then $rel = False EndIf Return $rel EndFunc Func RemovePath($file) Local $parts = StringSplit($file, "\") Return $parts[$parts[0]] EndFunc Func CheckCustomerFile($index, $name) If Not StringInStr("|" & $customerfileselections[$index] & "|", "|" & $name & "|") Then If StringInStr("|" & $customerfileforbiddens[$index] & "|", "|" & $name & "|") Then If $releasetype = "SERIES" Then AbortMessage("ERROR", "customer delivered " & $customerfilelist[$index] & " file """ & $name & """ is not allowed for this version " & $odx4vagversion & " for a SERIES release") Else Message("WARNING", "customer delivered " & $customerfilelist[$index] & " file """ & $name & """ is not allowed for this version " & $odx4vagversion) EndIf Else AbortMessage("ERROR", "customer delivered " & $customerfilelist[$index] & " file """ & $name & """ is not supported") EndIf ; Else ; Message("SUPPORT", "customer delivered " & $customerfilelist[$index] & " file """ & $name & """ is supported by this version " & $odx4vagversion) EndIf EndFunc