Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
V
vimba
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
kr69sugu
vimba
Commits
00b0b837
Commit
00b0b837
authored
1 year ago
by
am0ebe
Browse files
Options
Downloads
Patches
Plain Diff
fix load/save settings. check edge cases
parent
c2ae16f9
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/cam.cpp
+17
-12
17 additions, 12 deletions
src/cam.cpp
src/cmd/console.cpp
+6
-4
6 additions, 4 deletions
src/cmd/console.cpp
src/iprinter.cpp
+1
-0
1 addition, 0 deletions
src/iprinter.cpp
src/utils.cpp
+3
-4
3 additions, 4 deletions
src/utils.cpp
with
27 additions
and
20 deletions
src/cam.cpp
+
17
−
12
View file @
00b0b837
#include
"cam.h"
#include
"VmbC/VmbCommonTypes.h"
#include
"VmbC/VmbCTypeDefinitions.h"
#include
"iprinter.h"
#include
"utils.h"
#include
"frameobserver.h"
...
...
@@ -8,6 +9,7 @@
#include
<chrono>
#include
<memory>
//shared_ptr
#include
<string>
#include
<unistd.h>
#include
<QTimer>
...
...
@@ -17,7 +19,7 @@ using State = Cam::State;
using
namespace
VmbCPP
;
using
namespace
std
::
chrono
;
using
utils
::
DELIM
;
using
utils
::
settingsFile
;
Cam
::
Cam
(
QString
name
,
QString
ip
)
:
IPrinter
(),
_cam
(
nullptr
),
...
...
@@ -300,34 +302,37 @@ void Cam::onChanged(UpdateTriggerType type)
error
(
"onChanged: unknown trigger type"
);
}
}
#include
<VmbC/VmbCommonTypes.h>
//write out settings.xml for current open cam
void
Cam
::
saveSettings
()
{
if
(
_state
!=
opened
)
return
error
(
"can only save settings on opened cam. (its "
+
stateToString
(
_state
)
+
")"
);
// VmbFilePathChar_t* = wchar_t* > std::wstring
// auto file = L"settings_" + name().toStdWString() + L".xml";
std
::
wstring
file
=
L"settings_"
+
name
().
toStdWString
()
+
L".xml"
;
VmbFeaturePersistSettings_t
settingsStruct
;
settingsStruct
.
loggingLevel
=
VmbLogLevelWarn
;
//err/warn/dbg
settingsStruct
.
maxIterations
=
5
;
settingsStruct
.
persistType
=
VmbFeaturePersistNoLUT
;
//?
settingsStruct
.
maxIterations
=
8
;
settingsStruct
.
persistType
=
VmbFeaturePersistStreamable
;
//dont store IP address!
settingsStruct
.
modulePersistFlags
=
VmbModulePersistFlagsType
::
VmbModulePersistFlagsNone
;
//
// if (f(_cam->SaveSettings( (const VmbFilePathChar_t*)file.c_str() , &settingsStruct ) ))
if
(
f
(
_cam
->
SaveSettings
(
(
const
VmbFilePathChar_t
*
)
file
.
c_str
()
)
))
error
(
"Could not save camera settings to '"
+
QString
::
fromStdWString
(
file
)
+
"'"
);
QString
file
=
"settings_"
+
name
()
+
".xml"
;
if
(
f
(
_cam
->
SaveSettings
(
file
.
toStdString
().
c_str
(),
&
settingsStruct
)))
error
(
"Could not save camera settings to '"
+
file
+
"'"
);
else
IPrinter
::
info
(
"Saved settings to "
+
file
);
}
//load settings.xml for current open cam
void
Cam
::
loadSettings
()
{
using
utils
::
settingsFile
;
if
(
_state
!=
opened
)
return
error
(
"can only save settings on opened cam. (its "
+
stateToString
(
_state
)
+
")"
);
if
(
f
(
_cam
->
LoadSettings
(
(
const
VmbFilePathChar_t
*
)
settingsFile
().
toStd
W
String
().
c_str
())))
if
(
f
(
_cam
->
LoadSettings
(
settingsFile
().
toStdString
().
c_str
())))
error
(
"Could not load camera settings from '"
+
settingsFile
()
+
"'"
);
else
IPrinter
::
info
(
"Loaded settings from "
+
settingsFile
());
}
This diff is collapsed.
Click to expand it.
src/cmd/console.cpp
+
6
−
4
View file @
00b0b837
...
...
@@ -30,7 +30,9 @@ void Console::listenKeys()
while
(
utils
::
running
)
{
std
::
getline
(
std
::
cin
,
input
);
//blox
if
(
input
.
find_first_not_of
(
"0123456789"
)
==
std
::
string
::
npos
)
if
(
input
.
empty
()
)
continue
;
else
if
(
input
.
find_first_not_of
(
"0123456789"
)
==
std
::
string
::
npos
)
{
emit
numberEntered
(
std
::
stoi
(
input
));
// Number
}
...
...
@@ -45,7 +47,7 @@ void Console::listenKeys()
emit
lineEntered
(
QString
::
fromStdString
(
input
));
// Line
}
}
qDebug
()
<<
__LINE__
<<
"-"
<<
__PRETTY_FUNCTION__
<<
""
;
//
qDebug() << __LINE__ << "-" << __PRETTY_FUNCTION__ << "";
}
void
Console
::
error
(
const
int
&
errCode
)
...
...
@@ -101,7 +103,7 @@ void Console::printHelp()
<<
"s: stop recording"
<<
"l: list available cameras"
<<
"k: deteKt cameras"
<<
"y: load cam settings"
<<
"y: load cam settings
("
+
utils
::
settingsFile
()
+
")
"
<<
"u: save cam settings"
<<
"v: print versions"
<<
"q: quit"
...
...
@@ -131,7 +133,7 @@ getDur(false)
Controller
::~
Controller
()
{
qDebug
()
<<
__LINE__
<<
"-"
<<
__PRETTY_FUNCTION__
<<
""
;
//
qDebug() << __LINE__ << "-" << __PRETTY_FUNCTION__ << "";
thread
.
quit
();
thread
.
wait
();
//wait for thread to finish
qDebug
().
noquote
()
<<
__FUNCTION__
<<
"():"
<<
__LINE__
<<
": "
;
...
...
This diff is collapsed.
Click to expand it.
src/iprinter.cpp
+
1
−
0
View file @
00b0b837
#include
"iprinter.h"
#include
<QDebug>
#ifdef CONSOLE
#include
"cmd/console.h"
#endif
...
...
This diff is collapsed.
Click to expand it.
src/utils.cpp
+
3
−
4
View file @
00b0b837
...
...
@@ -176,11 +176,10 @@ QString settingsFile(QString filename)
static
QString
_settingsFile
;
if
(
_settingsFile
.
isEmpty
()
)
{
_settingsFile
=
filename
;
if
(
filename
.
isEmpty
())
QCoreApplication
::
applicationDirPath
()
+
"/settings.xml"
;
//default
_settingsFile
=
QCoreApplication
::
applicationDirPath
()
+
"/settings.xml"
;
//default
else
_settingsFile
=
filename
;
}
return
_settingsFile
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment