Skip to content

Commit 1fd8160

Browse files
committed
Merged PR 20067: Add support for VersionInfo class
This allows to handle the API `cam.GetSfncVersion()`
2 parents 28fc341 + 9135c6c commit 1fd8160

File tree

5 files changed

+60
-4
lines changed

5 files changed

+60
-4
lines changed

changelog.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
21
Version 2.x.y
32
- Date 2023-XX-YY
3+
- Add binding for VersionInfo
44
- add bindings to device factory methods on transport layers
5-
6-
75
Version 2.2.0
86
- Date 2023-06-14
97
- Integrate macos build for arm64

samples/call.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
cam = pylon.InstantCamera(pylon.TlFactory.GetInstance().CreateFirstDevice())
1010
cam.Open()
11-
print(cam.GetSfncVersion)
11+
print(cam.GetSfncVersion())
1212
cam.MaxNumBuffer = 22
1313

1414
cam.GainRaw.Value = 127

src/pylon/PylonVersionInfo.i

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
%rename(VersionInfo) Pylon::VersionInfo;
2+
3+
%ignore Pylon::VersionInfo::getVersionString;
4+
5+
%extend Pylon::VersionInfo {
6+
%pythoncode %{
7+
def __repr__(self):
8+
return f"<VersionInfo {self.getMajor()}.{self.getMinor()}.{self.getSubminor()}>"
9+
%}
10+
};
11+
12+
%include <pylon/PylonVersionInfo.h>;
13+

src/pylon/pylon.i

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -676,6 +676,7 @@ const Pylon::StringList_t & (Pylon::StringList_t str_list)
676676
// in all the places where pylon uses 'GenApi'.
677677
#define GenApi GENAPI_NAMESPACE
678678

679+
%include "PylonVersionInfo.i"
679680
%include "TypeMappings.i"
680681
%include "Container.i"
681682
%include "PixelType.i"
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
from pylonemutestcase import PylonEmuTestCase
2+
from pypylon import pylon
3+
import unittest
4+
5+
6+
class VersionInfoTestSuite(PylonEmuTestCase):
7+
# Tests that you can get proper version info
8+
def test_version_get(self):
9+
cam = self.create_first()
10+
cam.Open()
11+
12+
v = cam.GetSfncVersion()
13+
14+
# camemu has sfnc version 0.0.0.0
15+
self.assertEqual(0, v.getMajor())
16+
self.assertEqual(0, v.getMinor())
17+
self.assertEqual(0, v.getSubminor())
18+
self.assertEqual(0, v.getBuild())
19+
20+
cam.Close()
21+
22+
# Tests that you can compare version info
23+
def test_version_compare(self):
24+
v0 = pylon.VersionInfo(2, 2, 2)
25+
v1 = pylon.VersionInfo(2, 2, 1)
26+
v0_1 = pylon.VersionInfo(2, 2, 2)
27+
28+
self.assertGreater(v0, v1)
29+
self.assertLess(v1, v0)
30+
self.assertEqual(v0, v0_1)
31+
32+
# Tests that version info has repr
33+
def test_version_repr(self):
34+
cam = self.create_first()
35+
cam.Open()
36+
37+
v = cam.GetSfncVersion()
38+
sfnc_version_repr = v.__repr__()
39+
self.assertEqual("<VersionInfo 0.0.0>", sfnc_version_repr)
40+
41+
42+
if __name__ == "__main__":
43+
# import sys;sys.argv = ['', 'Test.testName']
44+
unittest.main()

0 commit comments

Comments
 (0)