[已解決]如何讓每一欄的第5格, 每10分鐘檢查一次值, 沒有更新成不一樣的值就回報錯誤?
本帖最后由 ipmitool 于 2016-6-16 07:44 编辑請問各位大師, 如何讓每一欄的第5格, 每10分鐘內檢查一次值, "沒有更新"成不一樣的值就回報 error?
1.txt
sdfasdfsadf
asdadfasdfasdfa
sdfs!ER#$@sdfasdfsa
dfasda
dfasdfasdfas
2.txt
sdfasdfsad@
fasdadfasdfasdf
asdfs!ER#$@sdfasdfs
adfasdadfasdfasdfas
sdfasdfsadfasdadfasdfasdfasdfs!ER#$@sdfasdfsadfasdadfasdfasdfas
3.txt
sdfsdfsf@w32
dsfgsg@dvsfgds
advsfgfhnjt5
Sdsdfgdgdgh
dsfw43@wrgt35y45@jmryjr
4.txt
advfssfdfbg5324353@wr535t3y
ergergy43@243453
@Vadgwrgwg
VDsaf
gryjhr
#include <Array.au3>
#include <File.au3>
#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
;#include <MsgBoxConstants.au3>
GUICreate("ListView Add Array", 800, 300)
$idListview = GUICtrlCreateListView("", 2, 2, 394, 268)
GUISetState(@SW_SHOW)
_GUICtrlListView_AddColumn($idListview, "Tester", 100)
_GUICtrlListView_AddColumn($idListview, "Test Item", 100)
_GUICtrlListView_AddColumn($idListview, "BMC IP", 100)
_GUICtrlListView_AddColumn($idListview, "Count", 100)
_GUICtrlListView_AddColumn($idListview, "Last Record Time", 100)
_GUICtrlListView_SetItemCount($idListview, 5000)
_add_lv_items()
AdlibRegister('_add_lv_items', 5000); 5秒刷新数据
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
GUIDelete()
Func _add_lv_items()
Local $path, $aFileList, $aNewList
$path = @ScriptDir
$aFileList = _FileListToArray($path, "*.txt")
If IsArray($aFileList) Then
ReDim $aNewList ;;;
For $i = 0 To UBound($aFileList) - 1 Step 1
$aNewList[$i] = $aFileList[$i]
$aNewList[$i] = FileReadLine($aFileList[$i], 1)
$aNewList[$i] = FileReadLine($aFileList[$i], 2)
$aNewList[$i] = FileReadLine($aFileList[$i], 3)
$aNewList[$i] = FileReadLine($aFileList[$i], 4)
Next
_GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($idListview))
_GUICtrlListView_AddArray($idListview, $aNewList)
EndIf
EndFunc 各位大哥大姊, 有沒有辦法處理阿...我想不出來... 回复 2# ipmitool
你不是檢查 寫出來了嗎
每10分鐘檢查一次 就
AdlibRegister('_add_lv_items', 5000);
註冊10分鐘 檢查一次呀 回复 3# kk_lee69
大哥, 我是要10分鐘檢查到都沒有更新字串的話, 要回報錯誤, 這樣要怎麼做啊? 回复 4# ipmitool
檢查有沒有更新 是不是 要 先找個地方放 原來的
可設陣列 或者 設變數存放 也可以 放在 文字檔裡面
然後AdlibRegister 註冊10分鐘跑一次 函數
取直比對不就是這樣嗎?? 小弟新手...望大哥寫個範例...嗚.... 回复 6# ipmitool
http://www.autoitx.com/forum.php?mod=viewthread&tid=23155&highlight=%BC%E0%BF%D8
http://www.autoitx.com/search.php?searchid=170&orderby=lastpost&ascdesc=desc&searchsubmit=yes&page=2 馬蓋仙, $LVN_ITEMCHANGE 要如何監控listview裡面的值有沒有變動啊? 本帖最后由 kk_lee69 于 2016-6-13 11:57 编辑
回复 8# ipmitool
你 列出 你目前寫的程式 看看
你要把你的程式 簡化掉 重點在於你不懂的部分做個簡單的範例就好....
別人是無法去了解你的環境跟系統 最好 提供的 程式就是 簡單的複製 貼上就可以用的
你原本 提供的 還有 1.TXT2.TXT這樣的 方式 太麻煩了..... 有點在亂寫了...#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>
#include <WindowsConstants.au3>
#include <Array.au3>
#include <File.au3>
;Local $GUI, $hImage, $iITEM_COUNT = 10000
GUICreate("Test Management v1.0", 1060, 410)
$hListView = GUICtrlCreateListView("", 5, 5, 1050, 345, $LVS_SHOWSELALWAYS, $LVS_EX_GRIDLINES + $LVS_EX_FULLROWSELECT + $LVS_EX_DOUBLEBUFFER)
;===================================================================
$Button1 = GUICtrlCreateButton("ReportData", 200, 362, 73, 33)
$Button2 = GUICtrlCreateButton("Complete", 300, 362, 73, 33)
$Button3 = GUICtrlCreateButton("Clear", 800, 362, 73, 33)
$PowerReset = GUICtrlCreateButton("Power Reset", 500, 362, 73, 33)
$SerialOverLan = GUICtrlCreateButton("SOL", 600, 362, 73, 33)
;$stopreportflash = GUICtrlCreateButton("Stopreportflash", 200, 392, 73, 33)
;$stopcompleteflash = GUICtrlCreateButton("Stopcompleteflash", 300, 392, 73, 33)
;===================================================================
GUISetState()
;GUISetState(@SW_SHOW)
_GUICtrlListView_AddColumn($hListView, "File Name", 0) ;disappear file name
_GUICtrlListView_AddColumn($hListView, "Test Case", 70)
_GUICtrlListView_AddColumn($hListView, "Product", 80)
_GUICtrlListView_AddColumn($hListView, "Serial", 90)
_GUICtrlListView_AddColumn($hListView, "BIOS", 40)
_GUICtrlListView_AddColumn($hListView, "BMC", 40)
_GUICtrlListView_AddColumn($hListView, "Count", 60)
_GUICtrlListView_AddColumn($hListView, "Status", 60)
_GUICtrlListView_AddColumn($hListView, "LOG err", 50)
_GUICtrlListView_AddColumn($hListView, "BMC err", 50)
_GUICtrlListView_AddColumn($hListView, "SDR err", 50)
_GUICtrlListView_AddColumn($hListView, "Sensor err", 65)
_GUICtrlListView_AddColumn($hListView, "BMC IP", 90)
_GUICtrlListView_AddColumn($hListView, "Tester", 50)
_GUICtrlListView_AddColumn($hListView, "Remind Time", 80)
_GUICtrlListView_AddColumn($hListView, "Upload Time", 120)
_GUICtrlListView_SetItemCount($hListView, 5000)
While 1
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") ;Double click value get
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
ExitLoop
Case $Button1
AdlibUnRegister('_add_complete_items')
_add_report_items()
AdlibRegister('_add_report_items', 5000);reflash every 10sec
Case $Button2
AdlibUnRegister('_add_report_items')
_add_complete_items()
AdlibRegister('_add_complete_items', 5000);reflash every 10sec
; Case $stopreportflash
; AdlibUnRegister('_add_report_items')
; Case $stopcompleteflash
; AdlibUnRegister('_add_complete_items')
Case $Button3
MsgBox(0,"123","456",0)
Case $PowerReset
Run("PowerReset.exe")
Case $SerialOverLan
Run("SOL.exe")
EndSwitch
WEnd
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
GUIDelete()
Exit
Func _add_report_items()
;_GUICtrlListView_SetHoverTime($hListView,6000)
;MsgBox($MB_SYSTEMMODAL, "Information", "Hover Time (milliseconds): " & _GUICtrlListView_GetHoverTime($hListView))
FileChangeDir("\\192.8.1.1\fs1\1")
Local $path, $aFileList, $aNewList
$path = "\\192.8.1.1\fs1\1"
$aFileList = _FileListToArray($path, "*.txt")
If IsArray($aFileList) Then
ReDim $aNewList ;;;
For $i = 0 To UBound($aFileList) - 1 Step 1
$aNewList = $i
;$aNewList[$i] = $aFileList[$i]
$aNewList[$i] = FileReadLine($aFileList[$i], 1)
$aNewList[$i] = FileReadLine($aFileList[$i], 2)
$aNewList[$i] = FileReadLine($aFileList[$i], 3)
$aNewList[$i] = FileReadLine($aFileList[$i], 4)
$aNewList[$i] = FileReadLine($aFileList[$i], 5)
$aNewList[$i] = FileReadLine($aFileList[$i], 6)
$aNewList[$i] = FileReadLine($aFileList[$i], 7)
$aNewList[$i] = FileReadLine($aFileList[$i], 8)
$aNewList[$i] = FileReadLine($aFileList[$i], 9)
$aNewList[$i] = FileReadLine($aFileList[$i], 10)
$aNewList[$i] = FileReadLine($aFileList[$i], 11)
$aNewList[$i] = FileReadLine($aFileList[$i], 12)
$aNewList[$i] = FileReadLine($aFileList[$i], 13)
$aNewList[$i] = FileReadLine($aFileList[$i], 14)
$aNewList[$i] = FileReadLine($aFileList[$i], 15)
;$change1=FileReadLine($aFileList[$i], 1)
Next
_GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($hListView))
_GUICtrlListView_AddArray($hListView, $aNewList)
EndIf
EndFunc
Func _add_complete_items()
FileChangeDir("\\192.8.1.1\fs1\2")
Local $path, $aFileList, $aNewList
$path = "\\192.8.1.1\fs1\2"
$aFileList = _FileListToArray($path, "*.txt")
If IsArray($aFileList) Then
ReDim $aNewList ;;;
For $i = 0 To UBound($aFileList) - 1 Step 1
$aNewList = $i
;$aNewList[$i] = $aFileList[$i]
$aNewList[$i] = FileReadLine($aFileList[$i], 1)
$aNewList[$i] = FileReadLine($aFileList[$i], 2)
$aNewList[$i] = FileReadLine($aFileList[$i], 3)
$aNewList[$i] = FileReadLine($aFileList[$i], 4)
$aNewList[$i] = FileReadLine($aFileList[$i], 5)
$aNewList[$i] = FileReadLine($aFileList[$i], 6)
$aNewList[$i] = FileReadLine($aFileList[$i], 7)
$aNewList[$i] = FileReadLine($aFileList[$i], 8)
$aNewList[$i] = FileReadLine($aFileList[$i], 9)
$aNewList[$i] = FileReadLine($aFileList[$i], 10)
$aNewList[$i] = FileReadLine($aFileList[$i], 11)
$aNewList[$i] = FileReadLine($aFileList[$i], 12)
$aNewList[$i] = FileReadLine($aFileList[$i], 13)
$aNewList[$i] = FileReadLine($aFileList[$i], 14)
$aNewList[$i] = FileReadLine($aFileList[$i], 15)
Next
_GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($hListView))
_GUICtrlListView_AddArray($hListView, $aNewList)
EndIf
EndFunc
Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
#forceref $hWnd, $iMsg, $iwParam
Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo
$hWndListView = $hListView
If Not IsHWnd($hListView) Then $hWndListView = GUICtrlGetHandle($hListView)
$hWndListView = GUICtrlGetHandle($hListView)
$tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
$hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
$iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
$iCode = DllStructGetData($tNMHDR, "Code")
Switch $hWndFrom
Case $hWndListView
Switch $iCode
Case $NM_DBLCLK
$tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
$Index= DllStructGetData($tInfo, "Index")
$DoubleClick = _GUICtrlListView_GetItemText($hListView, $Index,12)
;MsgBox(0, 'Connect SOL to BMC IP', _GUICtrlListView_GetItemText($hListView, $Index,12))
Run("cmd.exe")
sleep(500)
WinActivate("Administrator: C:\Windows\system32\cmd.exe")
sleep(500)
send("cd \TestStatusManagement\ipmitool_1.8.11\")
sleep(500)
Send("{ENTER}")
sleep(500)
Send("ipmitool.exe -I lanplus -H "&$DoubleClick&" -U admin -P admin sol deactivate")
sleep(500)
Send("{ENTER}")
sleep(500)
Send("ipmitool.exe -I lanplus -H "&$DoubleClick&" -U admin -P admin sol activate")
sleep(500)
Send("{ENTER}")
Case $LVN_ITEMCHANGED ; An item has changed
$tInfo = DllStructCreate($tagNMLISTVIEW, $ilParam)
$Index= DllStructGetData($tInfo, "Index")
$DoubleClick = _GUICtrlListView_GetItemText($hListView, $Index,12)
_DebugPrint("$LVN_ITEMCHANGED" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
"-->IDFrom:" & @TAB & $iIDFrom & @LF & _
"-->Code:" & @TAB & $iCode & @LF & _
"-->Test Case" & @TAB & DllStructGetData($hListView, "Test Case") & @LF & _
"-->SubItem:" & @TAB & DllStructGetData($hListView, "SubItem") & @LF & _
"-->NewState:" & @TAB & DllStructGetData($hListView, "NewState") & @LF & _
"-->OldState:" & @TAB & DllStructGetData($hListView, "OldState") & @LF & _
"-->Changed:" & @TAB & DllStructGetData($hListView, "Changed") & @LF & _
"-->ActionX:" & @TAB & DllStructGetData($hListView, "ActionX") & @LF & _
"-->ActionY:" & @TAB & DllStructGetData($hListView, "ActionY") & @LF & _
"-->Param:" & @TAB & DllStructGetData($hListView, "Param"))
MsgBox(0,"123",$hListView,0)
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc
Func _DebugPrint($s_text, $line = @ScriptLineNumber)
ConsoleWrite( _
"!===========================================================" & @LF & _
"+======================================================" & @LF & _
"-->Line(" & StringFormat("%04d", $line) & "):" & @TAB & $s_text & @LF & _
"+======================================================" & @LF)
;MsgBox(0,"123","456",0)
EndFunc 回复 10# ipmitool
#include <GuiListView.au3>
#include <WindowsConstants.au3>
#include <GuiConstantsEx.au3>
GUICreate('', 400, 400)
$ListView1 = GUICtrlCreateListView('1', 5, 5, 390, 280)
_GUICtrlListView_SetColumnWidth($ListView1, 0, 380)
$BUTTON1=GUICtrlCreateButton("點我改變值",100,350,100,20)
$BUTTON2=GUICtrlCreateButton("點我改變值",250,350,100,20)
;改變 第幾筆資料
$IT=3
For $i = 1 To 10
GUICtrlCreateListViewItem('?目 - ' & $i, $ListView1)
Next
GUISetState()
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
While 1
Switch GUIGetMsg()
Case -3
Exit
Case $BUTTON1
_GUICtrlListView_SetItemText($ListView1,$IT,"改變",0)
Case $BUTTON2
_GUICtrlListView_SetItemText($ListView1,$IT+3,"改變",0)
EndSwitch
WEnd
Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
$tNMTV = DllStructCreate($tagNMTVDISPINFO, $ilParam)
$iCode = DllStructGetData($tNMTV, "Code")
$iIndex = GUICtrlRead($ListView1)
Switch $iCode
Case $LVN_ITEMCHANGED
$tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
$iIndex = DllStructGetData($tInfo, "Index")
$iSub = DllStructGetData($tInfo, "SubItem")
MsgBox(0,"項目改變","第 "&$iIndex&" 的"&$iSub&" 子項 發生變化" )
EndSwitch
$tNMTV = 0
EndFunc ;==>WM_NOTIFY 回复 1# ipmitool
剛剛再仔細的看了一下 你的 程式 覺得邏輯有點怪??
首先 你是 用 每隔五秒 搜尋所有的文字檔案然後轉換成 陣列 然後秀在 LISTVIEW 上面
那請問所謂的所謂的 每10分鐘檢查一次 沒有更新成 不一樣的 是跟誰比呢??
8點的時候 讀取了 第一次的資料8點 05秒的時候 讀取的第二次的資料 8點10秒的時候 讀取了第三次的資料
8點10分 檢查的時候是跟 8點5秒的資料比還是 跟 8點10秒的資料比呢??? 回复 1# ipmitool
让ListView的第5格, 每10分钟內检查一次值, "沒有更新"成不一样的值就回报
我的想法:
1:读取ListView的第5格,将值写入X.ini
2:过10分钟检查一次值,再次读取ListView的第5格的值。
3:读取X.ini与再次读取ListView的第5格的值比对。
4:比对如是不同值,写入X.ini。比对是相同就不写入X.ini。 8點10秒 檢查的時候是跟 listview 倒數第二次做比較, 可能要有個地方暫時存放倒數第二次的資料... 回复 13# chzj589
除非 他的邏輯 是 10分鐘的檢查 與 5秒的 更新是 分開的
不然照理說五秒的時候 得更新 前一個五秒的狀態值 才對
也就是 每五秒 應該寫入 INI 檔那 10分鐘後 的檢查 會變得沒意義因為他永遠只能跟前五秒的值 相比