找回密码
 加入
搜索
楼主: ipmitool

[AU3基础] [已解決]如何讓每一欄的第5格, 每10分鐘檢查一次值, 沒有更新成不一樣的值就回報錯誤?

 火.. [复制链接]
发表于 2016-6-13 22:17:20 | 显示全部楼层
回复 30# ipmitool

数组变量已经超过了标或下标尺寸范围的数量不正确。

沒有環境無法測試 ....無法幫你  你得 從 數組 賦值  方面下手 看看是否有問題
发表于 2016-6-13 22:38:56 | 显示全部楼层
回复 26# ipmitool


    60 行 沒人 把  GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") ;Double click value get

放在  While 1 裡面 一直在重複註冊個幾千次 幾萬次
--------------------------------------------------------------------
有 While 1 怎麼又要
Do
Until
------------------------------------------------------
 楼主| 发表于 2016-6-14 10:43:16 | 显示全部楼层
回复 32# kk_lee69


謝謝表哥, 現在出現另一個問題, 第306跟309行, 要如何讓on-line off-line的字串顯示在每一行status欄位上面啊? 謝謝表哥

IF $OldList[$j][4]=$aNewList2[$j][4] THEN
;MsgBox (0,"10分鐘檢查","10 分鐘到了 第"&($j+1)&"筆 資料沒有更新")
_GUICtrlListView_SetItemText($hListView,$Index,"Off-line",7)
Else
;MsgBox (0,"10分鐘檢查","10 分鐘到了 第"&($j+1)&"筆 資料updated")
_GUICtrlListView_SetItemText($hListView,$Index,"On-line",7)
EndIf
#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>
#include <WindowsConstants.au3>
#include <Array.au3>
#include <File.au3>

DIM $OldList="" , $aNewList2=""
;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('_Checkitems2')

                                AdlibUnRegister('_add_complete_items')
                                        _add_report_items()

                                AdlibRegister('_add_report_items', 5000);reflash every 10sec
                                AdlibRegister('_Checkitems1', 3000); 1秒 檢查
                                        _Checkitems1()


                        Case $Button2
                                ;AdlibUnRegister('_Checkitems1')

                                AdlibUnRegister('_add_report_items')
                                                _add_complete_items()

                                AdlibRegister('_add_complete_items', 5000);reflash every 10sec
                                AdlibRegister('_Checkitems2', 3000); 1秒 檢查
                                        _Checkitems2()

                        Case $Button3
                                MsgBox(0,"123","456",0)

                        Case $PowerReset
                                Run("PowerReset.exe")

                        Case $SerialOverLan
                                Run("SOL.exe")

        EndSwitch
WEnd




Func _add_report_items()

FileChangeDir("\\192.8.1.1\fs1\1")

                Local $path, $aFileList, $aNewList[1][2]
                $path = "\\192.8.1.1\fs1\1"

        $aFileList = _FileListToArray($path, "*.txt")

        If IsArray($aFileList) Then
                ReDim $aNewList[UBound($aFileList)][16] ;;;[Col count]
                For $i = 0 To UBound($aFileList) - 1 Step 1
                                            $aNewList[0][1] = $i
                        ;$aNewList[$i][0] = $aFileList[$i]
                        $aNewList[$i][1] = FileReadLine($aFileList[$i], 1)
                        $aNewList[$i][2] = FileReadLine($aFileList[$i], 2)
                        $aNewList[$i][3] = FileReadLine($aFileList[$i], 3)
                        $aNewList[$i][4] = FileReadLine($aFileList[$i], 4)
                                                $aNewList[$i][5] = FileReadLine($aFileList[$i], 5)
                                                $aNewList[$i][6] = FileReadLine($aFileList[$i], 6)
                                                $aNewList[$i][7] = FileReadLine($aFileList[$i], 7)
                                                $aNewList[$i][8] = FileReadLine($aFileList[$i], 8)
                                                $aNewList[$i][9] = FileReadLine($aFileList[$i], 9)
                                                $aNewList[$i][10] = FileReadLine($aFileList[$i], 10)
                                                $aNewList[$i][11] = FileReadLine($aFileList[$i], 11)
                                                $aNewList[$i][12] = FileReadLine($aFileList[$i], 12)
                                                $aNewList[$i][13] = FileReadLine($aFileList[$i], 13)
                                                $aNewList[$i][14] = FileReadLine($aFileList[$i], 14)
                                                $aNewList[$i][15] = FileReadLine($aFileList[$i], 15)
;$change1=FileReadLine($aFileList[$i], 1)
                                Next

                _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($hListView))
                _GUICtrlListView_AddArray($hListView, $aNewList)
                                _GUICtrlListView_SetItemText($hListView, $aFileList,"...",7)
        EndIf
        EndFunc


Func _add_complete_items()

FileChangeDir("\\192.8.1.1\fs1\2")

                Local $path, $aFileList, $aNewList[1][2]
                $path = "\\192.8.1.1\fs1\2"

        $aFileList = _FileListToArray($path, "*.txt")

        If IsArray($aFileList) Then
                ReDim $aNewList[UBound($aFileList)][16] ;;;[Col count]
                For $i = 0 To UBound($aFileList) - 1 Step 1
                                            $aNewList[0][1] = $i
                        ;$aNewList[$i][0] = $aFileList[$i]
                        $aNewList[$i][1] = FileReadLine($aFileList[$i], 1)
                        $aNewList[$i][2] = FileReadLine($aFileList[$i], 2)
                        $aNewList[$i][3] = FileReadLine($aFileList[$i], 3)
                        $aNewList[$i][4] = FileReadLine($aFileList[$i], 4)
                                                $aNewList[$i][5] = FileReadLine($aFileList[$i], 5)
                                                $aNewList[$i][6] = FileReadLine($aFileList[$i], 6)
                                                $aNewList[$i][7] = FileReadLine($aFileList[$i], 7)
                                                $aNewList[$i][8] = FileReadLine($aFileList[$i], 8)
                                                $aNewList[$i][9] = FileReadLine($aFileList[$i], 9)
                                                $aNewList[$i][10] = FileReadLine($aFileList[$i], 10)
                                                $aNewList[$i][11] = FileReadLine($aFileList[$i], 11)
                                                $aNewList[$i][12] = FileReadLine($aFileList[$i], 12)
                                                $aNewList[$i][13] = FileReadLine($aFileList[$i], 13)
                                                $aNewList[$i][14] = FileReadLine($aFileList[$i], 14)
                                                $aNewList[$i][15] = 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 = GUICtrlGetHandle($hListView)
    $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")
;$Index = GUICtrlRead($hListView)


    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}")


EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG

EndFunc




Func _Checkitems1()
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") ;Double click value get
        Local $path, $aFileList, $aNewList2[1][2]


                ;DIM $OldList="" , $aNewList2=""
        $path = "\\192.8.1.1\fs1\1"
        $aFileList = _FileListToArray($path, "*.txt")
                                         _ArrayDelete($aFileList,0)
        If IsArray($aFileList) Then

                ReDim $aNewList2[UBound($aFileList)][16] ;;;[Col count]
                For $i = 0 To UBound($aFileList) - 1 Step 1
                                                $aNewList2[0][1] = $i
                        ;$aNewList2[$i][0] = $aFileList[$i]
                        $aNewList2[$i][1] = FileReadLine($aFileList[$i], 1)
                        $aNewList2[$i][2] = FileReadLine($aFileList[$i], 2)
                        $aNewList2[$i][3] = FileReadLine($aFileList[$i], 3)
                        $aNewList2[$i][4] = FileReadLine($aFileList[$i], 4)
                                                $aNewList2[$i][5] = FileReadLine($aFileList[$i], 5)
                                                $aNewList2[$i][6] = FileReadLine($aFileList[$i], 6)
                                                $aNewList2[$i][7] = FileReadLine($aFileList[$i], 7)
                                                $aNewList2[$i][8] = FileReadLine($aFileList[$i], 8)
                                                $aNewList2[$i][9] = FileReadLine($aFileList[$i], 9)
                                                $aNewList2[$i][10] = FileReadLine($aFileList[$i], 10)
                                                $aNewList2[$i][11] = FileReadLine($aFileList[$i], 11)
                                                $aNewList2[$i][12] = FileReadLine($aFileList[$i], 12)
                                                $aNewList2[$i][13] = FileReadLine($aFileList[$i], 13)
                                                $aNewList2[$i][14] = FileReadLine($aFileList[$i], 14)
                                                $aNewList2[$i][15] = FileReadLine($aFileList[$i], 15)

                Next
              ; _ArrayDisplay($aNewList2)
        EndIf

                If IsArray($OldList) Then
                        For $j=0 TO UBound($OldList)-1 STEP 1
                                IF $OldList[$j][4]=$aNewList2[$j][4] THEN
                                                                        ;MsgBox (0,"10分鐘檢查","10 分鐘到了 第"&($j+1)&"筆 資料沒有更新")
                                                                        _GUICtrlListView_SetItemText($hListView, $aFileList,"Off-line",7)

                                                                Else
                                                                        ;MsgBox (0,"10分鐘檢查","10 分鐘到了 第"&($j+1)&"筆 資料updated")
                                                                        _GUICtrlListView_SetItemText($hListView, $aFileList,"On-line",7)

                                                                EndIf

                        Next
                        $OldList=$aNewList2
                                Else
                        $OldList=$aNewList2
                EndIf
EndFunc



