Je m'explique, chaque station a un fichier sur un serveur et à chaque cycle, elles viennent écrire dedans.
Je réussi à définir quelle station est la plus longue mais il faudrait que je gère les erreurs d'accès au fichier sur serveur (éviter de lire pendant que la station écrit dedans ou autre cas...)...
Je joins mon code, merci par avance pour votre aide.
PS: Dites moi si le programme est convenablement structuré...
Merci par avance.
► Afficher le texte
Code : Tout sélectionner
;==[ Les Includes ]====
#include <Array.au3>
#include <FileListToArrayNT.au3>
#include <File.au3>
#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <ButtonConstants.au3>
#include <ListViewConstants.au3>
#include <StructureConstants.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>
#include <FontConstants.au3>
#include <Constants.au3>
#include <Date.au3>
Opt("GUICoordMode", 1)
HotKeySet("{ESC}", "Terminate")
AdLibRegister("_CheckCycleTime", 5500)
Global $hGUI, $hGUI2, $hListView, $NumberOfNestCell56 = 7, $CycleTimeTargetIni
;$CycleTimeTarget[1][1] = Temps de cycle cible contenu dans le fichier CycleTime.ini
Func _CheckCycleTime()
If WinExists ($hGUI) Then GUIDelete($hGUI)
$CycleTimeTargetIni = IniReadSection("CycleTime.ini", "CycleTimeTarget")
If @error Then
Exit
Else
$CycleTimeTarget = $CycleTimeTargetIni[1][1]
EndIf
;==[ On cherche les fichiers *.dat]====
$DATArray = _FileListToArrayNT (@WorkingDir, "*.dat", 1, 0, True, "")
;==[ Options _FileListToArrayNT ]====
;$sPath : Chemin de recherche
;$sFilter : Filtres de recherches (multiples filtres acceptés - caractères génériques et multi-fichiers séparés par un point virgule)
;$iSearchType : 0 = Retourne fichier et répertoire (défaut), 1 = Retourne que les fichiers, 2 = Retourne que les répertoires.
;$iPathType : Format des éléments renvoyés : 0 = Seulement le nom fichier/dossier (défaut), 1 = Chemin relatif, 2 = Chemin complet
;$bRecursive : Recherche récursive : False = Non (défaut), True = Oui
;$sExclude : Liste des exclusions, séparées par un point virgule.
;$iRetFormat : Format de renvoi du résultat. 0 = Tableau base 0, 1 = Tableau base 1 (défaut), 2 = Chaîne (délimitée par "|")
Local $aRecords
Local $HelpArray[Ubound($DATArray)-1][4]
Local $j = 0
For $i = 1 to Ubound($DATArray) - 1
$DATFile = _FileReadToArray(@WorkingDir & "\" & $DATArray[$i], $aRecords)
Local $CellNumber = StringSplit(StringReplace($aRecords[4], " ", ""), ":", 2)
If $CellNumber[1] = "44" Or $CellNumber[1] = "46" Or $CellNumber[1] = "62" Or $CellNumber[1] = "64" Then
Local $CellNumber = StringSplit(StringReplace($aRecords[4], " ", ""), ":", 2)
$HelpArray[$i-1][0] = $CellNumber[1]
Local $CellName = StringSplit(StringReplace($aRecords[5], " ", ""), ":", 2)
$HelpArray[$i-1][1] = $CellName[1]
Local $PartNrVar = StringSplit(StringReplace($aRecords[10], " ", ""), ":", 2)
$HelpArray[$i-1][2] = $PartNrVar[1]
Local $MeanCycleTime = StringSplit(StringReplace($aRecords[28], " ", ""), ":", 2)
$HelpArray[$i-1][3] = $MeanCycleTime[1] / 2
ElseIf $CellNumber[1] = "5601" Or $CellNumber[1] = "5602" Or $CellNumber[1] = "5603" _
Or $CellNumber[1] = "5604" Or $CellNumber[1] = "5605" Or $CellNumber[1] = "5606" _
Or $CellNumber[1] = "5607" Or $CellNumber[1] = "5608" Then
Local $CellNumber = StringSplit(StringReplace($aRecords[4], " ", ""), ":", 2)
$HelpArray[$i-1][0] = $CellNumber[1]
Local $CellName = StringSplit(StringReplace($aRecords[5], " ", ""), ":", 2)
$HelpArray[$i-1][1] = $CellName[1]
Local $PartNrVar = StringSplit(StringReplace($aRecords[10], " ", ""), ":", 2)
$HelpArray[$i-1][2] = $PartNrVar[1]
Local $MeanCycleTime = StringSplit(StringReplace($aRecords[28], " ", ""), ":", 2)
$HelpArray[$i-1][3] = Round($MeanCycleTime[1] / $NumberOfNestCell56, 3)
Else
Local $CellNumber = StringSplit(StringReplace($aRecords[4], " ", ""), ":", 2)
$HelpArray[$i-1][0] = $CellNumber[1]
Local $CellName = StringSplit(StringReplace($aRecords[5], " ", ""), ":", 2)
$HelpArray[$i-1][1] = $CellName[1]
Local $PartNrVar = StringSplit(StringReplace($aRecords[10], " ", ""), ":", 2)
$HelpArray[$i-1][2] = $PartNrVar[1]
Local $MeanCycleTime = StringSplit(StringReplace($aRecords[28], " ", ""), ":", 2)
$HelpArray[$i-1][3] = $MeanCycleTime[1]
EndIf
$j = $j+1
Next
;_ArrayDisplay($HelpArray)
Local $ValMax = 0
For $i = 0 To UBound($HelpArray) - 1
If Number($ValMax) < Number($HelpArray[$i][3]) Then
$ValMax = $HelpArray[$i][3]
$CellNumber = $HelpArray[$i][0]
$CellName = $HelpArray[$i][1]
$MaxCycleTime = $ValMax
EndIf
Next
$hGUI = GUICreate("", @DesktopWidth, 110, 0, (@DesktopHeight / 2) - 160, $WS_POPUP, $WS_EX_LAYERED)
GUISetBkColor(0xABCDEF)
_WinAPI_SetLayeredWindowAttributes($hGUI, 0xABCDEF)
GUISetState(@SW_SHOW, $hGUI)
$hGUI2 = GUICreate("", @DesktopWidth, 130, 10, 10, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $hGUI)
GUISetBkColor(0xABCDEF)
$hListView = GUICtrlCreateListView("Station|Nom|Temps", 2, 2, @DesktopWidth, 110, BitOR($LVS_SHOWSELALWAYS, $LVS_NOCOLUMNHEADER), $WS_EX_TRANSPARENT)
GUICtrlSetFont($hListView, 32, 200, 0, "Tahoma", 22)
GUICtrlSetBkColor(-1, 0xABCDEF)
_WinAPI_SetLayeredWindowAttributes($hGUI2, 0xABCDEF)
_GUICtrlListView_AddItem($hListView, $CellNumber, 0)
_GUICtrlListView_AddSubItem($hListView, 0, $CellName, 1)
_GUICtrlListView_AddSubItem($hListView, 0, $MaxCycleTime & "s", 2)
_GUICtrlListView_SetColumnWidth($hListView, 0, $LVSCW_AUTOSIZE)
_GUICtrlListView_SetColumnWidth($hListView, 1, $LVSCW_AUTOSIZE)
_GUICtrlListView_SetColumnWidth($hListView, 2, $LVSCW_AUTOSIZE)
GUISetState(@SW_SHOW, $hGUI2)
If $MaxCycleTime > $CycleTimeTarget Then
_GUICtrlListView_SetTextColor($hListView, $CLR_RED)
Else
_GUICtrlListView_SetTextColor($hListView, $CLR_GREEN)
EndIf
If $CellName = "5601" Or $CellName = "5602" Or $CellName = "5603" _
Or $CellName = "5604" Or $CellName = "5605" Or $CellName = "5606" _
Or $CellName = "5607" Or $CellName = "5608" Then
$MaxCycleTime = $MaxCycleTime
ElseIf $CellName = "44" Or $CellName = "46" Or $CellName = "62" Or $CellName = "64" Then
$MaxCycleTime = $MaxCycleTime * 2
EndIf
EndFunc
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
GUIDelete()
Func Terminate()
Exit
EndFunc



