Xojo windows example: Difference between revisions
Jump to navigation
Jump to search
(Created page with "= Overview & notes = This is C# example of the Windows program with list devices, simple measurement and view of the output data. '''Timepix3 only.'''<br> <br> '''Notes:''' * Use the release/64 bit configuration * The working directory is directory with the .xojo_binary_project. Copy pixet.ini and other auxilliary files here. = Window = Create window with components: # ListBox1 - Listbox for messages # ImageViewer1 - Image box with 256x256 pixels inside, for output imag...") |
No edit summary |
||
Line 3: | Line 3: | ||
<br> | <br> | ||
'''Notes:''' | '''Notes:''' | ||
* The working directory is directory with the .xojo_binary_project. Copy pixet.ini and other auxilliary files here. | * The working directory is directory with the .xojo_binary_project. Copy pixet.ini and other auxilliary files here. | ||
Line 12: | Line 11: | ||
# Button1- Button to run the example measuring | # Button1- Button to run the example measuring | ||
[[File: | [[File:xojo-windows-example.png|frame|none|alt=Xojo Basic Windows example - App window screenshot|Xojo Basic Windows example - App window screenshot]] | ||
= Code = | = Code of Button1 Pressed event = | ||
<syntaxhighlight lang="basic"> | <syntaxhighlight lang="basic"> | ||
Declare Function pxcInitialize Lib "pxcore.dll" () As Integer | Declare Function pxcInitialize Lib "pxcore.dll" () As Integer |
Latest revision as of 12:30, 29 June 2023
Overview & notes
This is C# example of the Windows program with list devices, simple measurement and view of the output data. Timepix3 only.
Notes:
- The working directory is directory with the .xojo_binary_project. Copy pixet.ini and other auxilliary files here.
Window
Create window with components:
- ListBox1 - Listbox for messages
- ImageViewer1 - Image box with 256x256 pixels inside, for output image (second output only)
- Button1- Button to run the example measuring
Code of Button1 Pressed event
Declare Function pxcInitialize Lib "pxcore.dll" () As Integer
Declare Function pxcExit Lib "pxcore.dll" () As Integer
Declare Function pxcGetDevicesCount Lib "pxcore.dll" () As Integer
Declare Function pxcGetDeviceName Lib "pxcore.dll" (deviceIndex as Integer, nameBuffer as Ptr, size as Int32) As Integer
Declare Function pxcMeasureSingleFrameTpx3 Lib "pxcore.dll" (deviceIndex as Integer, frameTime as double, frameToaITot as Ptr, frameTotEvent as Ptr, size as Ptr, trgStg as integer) As Integer
Declare Function pxcSetTimepix3Mode Lib "pxcore.dll" (deviceIndex as Integer, mode as Integer) As Integer
Const PXC_TPX3_OPM_TOATOT As Integer = 0
Const PXC_TPX3_OPM_TOA As Integer = 1
Const PXC_TPX3_OPM_EVENT_ITOT As Integer = 2
Const PXC_TPX3_OPM_TOT_NOTOA As Integer = 3
dim rc as integer
dim rc2 as integer
Dim arr1 As New MemoryBlock(65536*8)
Dim arr2 As New MemoryBlock(65536*2)
Dim siz As New MemoryBlock(4)
Dim nameBuffer as New MemoryBlock(100)
siz.Int32Value(0) = 65536
Dim a1, a2, si, nb as Ptr
listbox1.RemoveAllRows()
listbox1.addrow("pxcInitialize...")
App.DoEvents(100)
rc = pxcInitialize()
listbox1.addrow("rc " + rc.tostring)
App.DoEvents(100)
if rc<>0 Then goto exitCore
rc = pxcGetDevicesCount()
listbox1.addrow("pxcGetDevicesCount " + rc.tostring)
App.DoEvents(100)
if rc<0 Then goto exitCore
nb = nameBuffer
dim n as Integer
dim di as Int32
for di=0 to rc-1
rc2 = pxcGetDeviceName(di, nb, 100)
if rc2=0 Then
for n=0 to 100
if nameBuffer.uint8value(n) = 0 Then Exit
Next
listbox1.addrow(" " + di.tostring + ": " +nameBuffer.StringValue(0, n))
Else
listbox1.addrow(" " + di.tostring + ": (pxcGetDeviceName failed)")
End If
next
listbox1.addrow("pxcSetTimepix3Mode...")
rc = pxcSetTimepix3Mode(0, PXC_TPX3_OPM_TOATOT)
listbox1.addrow("rc " + rc.tostring)
App.DoEvents(100)
if rc<>0 Then goto exitCore
a1 = arr1
a2 = arr2
si = siz
listbox1.addrow("pxcMeasureSingleFrameTpx3...")
App.DoEvents(100)
rc = pxcMeasureSingleFrameTpx3(0, 5.1, a1, a2, si, 0)
listbox1.addrow("rc " + rc.tostring)
if rc<>0 Then goto exitCore
listbox1.addrow("(Dummy image with artefacts of short time after init)")
listbox1.addrow("pxcMeasureSingleFrameTpx3...")
App.DoEvents(100)
rc = pxcMeasureSingleFrameTpx3(0, 1.5, a1, a2, si, 0)
listbox1.addrow("rc " + rc.tostring)
if rc<>0 Then goto exitCore
exitCore:
if rc<>0 Then listbox1.addrow("Test failed")
listbox1.addrow("pxcExit...")
App.DoEvents(100)
rc2 = pxcExit()
listbox1.addrow("rc " + rc2.tostring)
Dim memoryBlockOffset As Int32
Dim p As Picture
Dim r As RGBSurface
Dim x, y As Int32
Dim value As Int32
p = New Picture(256, 256)
r = p.RGBSurface
memoryBlockOffset = 0
For y = 0 To 255
For x = 0 To 255
value = arr2.UInt16Value((y*256+x)*2)/4
if rc=0 Then
r.Pixel(y, x) = RGB(value, value, value)
Else
r.Pixel(y, x) = RGB(255, 0, 0)
end if
memoryBlockOffset = memoryBlockOffset + 1
Next
Next
ImageViewer1.Image = p