Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
U
uniset2
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
UniSet project repositories
uniset2
Commits
9860cfce
Commit
9860cfce
authored
May 26, 2009
by
Pavel Vainerman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update for new gcc
parent
24ad8c8b
Hide whitespace changes
Inline
Side-by-side
Showing
21 changed files
with
128 additions
and
374 deletions
+128
-374
ComediInterface.cc
extentions/IOControl/ComediInterface.cc
+13
-144
ComediInterface.h
extentions/IOControl/ComediInterface.h
+7
-25
iotest.cc
extentions/IOControl/iotest.cc
+51
-147
MBMaster.cc
extentions/MBTCPMaster/MBMaster.cc
+1
-1
MBSlave.cc
extentions/ModbusSlave/MBSlave.cc
+1
-1
RTUExchange.cc
extentions/RTUExchange/RTUExchange.cc
+1
-1
RTUStorage.cc
extentions/RTUExchange/RTUStorage.cc
+1
-1
mtrconv.cc
extentions/RTUExchange/mtrconv.cc
+1
-1
Calibration.h
extentions/include/Calibration.h
+1
-1
DigitalFilter.cc
extentions/lib/DigitalFilter.cc
+1
-1
MTR.cc
extentions/lib/MTR.cc
+1
-1
CallBackTimer.h
include/CallBackTimer.h
+2
-2
Configuration.h
include/Configuration.h
+3
-7
DebugStream.h
include/DebugStream.h
+7
-6
MessageInterface.h
include/MessageInterface.h
+3
-3
SMonitor.h
include/SMonitor.h
+2
-4
UniSetTypes.h
include/UniSetTypes.h
+6
-2
UniXML.h
include/UniXML.h
+1
-1
UniSetTypes.cc
src/ObjectRepository/UniSetTypes.cc
+24
-2
IOController.cc
src/Processes/IOController.cc
+1
-1
SMonitor.cc
src/Various/SMonitor.cc
+0
-22
No files found.
extentions/IOControl/ComediInterface.cc
View file @
9860cfce
...
...
@@ -43,41 +43,6 @@ int ComediInterface::getAnalogChannel( int subdev, int channel, int range, int a
return
data
;
}
// -----------------------------------------------------------------------------
std
::
vector
<
lsampl_t
>
ComediInterface
::
getAnalogPacket
(
int
subdev
,
int
channel
,
int
range
,
int
aref
)
throw
(
UniSetTypes
::
Exception
)
{
lsampl_t
*
data
=
new
lsampl_t
[
1024
];
/* FIFO size, maximum possible samples */
comedi_insn
insn
;
memset
(
&
insn
,
0
,
sizeof
(
insn
));
insn
.
insn
=
INSN_READ
;
insn
.
n
=
1024
;
insn
.
data
=
data
;
insn
.
subdev
=
subdev
;
insn
.
chanspec
=
CR_PACK
(
channel
,
range
,
aref
);
int
ret
=
comedi_do_insn
(
card
,
&
insn
);
if
(
ret
<
0
)
{
delete
[]
data
;
ostringstream
err
;
err
<<
"(ComediInterface:getAnalogPacket): can`t read data from subdev="
<<
subdev
<<
" channel="
<<
channel
<<
" range="
<<
range
<<
" aref="
<<
aref
<<
" err: "
<<
ret
<<
" ("
<<
strerror
(
ret
)
<<
")"
;
throw
Exception
(
err
.
str
());
// return std::vector<lsampl_t>(0);
}
std
::
vector
<
lsampl_t
>
result
(
ret
);
if
(
ret
>
0
)
memcpy
(
&
result
[
0
],
data
,
ret
*
sizeof
(
lsampl_t
));
delete
[]
data
;
return
result
;
}
// -----------------------------------------------------------------------------
void
ComediInterface
::
setAnalogChannel
(
int
subdev
,
int
channel
,
int
data
,
int
range
,
int
aref
)
throw
(
UniSetTypes
::
Exception
)
{
...
...
@@ -117,41 +82,6 @@ void ComediInterface::setDigitalChannel( int subdev, int channel, bool bit )
throw
Exception
(
err
.
str
());
}
}
// -----------------------------------------------------------------------------
void
ComediInterface
::
instrChannel
(
int
subdev
,
int
channel
,
const
std
::
string
instr
,
std
::
vector
<
lsampl_t
>
args
,
int
range
,
int
aref
)
throw
(
UniSetTypes
::
Exception
)
{
lsampl_t
ins
=
instr2type
(
instr
);
comedi_insn
insn
;
if
(
ins
<
0
)
{
ostringstream
err
;
err
<<
"(ComediInterface:instrChannel): unknown instruction "
<<
" subdev="
<<
subdev
<<
" channel="
<<
channel
<<
" instruction="
<<
instr
;
throw
Exception
(
err
.
str
());
}
args
.
insert
(
args
.
begin
(),
ins
);
memset
(
&
insn
,
0
,
sizeof
(
insn
));
insn
.
insn
=
INSN_CONFIG
;
insn
.
n
=
args
.
size
();
insn
.
data
=
&
args
[
0
];
insn
.
subdev
=
subdev
;
insn
.
chanspec
=
CR_PACK
(
channel
,
range
,
aref
);
if
(
comedi_do_insn
(
card
,
&
insn
)
<
0
)
{
ostringstream
err
;
err
<<
"(ComediInterface:instrChannel): can`t execute the instruction "
<<
" subdev="
<<
subdev
<<
" channel="
<<
channel
<<
" instruction="
<<
instr
;
throw
Exception
(
err
.
str
());
}
return
;
}
// -----------------------------------------------------------------------------
void
ComediInterface
::
configureChannel
(
int
subdev
,
int
channel
,
ChannelType
t
,
int
range
,
int
aref
)
...
...
@@ -209,39 +139,21 @@ void ComediInterface::configureChannel( int subdev, int channel, ChannelType t,
void
ComediInterface
::
configureSubdev
(
int
subdev
,
SubdevType
t
)
throw
(
UniSetTypes
::
Exception
)
{
static
const
unsigned
char
chans
[
4
]
=
{
0
,
8
,
16
,
20
};
/* We can configure only one channel per 8-bit port (4-bit for CL and CH). */
lsampl_t
cmd
[
4
];
/* Ports A, B, CL, CH */
lsampl_t
cmd
=
102
;
comedi_insn
insn
;
switch
(
t
)
memset
(
&
insn
,
0
,
sizeof
(
insn
));
insn
.
insn
=
INSN_CONFIG
;
insn
.
n
=
1
;
insn
.
data
=
&
cmd
;
insn
.
unused
[
0
]
=
t
;
insn
.
subdev
=
subdev
;
insn
.
chanspec
=
0
;
if
(
comedi_do_insn
(
card
,
&
insn
)
<
0
)
{
case
TBI24_0
:
cmd
[
0
]
=
cmd
[
1
]
=
cmd
[
2
]
=
cmd
[
3
]
=
INSN_CONFIG_DIO_INPUT
;
break
;
case
TBI0_24
:
default
:
cmd
[
0
]
=
cmd
[
1
]
=
cmd
[
2
]
=
cmd
[
3
]
=
INSN_CONFIG_DIO_OUTPUT
;
break
;
case
TBI16_8
:
cmd
[
0
]
=
cmd
[
1
]
=
INSN_CONFIG_DIO_INPUT
;
cmd
[
2
]
=
cmd
[
3
]
=
INSN_CONFIG_DIO_OUTPUT
;
break
;
}
for
(
int
i
=
0
;
i
<
4
;
i
++
)
{
memset
(
&
insn
,
0
,
sizeof
(
insn
));
insn
.
insn
=
INSN_CONFIG
;
insn
.
n
=
1
;
insn
.
data
=
&
cmd
[
i
];
insn
.
subdev
=
subdev
;
insn
.
chanspec
=
CR_PACK
(
chans
[
i
],
0
,
0
);
if
(
comedi_do_insn
(
card
,
&
insn
)
<
0
)
{
ostringstream
err
;
err
<<
"(ComediInterface:configureSubdev): can`t configure subdev "
<<
" subdev="
<<
subdev
<<
" type="
<<
t
;
throw
Exception
(
err
.
str
());
}
ostringstream
err
;
err
<<
"(ComediInterface:configureSubdev): can`t configure subdev "
<<
" subdev="
<<
subdev
<<
" type="
<<
t
;
throw
Exception
(
err
.
str
());
}
}
// -----------------------------------------------------------------------------
...
...
@@ -279,46 +191,3 @@ ComediInterface::SubdevType ComediInterface::str2type( const std::string s )
return
Unknown
;
}
// -----------------------------------------------------------------------------
ComediInterface
::
EventType
ComediInterface
::
event2type
(
const
std
::
string
s
)
{
if
(
s
==
"Front"
)
return
Front
;
if
(
s
==
"Rear"
)
return
Rear
;
if
(
s
==
"FrontThenRear"
)
return
FrontThenRear
;
return
No
;
}
// -----------------------------------------------------------------------------
lsampl_t
ComediInterface
::
instr2type
(
const
std
::
string
s
)
{
if
(
s
==
"AVERAGING"
||
s
==
"BOUNCE_SUPPRESSION"
)
/* This are the same instructions, one for AI, another for DI */
return
INSN_CONFIG_AVERAGING
;
if
(
s
==
"TIMER"
)
return
INSN_CONFIG_TIMER_1
;
if
(
s
==
"INPUT_MASK"
)
return
INSN_CONFIG_INPUT_MASK
;
if
(
s
==
"FILTER"
)
return
INSN_CONFIG_FILTER
;
if
(
s
==
"0mA"
)
return
INSN_CONFIG_0MA
;
if
(
s
==
"COMPL"
)
return
INSN_CONFIG_COMPL
;
if
(
s
==
"COUNTER"
)
return
INSN_CONFIG_COUNTER
;
if
(
s
==
"DI_MODE"
)
return
INSN_CONFIG_DI_MODE
;
return
-
1
;
}
// -----------------------------------------------------------------------------
extentions/IOControl/ComediInterface.h
View file @
9860cfce
...
...
@@ -4,9 +4,7 @@
#define ComediInterface_H_
// -----------------------------------------------------------------------------
#include <string>
#include <vector>
#include <comedilib.h>
#include <fastwel.h>
#include "Exceptions.h"
// -----------------------------------------------------------------------------
/*! / */
...
...
@@ -19,9 +17,6 @@ class ComediInterface
int
getAnalogChannel
(
int
subdev
,
int
channel
,
int
range
=
0
,
int
aref
=
AREF_GROUND
)
throw
(
UniSetTypes
::
Exception
);
std
::
vector
<
lsampl_t
>
getAnalogPacket
(
int
subdev
,
int
channel
,
int
range
=
0
,
int
aref
=
AREF_GROUND
)
throw
(
UniSetTypes
::
Exception
);
void
setAnalogChannel
(
int
subdev
,
int
channel
,
int
data
,
int
range
=
0
,
int
aref
=
AREF_GROUND
)
throw
(
UniSetTypes
::
Exception
);
...
...
@@ -37,10 +32,10 @@ class ComediInterface
{
DI
=
INSN_CONFIG_DIO_INPUT
,
DO
=
INSN_CONFIG_DIO_OUTPUT
,
AI
=
INSN_CONFIG_AIO_INPUT
,
AO
=
INSN_CONFIG_AIO_OUTPUT
AI
=
100
,
//
INSN_CONFIG_AIO_INPUT,
AO
=
101
//
INSN_CONFIG_AIO_OUTPUT
};
enum
SubdevType
{
Unknown
=
0
,
...
...
@@ -48,31 +43,18 @@ class ComediInterface
TBI0_24
=
2
,
TBI16_8
=
3
};
enum
EventType
{
No
=
0
,
Front
=
1
,
Rear
=
2
,
FrontThenRear
=
3
};
static
std
::
string
type2str
(
SubdevType
t
);
static
SubdevType
str2type
(
const
std
::
string
s
);
static
EventType
event2type
(
const
std
::
string
s
);
static
lsampl_t
instr2type
(
const
std
::
string
s
);
void
configureSubdev
(
int
subdev
,
SubdevType
type
)
throw
(
UniSetTypes
::
Exception
);
void
configureChannel
(
int
subdev
,
int
channel
,
ChannelType
type
,
int
range
=
0
,
int
aref
=
0
)
throw
(
UniSetTypes
::
Exception
);
/* Perform extended instruction at the channel. Arguments are being taken as C++ vector. */
void
instrChannel
(
int
subdev
,
int
channel
,
const
std
::
string
instr
,
std
::
vector
<
lsampl_t
>
args
,
int
range
=
0
,
int
aref
=
0
)
throw
(
UniSetTypes
::
Exception
);
inline
const
std
::
string
devname
(){
return
dname
;
}
protected
:
comedi_t
*
card
;
/*!< / */
...
...
extentions/IOControl/iotest.cc
View file @
9860cfce
...
...
@@ -3,7 +3,6 @@
#include <stdlib.h>
#include <string.h>
#include <comedilib.h>
#include <fastwel.h>
#include <getopt.h>
int
subdev
=
0
;
...
...
@@ -17,7 +16,6 @@ static struct option longopts[] = {
{
"read"
,
required_argument
,
0
,
'r'
},
{
"write"
,
required_argument
,
0
,
'w'
},
{
"aread"
,
required_argument
,
0
,
'i'
},
{
"anread"
,
required_argument
,
0
,
'n'
},
{
"awrite"
,
required_argument
,
0
,
'o'
},
{
"subdev"
,
required_argument
,
0
,
's'
},
{
"device"
,
required_argument
,
0
,
'd'
},
...
...
@@ -25,9 +23,6 @@ static struct option longopts[] = {
{
"aref"
,
required_argument
,
0
,
'z'
},
{
"range"
,
required_argument
,
0
,
'x'
},
{
"config"
,
required_argument
,
0
,
'c'
},
{
"extconfig"
,
required_argument
,
0
,
'e'
},
{
"timer"
,
required_argument
,
0
,
't'
},
{
"autoscan"
,
no_argument
,
0
,
'u'
},
{
"autoconf"
,
no_argument
,
0
,
'a'
},
{
"plus"
,
required_argument
,
0
,
'p'
},
{
"blink"
,
no_argument
,
0
,
'b'
},
...
...
@@ -44,22 +39,18 @@ enum Command
cmdARead
,
cmdAWrite
,
cmdConfig
,
cmdSubConfig
,
cmdAnRead
,
cmdExtConfig
,
cmdTimer
cmdSubConfig
}
cmd
;
// --------------------------------------------------------------------------
static
void
insn_config
(
comedi_t
*
card
,
int
subdev
,
int
channel
,
lsampl_t
iotype
,
int
range
,
int
aref
);
static
void
insn_subdev_config
(
comedi_t
*
card
,
int
subdev
,
lsampl_t
type
);
static
void
insn_config_extra
(
comedi_t
*
card
,
int
subdev
,
int
channel
,
lsampl_t
data
,
int
range
,
int
aref
,
int
val
);
// --------------------------------------------------------------------------
int
main
(
int
argc
,
char
*
argv
[])
{
comedi_t
*
card
;
lsampl_t
data
=
0
;
lsampl_t
darr
[
20
];
int
optindex
=
0
;
int
opt
=
0
;
char
*
dev
=
"/dev/comedi0"
;
...
...
@@ -70,14 +61,10 @@ int main(int argc, char* argv[])
int
cnum
=
0
;
int
blink
=
0
;
int
exret
=
EXIT_SUCCESS
;
int
instruction
;
int
autoscan
=
0
;
int
n_data
;
memset
(
chan
,
-
1
,
sizeof
(
chan
));
while
(
(
opt
=
getopt_long
(
argc
,
argv
,
"hab
ur:w:i:o:s:d:c:p:m:q:e:t:n
:"
,
longopts
,
&
optindex
))
!=
-
1
)
while
(
(
opt
=
getopt_long
(
argc
,
argv
,
"hab
r:w:i:o:s:d:c:p:m:q
:"
,
longopts
,
&
optindex
))
!=
-
1
)
{
switch
(
opt
)
{
...
...
@@ -87,7 +74,6 @@ int main(int argc, char* argv[])
printf
(
"[-r|--read] chan - read from digital channel
\n
"
);
printf
(
"[-o|--awrite] chan val - write to analog channel
\n
"
);
printf
(
"[-i|--aread] chan - read from analog channel
\n
"
);
printf
(
"[-n|--anread] chan - read N values (n = 20) from analog channel
\n
"
);
printf
(
"[-s|--subdev] sub - use subdev number sub. (Default: 0)
\n
"
);
printf
(
"[-d|--device] dev - use device dev. (Default: /dev/comedi0)
\n
"
);
printf
(
"[--aref] val - AREF (Default: %d)
\n
"
,
aref
);
...
...
@@ -108,14 +94,11 @@ int main(int argc, char* argv[])
printf
(
" 1 - -5 - 5
\n
"
);
printf
(
" 2 - -2.5 - 2.5
\n
"
);
printf
(
" 3 - -1.25 - 1.25
\n
"
);
printf
(
"[-e|--extconfig] channel instruction [parameters] - perform configuring instruction at given channel
\n
"
);
printf
(
"[-t|--timer] channel interval - start acquisition by timer at given channel or stop it (if interval = 0)
\n
"
);
printf
(
"[-u|--autoscan] - (together with -t) set autoscan mode for acquisition by timer
\n
"
);
printf
(
"[--blink] - (blink output): ONLY FOR 'write': 0-1-0-1-0-...
\n
"
);
printf
(
"[--blink-msec] val - Blink pause [msec]. Default: 300 msec
\n
"
);
return
0
;
case
'r'
:
case
'r'
:
chan
[
0
]
=
atoi
(
optarg
);
cmd
=
cmdDRead
;
break
;
...
...
@@ -127,16 +110,7 @@ int main(int argc, char* argv[])
val
=
atoi
(
argv
[
optind
]);
break
;
case
'n'
:
chan
[
0
]
=
atoi
(
optarg
);
cmd
=
cmdAnRead
;
break
;
case
'u'
:
autoscan
=
1
;
break
;
case
'i'
:
case
'i'
:
chan
[
0
]
=
atoi
(
optarg
);
cmd
=
cmdARead
;
break
;
...
...
@@ -148,23 +122,7 @@ int main(int argc, char* argv[])
val
=
atoi
(
argv
[
optind
]);
break
;
case
'e'
:
chan
[
0
]
=
atoi
(
optarg
);
cmd
=
cmdExtConfig
;
n_data
=
0
;
for
(;
optind
<
argc
&&
(
argv
[
optind
])[
0
]
!=
'-'
;
optind
++
,
n_data
++
)
{
darr
[
n_data
]
=
atoi
(
argv
[
optind
]);
}
break
;
case
't'
:
chan
[
0
]
=
atoi
(
optarg
);
cmd
=
cmdTimer
;
if
(
optind
<
argc
&&
(
argv
[
optind
])[
0
]
!=
'-'
)
val
=
atoi
(
argv
[
optind
++
]);
break
;
case
'd'
:
case
'd'
:
dev
=
optarg
;
break
;
...
...
@@ -239,6 +197,12 @@ int main(int argc, char* argv[])
{
for
(
int
k
=
0
;
chan
[
k
]
!=-
1
;
k
++
)
{
if
(
comedi_dio_config
(
card
,
subdev
,
chan
[
k
],
INSN_CONFIG_DIO_INPUT
)
<
0
)
{
comedi_perror
(
"can't configure DI channels"
);
exret
=
EXIT_FAILURE
;
}
if
(
comedi_dio_read
(
card
,
subdev
,
chan
[
k
],
&
data
)
<
0
)
{
fprintf
(
stderr
,
"can't read from channel %d
\n
"
,
chan
[
k
]);
...
...
@@ -252,6 +216,14 @@ int main(int argc, char* argv[])
case
cmdDWrite
:
{
for
(
int
k
=
0
;
chan
[
k
]
!=-
1
;
k
++
)
{
if
(
comedi_dio_config
(
card
,
subdev
,
chan
[
k
],
INSN_CONFIG_DIO_OUTPUT
)
<
0
)
{
comedi_perror
(
"can't configure DO channels"
);
exret
=
EXIT_FAILURE
;
}
}
//
while
(
1
)
{
...
...
@@ -295,35 +267,6 @@ int main(int argc, char* argv[])
}
break
;
case
cmdAnRead
:
{
comedi_insn
insn
;
memset
(
&
insn
,
0
,
sizeof
(
insn
));
insn
.
insn
=
INSN_READ
;
insn
.
n
=
20
;
insn
.
data
=
darr
;
insn
.
subdev
=
subdev
;
for
(
int
k
=
0
;
chan
[
k
]
!=-
1
;
k
++
)
{
if
(
autoconf
)
insn_config
(
card
,
subdev
,
chan
[
k
],
100
,
range
,
aref
);
insn
.
chanspec
=
CR_PACK
(
chan
[
k
],
range
,
aref
);
int
ret
=
comedi_do_insn
(
card
,
&
insn
);
if
(
ret
<
0
)
{
fprintf
(
stderr
,
"can't read from channel %d: (%d) %s
\n
"
,
chan
,
ret
,
strerror
(
ret
));
exret
=
EXIT_FAILURE
;
}
printf
(
"Readed from channel %d: expected 20 samples, got %d samples
\n
"
,
chan
[
k
],
ret
);
for
(
int
i
=
0
;
i
<
ret
;
i
++
)
printf
(
"Data[%d] = %d
\n
"
,
i
,
darr
[
i
]);
}
}
break
;
case
cmdAWrite
:
{
for
(
int
k
=
0
;
chan
[
k
]
!=-
1
;
k
++
)
...
...
@@ -346,10 +289,10 @@ int main(int argc, char* argv[])
for
(
int
k
=
0
;
chan
[
k
]
!=-
1
;
k
++
)
{
if
(
val
!=
INSN_CONFIG_DIO_INPUT
&&
val
!=
INSN_CONFIG_DIO_OUTPUT
&&
val
!=
INSN_CONFIG_AIO_INPUT
&&
val
!=
INSN_CONFIG_AIO_OUTPUT
if
(
val
!=
INSN_CONFIG_DIO_INPUT
&&
val
!=
INSN_CONFIG_DIO_OUTPUT
&&
val
!=
100
/* INSN_CONFIG_AIO_INPUT */
&&
val
!=
101
/* INSN_CONFIG_AIO_OUTPUT */
)
{
fprintf
(
stderr
,
"can't config channel %d for type = %d (val=[%d,%d,%d,%d])
\n
"
...
...
@@ -358,45 +301,6 @@ int main(int argc, char* argv[])
}
}
}
case
cmdExtConfig
:
{
for
(
int
k
=
0
;
chan
[
k
]
!=-
1
;
k
++
)
{
comedi_insn
insn
;
memset
(
&
insn
,
0
,
sizeof
(
insn
));
insn
.
insn
=
INSN_CONFIG
;
insn
.
n
=
n_data
;
insn
.
data
=
darr
;
insn
.
subdev
=
subdev
;
insn
.
chanspec
=
CR_PACK
(
chan
[
k
],
0
,
0
);
comedi_do_insn
(
card
,
&
insn
);
}
break
;
}
case
cmdTimer
:
{
for
(
int
k
=
0
;
chan
[
k
]
!=-
1
;
k
++
)
{
comedi_insn
insn
;
lsampl_t
data
[
3
];
data
[
0
]
=
INSN_CONFIG_TIMER_1
;
data
[
1
]
=
val
;
data
[
2
]
=
autoscan
;
memset
(
&
insn
,
0
,
sizeof
(
insn
));
insn
.
insn
=
INSN_CONFIG
;
insn
.
n
=
3
;
insn
.
data
=
data
;
insn
.
subdev
=
subdev
;
insn
.
chanspec
=
CR_PACK
(
chan
[
k
],
0
,
0
);
comedi_do_insn
(
card
,
&
insn
);
}
break
;
}
case
cmdSubConfig
:
insn_subdev_config
(
card
,
subdev
,
val
);
...
...
@@ -429,38 +333,38 @@ void insn_config( comedi_t* card, int subdev, int channel, lsampl_t iotype, int
void
insn_subdev_config
(
comedi_t
*
card
,
int
subdev
,
lsampl_t
type
)
{
static
const
unsigned
char
chans
[
4
]
=
{
0
,
8
,
16
,
20
};
/* We can configure only one channel per 8-bit port (4-bit for CL and CH). */
lsampl_t
cmd
[
4
];
/* Ports A, B, CL, CH */
lsampl_t
cmd
=
102
;
comedi_insn
insn
;
memset
(
&
insn
,
0
,
sizeof
(
insn
));
insn
.
insn
=
INSN_CONFIG
;
insn
.
n
=
1
;
insn
.
data
=
&
cmd
;
insn
.
unused
[
0
]
=
type
;
insn
.
subdev
=
subdev
;
insn
.
chanspec
=
0
;
switch
(
type
)
{
case
1
:
/* TBI 24_0 */
cmd
[
0
]
=
cmd
[
1
]
=
cmd
[
2
]
=
cmd
[
3
]
=
INSN_CONFIG_DIO_INPUT
;
case
1
:
printf
(
"set subdev %d type: 'TBI 24/0'
\n
"
,
subdev
);
break
;
case
2
:
/* TBI 0_24 */
default:
cmd
[
0
]
=
cmd
[
1
]
=
cmd
[
2
]
=
cmd
[
3
]
=
INSN_CONFIG_DIO_OUTPUT
;
break
;
case
2
:
printf
(
"set subdev %d type: 'TBI 0/24'
\n
"
,
subdev
);
break
;
case
3
:
/* TBI 16_8 */
cmd
[
0
]
=
cmd
[
1
]
=
INSN_CONFIG_DIO_INPUT
;
cmd
[
2
]
=
cmd
[
3
]
=
INSN_CONFIG_DIO_OUTPUT
;
break
;
case
3
:
printf
(
"set subdev %d type: 'TBI 16/8'
\n
"
,
subdev
);
break
;
break
;
default:
printf
(
"set subdev %d type: UNKNOWN
\n
"
,
subdev
);
break
;
}
for
(
int
i
=
0
;
i
<
4
;
i
++
)
{
memset
(
&
insn
,
0
,
sizeof
(
insn
));
insn
.
insn
=
INSN_CONFIG
;
insn
.
n
=
1
;
insn
.
data
=
&
cmd
[
i
];
insn
.
subdev
=
subdev
;
insn
.
chanspec
=
CR_PACK
(
chans
[
i
],
0
,
0
);
if
(
comedi_do_insn
(
card
,
&
insn
)
<
0
)
{
fprintf
(
stderr
,
"can`t configure subdev subdev=%d type=%d"
,
subdev
,
type
);
exit
(
EXIT_FAILURE
);
}
if
(
comedi_do_insn
(
card
,
&
insn
)
<
0
)
{
fprintf
(
stderr
,
"can`t configure subdev subdev=%d type=%d"
,
subdev
,
type
);
exit
(
EXIT_FAILURE
);
}
}
extentions/MBTCPMaster/MBMaster.cc
View file @
9860cfce
// $Id: MBMaster.cc,v 1.11 2009/03/03 10:33:27 pv Exp $
// -----------------------------------------------------------------------------
#include <
math.
h>
#include <
cmat
h>
#include <sstream>
#include "Exceptions.h"
#include "Extentions.h"
...
...
extentions/ModbusSlave/MBSlave.cc
View file @
9860cfce
// $Id: MBSlave.cc,v 1.1 2009/01/11 19:08:45 vpashka Exp $
// -----------------------------------------------------------------------------
#include <
math.
h>
#include <
cmat
h>
#include <sstream>
#include "Exceptions.h"
#include "Extentions.h"
...
...
extentions/RTUExchange/RTUExchange.cc
View file @
9860cfce
// $Id: RTUExchange.cc,v 1.4 2009/01/23 23:56:54 vpashka Exp $
// -----------------------------------------------------------------------------
#include <
math.
h>
#include <
cmat
h>
#include <sstream>
#include "Exceptions.h"
#include "Extentions.h"
...
...
extentions/RTUExchange/RTUStorage.cc
View file @
9860cfce
...
...
@@ -2,7 +2,7 @@
//! \version $Id: RTUStorage.cc,v 1.1 2008/12/14 21:57:50 vpashka Exp $
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
#include <
math.
h>
#include <
cmat
h>
#include <iostream>
#include <iomanip>
#include <string>
...
...
extentions/RTUExchange/mtrconv.cc
View file @
9860cfce
...
...
@@ -3,7 +3,7 @@
// --------------------------------------------------------------------------
#include <iostream>
#include <iomanip>
#include <
math.
h>
#include <
cmat
h>
#include "Configuration.h"
#include "MTR.h"
// --------------------------------------------------------------------------
...
...
extentions/include/Calibration.h
View file @
9860cfce
#ifndef Calibration_H_
#define Calibration_H_
// -----------------------------------------------------------------------------
#include <
math.
h>
#include <
cmat
h>
#include <string>
#include <list>
#include <ostream>
...
...
extentions/lib/DigitalFilter.cc
View file @
9860cfce
// --------------------------------------------------------------------------
/*! $Id: DigitalFilter.cc,v 1.2 2009/01/16 23:16:42 vpashka Exp $ */
// --------------------------------------------------------------------------
#include <
math.
h>
#include <
cmat
h>
#include <iomanip>
#include <algorithm>
#include <iostream>
...
...
extentions/lib/MTR.cc
View file @
9860cfce
// --------------------------------------------------------------------------
//! \version $Id: MTR.cc,v 1.1 2008/12/14 21:57:50 vpashka Exp $
// --------------------------------------------------------------------------
#include <
math.
h>
#include <
cmat
h>
#include "modbus/ModbusRTUMaster.h"
#include "MTR.h"
// --------------------------------------------------------------------------
...
...
include/CallBackTimer.h
View file @
9860cfce
...
...
@@ -45,7 +45,7 @@ namespace UniSetTypes
LimitTimers
()
:
Exception
(
"LimitTimers"
){
printException
();
}
/*! err */
LimitTimers
(
const
string
err
)
:
Exception
(
err
){
printException
();
}
LimitTimers
(
const
st
d
::
st
ring
err
)
:
Exception
(
err
){
printException
();
}
};
};
//@}
...
...
@@ -135,7 +135,7 @@ class CallBackTimer
PassiveTimer
pt
;
};
typedef
list
<
TimerInfo
>
TimersList
;
typedef
std
::
list
<
TimerInfo
>
TimersList
;
TimersList
lst
;
// - id
...
...
include/Configuration.h
View file @
9860cfce
...
...
@@ -28,7 +28,6 @@
#define Configuration_H_
// --------------------------------------------------------------------------
// UniXML.h, unixml !!!!!!!!
#include <string>
#include <ostream>
#include "UniXML.h"
...
...
@@ -39,7 +38,6 @@
#include "Debug.h"
class
SystemGuard
;
/*
main Configuration
fileConf - ,
...
...
@@ -57,7 +55,7 @@ namespace UniSetTypes
class
Configuration
{
public
:
virtual
~
Configuration
();
virtual
~
Configuration
();
/*! xml- ( ) */
Configuration
(
int
argc
,
char
**
argv
,
const
std
::
string
xmlfile
=
""
);
...
...
@@ -78,7 +76,7 @@ namespace UniSetTypes
//
std
::
string
getProp
(
xmlNode
*
,
const
std
::
string
name
);
//
std
::
string
getPropByNodeName
(
const
std
::
string
&
nodename
,
const
std
::
string
&
prop
);
std
::
string
getPropByNodeName
(
const
std
::
string
&
nodename
,
const
std
::
string
&
prop
);
static
std
::
ostream
&
help
(
std
::
ostream
&
os
);
...
...
@@ -213,7 +211,7 @@ namespace UniSetTypes
ObjectId
localNode
;
std
::
string
fileConfName
;
std
::
string
imagesDir
;
std
::
string
imagesDir
;
std
::
string
confDir
;
std
::
string
dataDir
;
...
...
@@ -239,6 +237,4 @@ namespace UniSetTypes
}
// end of UniSetTypes namespace
#endif // Configuration_H_
include/DebugStream.h
View file @
9860cfce
...
...
@@ -14,11 +14,12 @@
#ifndef DEBUGSTREAM_H
#define DEBUGSTREAM_H
#ifdef __GNUG__
#pragma interface
#endif
//
#ifdef __GNUG__
//
#pragma interface
//
#endif
#include <iostream>
#include <string>
#ifdef TEST_DEBUGSTREAM
#include <string>
...
...
@@ -30,7 +31,7 @@ struct Debug {
CRIT
=
(
1
<<
2
)
// 4
};
static
const
type
ANY
=
type
(
INFO
|
WARN
|
CRIT
);
static
Debug
::
type
value
(
string
const
&
val
)
{
static
Debug
::
type
value
(
st
d
::
st
ring
const
&
val
)
{
if
(
val
==
"NONE"
)
return
Debug
::
NONE
;
if
(
val
==
"INFO"
)
return
Debug
::
INFO
;
if
(
val
==
"WARN"
)
return
Debug
::
WARN
;
...
...
@@ -113,7 +114,7 @@ public:
/// Sets the debugstreams' logfile to f.
void
logFile
(
char
const
*
f
);
inline
string
getLogFile
(){
return
fname
;
}
inline
st
d
::
st
ring
getLogFile
(){
return
fname
;
}
/// Returns true if t is part of the current debug level.
bool
debugging
(
Debug
::
type
t
=
Debug
::
ANY
)
const
...
...
@@ -180,7 +181,7 @@ private:
///
debugstream_internal
*
internal
;
bool
show_datetime
;
string
fname
;
st
d
::
st
ring
fname
;
};
...
...
include/MessageInterface.h
View file @
9860cfce
...
...
@@ -35,12 +35,12 @@
class
MessageInterface
{
public
:
virtual
~
MessageInterface
(){}
;
virtual
~
MessageInterface
(){}
virtual
std
::
string
getMessage
(
UniSetTypes
::
MessageCode
code
)
=
0
;
virtual
bool
isExist
(
UniSetTypes
::
MessageCode
code
)
=
0
;
virtual
UniSetTypes
::
MessageCode
getCode
(
const
std
::
string
&
msg
){
return
UniSetTypes
::
DefaultMessageCode
;
}
;
virtual
UniSetTypes
::
MessageCode
getCodeByIdName
(
const
std
::
string
&
name
){
return
UniSetTypes
::
DefaultMessageCode
;
}
;
virtual
UniSetTypes
::
MessageCode
getCode
(
const
std
::
string
&
msg
){
return
UniSetTypes
::
DefaultMessageCode
;
}
virtual
UniSetTypes
::
MessageCode
getCodeByIdName
(
const
std
::
string
&
name
){
return
UniSetTypes
::
DefaultMessageCode
;
}
virtual
std
::
ostream
&
printMessagesMap
(
std
::
ostream
&
os
)
=
0
;
};
...
...
include/SMonitor.h
View file @
9860cfce
...
...
@@ -18,14 +18,12 @@ class SMonitor:
// -----
protected
:
virtual
void
processingMessage
(
UniSetTypes
::
VoidMessage
*
msg
);
virtual
void
processingMessage
(
UniSetTypes
::
VoidMessage
*
msg
);
virtual
void
sysCommand
(
UniSetTypes
::
SystemMessage
*
sm
);
virtual
void
sensorInfo
(
UniSetTypes
::
SensorMessage
*
si
);
virtual
void
sensorInfo
(
UniSetTypes
::
SensorMessage
*
si
);
virtual
void
timerInfo
(
UniSetTypes
::
TimerMessage
*
tm
);
virtual
void
sigterm
(
int
signo
);
SMonitor
();
UniSetTypes
::
IDList
explode
(
const
string
str
,
char
sep
=
','
);
private
:
UniSetTypes
::
IDList
lst
;
...
...
include/UniSetTypes.h
View file @
9860cfce
...
...
@@ -28,13 +28,14 @@
#define UniSetTypes_H_
// --------------------------------------------------------------------------
#include <cstdlib>
#include <cstdio>
#include <string>
#include <list>
#include <limits>
#include <omniORB4/CORBA.h>
#include "UniSetTypes_i.hh"
#include "Mutex.h"
// -----------------------------------------------------------------------------------------
/*! */
inline
void
msleep
(
unsigned
int
m
)
{
usleep
(
m
*
1000
);
}
...
...
@@ -208,9 +209,12 @@ namespace UniSetTypes
return
std
::
atoi
(
str
);
unsigned
int
n
;
sscanf
(
str
,
"%x"
,
&
n
);
std
::
sscanf
(
str
,
"%x"
,
&
n
);
return
n
;
}
IDList
explode
(
const
std
::
string
str
,
char
sep
=
','
);
}
// -----------------------------------------------------------------------------------------
...
...
include/UniXML.h
View file @
9860cfce
...
...
@@ -42,7 +42,7 @@ class UniXML
{
public
:
xmlNode
*
getFirstNode
()
inline
xmlNode
*
getFirstNode
()
{
return
xmlDocGetRootElement
(
doc
);
}
...
...
src/ObjectRepository/UniSetTypes.cc
View file @
9860cfce
...
...
@@ -23,12 +23,13 @@
* \version $Id: UniSetTypes.cc,v 1.4 2009/01/16 23:16:42 vpashka Exp $
*/
// -----------------------------------------------------------------------------
#include <math.h>
#include "Configuration.h"
#include <cmath>
#include "UniSetTypes.h"
#include "Configuration.h"
// -----------------------------------------------------------------------------
using
namespace
std
;
using
namespace
UniSetTypes
;
// -----------------------------------------------------------------------------
float
UniSetTypes
::
fcalibrate
(
float
raw
,
float
rawMin
,
float
rawMax
,
float
calMin
,
float
calMax
,
bool
limit
)
...
...
@@ -162,3 +163,24 @@ using namespace UniSetTypes;
return
seq
;
}
// -------------------------------------------------------------------------
UniSetTypes
::
IDList
UniSetTypes
::
explode
(
const
string
str
,
char
sep
)
{
UniSetTypes
::
IDList
l
;
string
::
size_type
prev
=
0
;
string
::
size_type
pos
=
0
;
do
{
pos
=
str
.
find
(
sep
,
prev
);
string
s
(
str
.
substr
(
prev
,
pos
-
prev
));
if
(
!
s
.
empty
()
)
{
l
.
add
(
uni_atoi
(
s
.
c_str
())
);
prev
=
pos
+
1
;
}
}
while
(
pos
!=
string
::
npos
);
return
l
;
}
// ------------------------------------------------------------------------------------------
src/Processes/IOController.cc
View file @
9860cfce
...
...
@@ -25,7 +25,7 @@
// --------------------------------------------------------------------------
//#include <stream.h>
#include <sstream>
#include <
math.
h>
#include <
cmat
h>
#include "UniversalInterface.h"
#include "IOController.h"
#include "Debug.h"
...
...
src/Various/SMonitor.cc
View file @
9860cfce
...
...
@@ -191,25 +191,3 @@ void SMonitor::timerInfo( UniSetTypes::TimerMessage *tm )
}
// ------------------------------------------------------------------------------------------
UniSetTypes
::
IDList
SMonitor
::
explode
(
const
string
str
,
char
sep
)
{
UniSetTypes
::
IDList
l
;
string
::
size_type
prev
=
0
;
string
::
size_type
pos
=
0
;
do
{
pos
=
str
.
find
(
sep
,
prev
);
// cout << "add " << str.substr(prev,pos-prev) << endl;
string
s
(
str
.
substr
(
prev
,
pos
-
prev
));
if
(
!
s
.
empty
()
)
{
l
.
add
(
uni_atoi
(
s
.
c_str
())
);
prev
=
pos
+
1
;
}
}
while
(
pos
!=
string
::
npos
);
return
l
;
}
// ------------------------------------------------------------------------------------------
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