Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
elphel-apps-astreamer
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Elphel
elphel-apps-astreamer
Commits
6f34e998
Commit
6f34e998
authored
7 years ago
by
Mikhail Karpenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WIP: compile parameters without errors
parent
09d720de
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
62 additions
and
64 deletions
+62
-64
parameters.cpp
src/parameters.cpp
+50
-37
parameters.h
src/parameters.h
+12
-27
No files found.
src/parameters.cpp
View file @
6f34e998
/**
* @file
FILENAME
* @brief
BRIEF DESCRIPTION
* @copyright Copyright (C)
YEAR
Elphel Inc.
* @file
parameters.cpp
* @brief
Provides interface to global camera parameters
* @copyright Copyright (C)
2017
Elphel Inc.
* @author AUTHOR <EMAIL>
*
* @par License:
...
...
@@ -19,8 +19,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "parameters.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
...
...
@@ -28,15 +26,18 @@
#include <arpa/inet.h>
#include <fcntl.h>
#include <unistd.h>
#include <iostream>
#include <sstream>
#include <string>
#include <elphel/x393_devices.h>
#include <asm/elphel/c313a.h>
#include "parameters.h"
//#include "streamer.h"
#include <iostream>
#include "streamer.h"
using
namespace
std
;
#undef PARAMETERS_DEBUG
//
#define PARAMETERS_DEBUG
//
#undef PARAMETERS_DEBUG
#define PARAMETERS_DEBUG
#ifdef PARAMETERS_DEBUG
#define D(a) a
...
...
@@ -44,23 +45,46 @@ using namespace std;
#define D(a)
#endif
Parameters
*
Parameters
::
_parameters
=
NULL
;
Parameters
::
Parameters
(
void
)
{
fd_fparmsall
=
open
(
"/dev/frameparsall"
,
O_RDWR
);
if
(
fd_fparmsall
<
0
)
throw
(
"can't open /dev/frameparsall"
);
//! now try to mmap
frameParsAll
=
(
struct
framepars_all_t
*
)
mmap
(
0
,
sizeof
(
struct
framepars_all_t
)
,
PROT_READ
|
PROT_WRITE
,
MAP_SHARED
,
fd_fparmsall
,
0
);
if
((
int
)
frameParsAll
==
-
1
)
throw
(
"Error in mmap /dev/frameparsall"
);
//Parameters *Parameters::_parameters = NULL;
static
const
char
*
ctl_file_names
[]
=
{
DEV393_PATH
(
DEV393_FRAMEPARS0
),
DEV393_PATH
(
DEV393_FRAMEPARS1
),
DEV393_PATH
(
DEV393_FRAMEPARS2
),
DEV393_PATH
(
DEV393_FRAMEPARS3
)
};
Parameters
::
Parameters
(
int
port
)
{
string
err_msg
;
if
((
port
>=
0
)
&&
(
port
<
SENSOR_PORTS
))
{
sensor_port
=
port
;
}
else
{
string
port_str
=
static_cast
<
ostringstream
&>
((
ostringstream
()
<<
dec
<<
port
)).
str
();
err_msg
=
"port number specified is invalid: "
+
port_str
;
throw
invalid_argument
(
err_msg
);
}
fd_fparmsall
=
open
(
ctl_file_names
[
sensor_port
],
O_RDWR
);
if
(
fd_fparmsall
<
0
)
{
err_msg
=
"can not open "
+
*
ctl_file_names
[
sensor_port
];
throw
std
::
runtime_error
(
err_msg
);
}
frameParsAll
=
(
struct
framepars_all_t
*
)
mmap
(
0
,
sizeof
(
struct
framepars_all_t
),
PROT_READ
|
PROT_WRITE
,
MAP_SHARED
,
fd_fparmsall
,
0
);
if
((
int
)
frameParsAll
==
-
1
)
{
frameParsAll
=
NULL
;
err_msg
=
"Error in mmap "
+
*
ctl_file_names
[
sensor_port
];
throw
std
::
invalid_argument
(
err_msg
);
}
framePars
=
frameParsAll
->
framePars
;
globalPars
=
frameParsAll
->
globalPars
;
}
Parameters
::~
Parameters
(
void
)
{
if
(
fd_fparmsall
>
0
)
if
(
frameParsAll
!=
NULL
)
{
munmap
(
frameParsAll
,
sizeof
(
struct
framepars_all_t
));
frameParsAll
=
NULL
;
}
if
(
fd_fparmsall
>
0
)
close
(
fd_fparmsall
);
}
...
...
@@ -71,7 +95,8 @@ Parameters::~Parameters(void) {
* @return parameter value
*/
unsigned
long
Parameters
::
getGPValue
(
unsigned
long
GPNumber
)
{
return
(
GPNumber
>=
FRAMEPAR_GLOBALS
)
?
GLOBALPARS
(
GPNumber
)
:
framePars
[
GLOBALPARS
(
G_THIS_FRAME
)
&
PARS_FRAMES_MASK
].
pars
[
GPNumber
];
return
(
GPNumber
>=
FRAMEPAR_GLOBALS
)
?
GLOBALPARS_SNGL
(
GPNumber
)
:
framePars
[
GLOBALPARS_SNGL
(
G_THIS_FRAME
)
&
PARS_FRAMES_MASK
].
pars
[
GPNumber
];
}
/**
...
...
@@ -80,11 +105,11 @@ unsigned long Parameters::getGPValue(unsigned long GPNumber) {
* @param value - value to set
*/
void
Parameters
::
setGValue
(
unsigned
long
GNumber
,
unsigned
long
value
)
{
GLOBALPARS
(
GNumber
)
=
value
;
GLOBALPARS
_SNGL
(
GNumber
)
=
value
;
}
unsigned
long
Parameters
::
getFrameValue
(
unsigned
long
FPNumber
)
{
return
framePars
[
GLOBALPARS
(
G_THIS_FRAME
)
&
PARS_FRAMES_MASK
].
pars
[
FPNumber
];
return
framePars
[
GLOBALPARS
_SNGL
(
G_THIS_FRAME
)
&
PARS_FRAMES_MASK
].
pars
[
FPNumber
];
}
bool
Parameters
::
daemon_enabled
(
void
)
{
...
...
@@ -92,17 +117,5 @@ bool Parameters::daemon_enabled(void) {
}
void
Parameters
::
setPValue
(
unsigned
long
*
val_array
,
int
count
)
{
/*
long target_frame = params->getGPValue(G_THIS_FRAME) + FRAMES_AHEAD_FPS;
write_data[0] = FRAMEPARS_SETFRAME;
write_data[1] = target_frame; /// wait then for that frame to be available on the output plus 2 frames for fps to be stable
write_data[2] = P_FP1000SLIM;
write_data[3] = (unsigned long)fps * 1000;
write_data[4] = P_FPSFLAGS;
write_data[5] = 3;
*/
// long rslt = write(fd_fparmsall, write_data, sizeof(write_data));
this
->
write
(
val_array
,
sizeof
(
unsigned
long
)
*
count
);
}
//------------------------------------------------------------------------------
This diff is collapsed.
Click to expand it.
src/parameters.h
View file @
6f34e998
/**
* @file
FILENAME
* @brief
BRIEF DESCRIPTION
* @copyright Copyright (C)
YEAR
Elphel Inc.
* @file
parameters.h
* @brief
Provides interface to global camera parameters
* @copyright Copyright (C)
2017
Elphel Inc.
* @author AUTHOR <EMAIL>
*
* @par License:
...
...
@@ -24,34 +24,21 @@
#include <sys/types.h>
#include <unistd.h>
#include <string>
#include <elphel/c313a.h>
using
namespace
std
;
#include <asm/elphel/c313a.h>
//#define FRAMES_AHEAD_FPS 3 /// number of video frames ahead of current to frite FPS limit
//#define FRAMES_SKIP_FPS 3 /// number of video frames to wait after target so circbuf will have at least 2 frames with new fps for calculation
class
Parameters
{
public
:
/*
enum vevent {
VEVENT0,
DAEMON_DISABLED,
FPS_CHANGE,
SIZE_CHANGE
};
*/
inline
static
Parameters
*
instance
(
void
)
{
if
(
_parameters
==
NULL
)
_parameters
=
new
Parameters
();
return
_parameters
;
}
// inline static Parameters *instance(void) {
// if(_parameters == NULL)
// _parameters = new Parameters();
// return _parameters;
// }
Parameters
(
int
port
);
~
Parameters
(
void
);
// unsigned long get
/// interface to global camera parameters
unsigned
long
getGPValue
(
unsigned
long
GPNumber
);
void
setGValue
(
unsigned
long
GNumber
,
unsigned
long
value
);
...
...
@@ -61,15 +48,13 @@ public:
bool
daemon_enabled
(
void
);
void
setPValue
(
unsigned
long
*
val_array
,
int
count
);
protected
:
static
Parameters
*
_parameters
;
Parameters
(
void
);
// static Parameters *_parameters;
struct
framepars_all_t
*
frameParsAll
;
struct
framepars_t
*
framePars
;
unsigned
long
*
globalPars
;
int
fd_fparmsall
;
int
sensor_port
;
};
//extern Video *video;
#endif // _VIDEO__H_
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment