Xojo Conferences
XDCMay2019MiamiUSA

Platforms to show: All Mac Windows Linux Cross-Platform

/MacCF/Darwin Drive Statistics
Function:
Required plugins for this example: MBS MacCF Plugin, MBS Main Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /MacCF/Darwin Drive Statistics
This example is the version from Sun, 17th Mar 2012.
Project "Darwin Drive Statistics.rbp"
Class MainWindow Inherits Window
Control StaticTexts Inherits Label
ControlInstance StaticTexts(0) Inherits Label
ControlInstance StaticTexts(1) Inherits Label
ControlInstance StaticTexts(2) Inherits Label
ControlInstance StaticTexts(3) Inherits Label
ControlInstance StaticTexts(4) Inherits Label
ControlInstance StaticTexts(5) Inherits Label
ControlInstance StaticTexts(6) Inherits Label
ControlInstance StaticTexts(7) Inherits Label
ControlInstance StaticTexts(8) Inherits Label
ControlInstance StaticTexts(9) Inherits Label
ControlInstance StaticTexts(10) Inherits Label
ControlInstance StaticTexts(11) Inherits Label
End Control
Control cBytesRead Inherits Label
ControlInstance cBytesRead Inherits Label
End Control
Control cBytesWrite Inherits Label
ControlInstance cBytesWrite Inherits Label
End Control
Control cLatencyTimeRead Inherits Label
ControlInstance cLatencyTimeRead Inherits Label
End Control
Control cLatencyTimeWrite Inherits Label
ControlInstance cLatencyTimeWrite Inherits Label
End Control
Control cErrorsRead Inherits Label
ControlInstance cErrorsRead Inherits Label
End Control
Control cErrorsWrite Inherits Label
ControlInstance cErrorsWrite Inherits Label
End Control
Control cRetriesRead Inherits Label
ControlInstance cRetriesRead Inherits Label
End Control
Control cRetriesWrite Inherits Label
ControlInstance cRetriesWrite Inherits Label
End Control
Control cTotalTimeRead Inherits Label
ControlInstance cTotalTimeRead Inherits Label
End Control
Control cTotalTimeWrite Inherits Label
ControlInstance cTotalTimeWrite Inherits Label
End Control
Control cOperationsRead Inherits Label
ControlInstance cOperationsRead Inherits Label
End Control
Control cOperationsWrite Inherits Label
ControlInstance cOperationsWrite Inherits Label
End Control
Control Timer1 Inherits Timer
ControlInstance Timer1 Inherits Timer
EventHandler Sub Action() update End EventHandler
End Control
EventHandler Sub Open() update End EventHandler
Function GetNumber(d as cfdictionaryMBS, s as cfstringMBS) As double dim n as CFNumberMBS dim o as CFObjectMBS o=d.value(s) if o<>Nil then n=CFNumberMBS(o) if n<>nil then Return n.doubleValue end if end if End Function
Sub update() dim dd as DarwinDriveStatisticsMBS dim d,l as CFDictionaryMBS dim o as CFObjectMBS dim ErrorsRead as Double dim ErrorsWrite as Double dim LatencyTimeRead as Double dim LatencyTimeWrite as Double dim TotalTimeRead as Double dim TotalTimeWrite as Double dim OperationsRead as Double dim OperationsWrite as Double dim RetriesRead as Double dim RetriesWrite as Double dim BytesRead as Double dim BytesWrite as Double dd=new DarwinDriveStatisticsMBS l=dd.NextDrive while l<>Nil o=l.Value(dd.kIOBlockStorageDriverStatisticsKey) if o<>Nil then d=CFDictionaryMBS(o) if d<>nil then BytesRead=BytesRead+GetNumber(d,dd.kIOBlockStorageDriverStatisticsBytesReadKey) BytesWrite=BytesWrite+GetNumber(d,dd.kIOBlockStorageDriverStatisticsBytesWrittenKey) LatencyTimeRead=LatencyTimeRead+GetNumber(d,dd.kIOBlockStorageDriverStatisticsLatentReadTimeKey) LatencyTimeWrite=LatencyTimeWrite+GetNumber(d,dd.kIOBlockStorageDriverStatisticsLatentWriteTimeKey) ErrorsRead=ErrorsRead+GetNumber(d,dd.kIOBlockStorageDriverStatisticsReadErrorsKey) ErrorsWrite=ErrorsWrite+GetNumber(d,dd.kIOBlockStorageDriverStatisticsWriteErrorsKey) RetriesRead=RetriesRead+GetNumber(d,dd.kIOBlockStorageDriverStatisticsReadRetriesKey) RetriesWrite=RetriesWrite+GetNumber(d,dd.kIOBlockStorageDriverStatisticsWriteRetriesKey) TotalTimeRead=TotalTimeRead+GetNumber(d,dd.kIOBlockStorageDriverStatisticsTotalReadTimeKey) TotalTimeWrite=TotalTimeWrite+GetNumber(d,dd.kIOBlockStorageDriverStatisticsTotalWriteTimeKey) OperationsRead=OperationsRead+GetNumber(d,dd.kIOBlockStorageDriverStatisticsReadsKey) OperationsWrite=OperationsWrite+GetNumber(d,dd.kIOBlockStorageDriverStatisticsWritesKey) end if end if l=dd.NextDrive wend cBytesRead.text=Format(BytesRead,"-0") cBytesWrite.text=Format(BytesWrite,"-0") cLatencyTimeRead.text=Format(LatencyTimeRead,"-0") cLatencyTimeWrite.text=Format(LatencyTimeWrite,"-0") cErrorsRead.text=Format(ErrorsRead,"-0") cErrorsWrite.text=Format(ErrorsWrite,"-0") cRetriesRead.text=Format(RetriesRead,"-0") cRetriesWrite.text=Format(RetriesWrite,"-0") cTotalTimeRead.text=Format(TotalTimeRead,"-0") cTotalTimeWrite.text=Format(TotalTimeWrite,"-0") cOperationsRead.text=Format(OperationsRead,"-0") cOperationsWrite.text=Format(OperationsWrite,"-0") End Sub
End Class
MenuBar Menu
MenuItem UntitledMenu3 = ""
MenuItem UntitledMenu2 = "File"
MenuItem FileQuit = "Quit"
MenuItem UntitledMenu0 = "Edit"
MenuItem EditUndo = "Undo"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "Cut"
MenuItem EditCopy = "Copy"
MenuItem EditPaste = "Paste"
MenuItem EditClear = "Clear"
End MenuBar
Class App Inherits Application
EventHandler Sub Open() if TargetMachO then // ok else MsgBox "This needs a Mach-O target running on Mac OS X." end if End EventHandler
End Class
End Project

See also:

Feedback, Comments & Corrections

The items on this page are in the following plugins: MBS MacCF Plugin.




Links
MBS Xojo Plugins