Func _Checkitems2()

        Local $path, $aFileList, $aNewList2[1][2]
                ;DIM $OldList="" , $aNewList2=""
        $path = "\\192.8.1.1\fs1\2"
        $aFileList = _FileListToArray($path, "*.txt")
                                         _ArrayDelete($aFileList,0)
        If IsArray($aFileList) Then

                ReDim $aNewList2[UBound($aFileList)][16] ;;;[Col count]
                For $i = 0 To UBound($aFileList) - 1 Step 1
                                                $aNewList2[0][1] = $i
                        ;$aNewList2[$i][0] = $aFileList[$i]
                        $aNewList2[$i][1] = FileReadLine($aFileList[$i], 1)
                        $aNewList2[$i][2] = FileReadLine($aFileList[$i], 2)
                        $aNewList2[$i][3] = FileReadLine($aFileList[$i], 3)
                        $aNewList2[$i][4] = FileReadLine($aFileList[$i], 4)
                                                $aNewList2[$i][5] = FileReadLine($aFileList[$i], 5)
                                                $aNewList2[$i][6] = FileReadLine($aFileList[$i], 6)
                                                $aNewList2[$i][7] = FileReadLine($aFileList[$i], 7)
                                                $aNewList2[$i][8] = FileReadLine($aFileList[$i], 8)
                                                $aNewList2[$i][9] = FileReadLine($aFileList[$i], 9)
                                                $aNewList2[$i][10] = FileReadLine($aFileList[$i], 10)
                                                $aNewList2[$i][11] = FileReadLine($aFileList[$i], 11)
                                                $aNewList2[$i][12] = FileReadLine($aFileList[$i], 12)
                                                $aNewList2[$i][13] = FileReadLine($aFileList[$i], 13)
                                                $aNewList2[$i][14] = FileReadLine($aFileList[$i], 14)
                                                $aNewList2[$i][15] = FileReadLine($aFileList[$i], 15)

                Next
              ; _ArrayDisplay($aNewList2)
        EndIf

                If IsArray($OldList) Then
                        For $j=0 TO UBound($OldList)-1 STEP 1
                                IF $OldList[$j][4]=$aNewList2[$j][4] THEN
                                                                        ;MsgBox (0,"10分鐘檢查","10 分鐘到了 第"&($j+1)&"筆 資料沒有更新")
                                                                        _GUICtrlListView_SetItemText($hListView,$Index,"Off-line",7)
                                                                Else
                                                                        ;MsgBox (0,"10分鐘檢查","10 分鐘到了 第"&($j+1)&"筆 資料updated")
                                                                        _GUICtrlListView_SetItemText($hListView,$Index,"On-line",7)
                                                                EndIf

                        Next
                        $OldList=$aNewList2
                                Else
                        $OldList=$aNewList2
                EndIf
EndFunc
发表于 2016-6-14 13:10:46 | 显示全部楼层
回复 33# ipmitool


    試看看 _GUICtrlListView_SetItemText($hListView,$j,"Off-line",7)
 楼主| 发表于 2016-6-14 13:42:04 | 显示全部楼层
回复 34# kk_lee69


謝謝表哥, 我請你喝飲料好嗎~
发表于 2016-6-14 21:27:22 | 显示全部楼层
回复 35# ipmitool

解決的話 請將標題 加註 [已解決]
发表于 2016-6-15 11:27:27 | 显示全部楼层
希望把完整的源码贴出来
发表于 2016-6-15 11:30:25 | 显示全部楼层
_GUICtrlListView_SetItemText($hListView,$j,"Off-line",7) 用了这句话最后一行老是显示不了Off-line
 楼主| 发表于 2016-6-15 18:50:05 | 显示全部楼层
回复 22# kk_lee69


    老哥, 我已經標示已解決, 謝謝你的幫忙, 有個問題想再請教, 就是你給我的這個範例, 我如果新增一筆txt, 再砍掉那一個txt, 就會出現error, 如下:
IF $oldlist[$j][14]=$anewlist2[j][14] then
if $oldlist[$j][14]^ERROR

ERROR: Array variable has incorrect number of subscripts or subscript dimension range exceeded.

請問這要怎麼解決呢...謝謝~
发表于 2016-6-15 21:46:54 | 显示全部楼层
回复 39# ipmitool

那是 因為 譬如本來有五個 TXT  已經設定到 $oldlist  你殺掉一個 所以新的 $anewlist2 就剩下四個

所以會產生錯誤....

解決方法  

1. 比對前 先 將 不存在的  $oldlist   裡面的資料刪除掉  再進行比對動作....
发表于 2016-6-15 21:49:38 | 显示全部楼层
回复 39# ipmitool


    另外 你當時 在標題加上 已解決  是複製我的字吧   那是繁體字  所以 你不會歸入到已解決區

請修改 標題 打上 簡體字的已解決
 楼主| 发表于 2016-6-16 07:42:19 | 显示全部楼层
回复 41# kk_lee69


    喔喔, 我試試, 拍謝, 我是台灣人拉, 所以打繁體...我改一下!!
 楼主| 发表于 2016-6-16 07:48:25 | 显示全部楼层
回复 40# kk_lee69


    比對前 先 將 不存在的  $oldlist   裡面的資料刪除掉
忘了問...刪除資料要用甚麼參數啊??? 小弟新手...><"
发表于 2016-6-16 23:49:44 | 显示全部楼层
回复 43# ipmitool


    _ArrayDelete
 楼主| 发表于 2016-6-23 14:04:35 | 显示全部楼层
回复 44# kk_lee69


_arrayDelete($oldList,1000) 這樣可以嗎? 要插在哪裡啊?
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-9-29 03:29 , Processed in 0.077408 second(s), 14 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表