Commit c8e01bfe authored by Vinogradov Aleksei's avatar Vinogradov Aleksei

добавил параметр для настройки задержки считывания аналоговых каналов

parent 8929597c
......@@ -42,10 +42,10 @@ ComediInterface::~ComediInterface()
}
// -----------------------------------------------------------------------------
int ComediInterface::getAnalogChannel( int subdev, int channel, int range, int aref ) const
int ComediInterface::getAnalogChannel( int subdev, int channel, int range, int aref, int adelay ) const
{
lsampl_t data = 0;
int ret = comedi_data_read_delayed(card, subdev, channel, range, aref, &data, 10000);
int ret = comedi_data_read_delayed(card, subdev, channel, range, aref, &data, adelay);
if( ret < 0 )
{
......
......@@ -32,7 +32,7 @@ namespace uniset
virtual ~ComediInterface();
// throw uniset::Exception
virtual int getAnalogChannel( int subdev, int channel, int range = 0, int aref = AREF_GROUND ) const;
virtual int getAnalogChannel( int subdev, int channel, int range = 0, int aref = AREF_GROUND, int adelay = 10 * 1000 ) const; // adelay = 10 мкс
// throw uniset::Exception
virtual void setAnalogChannel( int subdev, int channel, int data, int range = 0, int aref = AREF_GROUND ) const;
......
......@@ -37,7 +37,7 @@ namespace uniset
{
os << "(" << inf.si.id << ")" << uniset_conf()->oind->getMapName(inf.si.id)
<< " card=" << inf.ncard << " channel=" << inf.channel << " subdev=" << inf.subdev
<< " aref=" << inf.aref << " range=" << inf.range
<< " aref=" << inf.aref << " range=" << inf.range << " adelay=" << inf.adelay
<< " default=" << inf.defval << " safeval=" << inf.safeval;
if( inf.cal.minRaw != inf.cal.maxRaw )
......@@ -599,7 +599,7 @@ namespace uniset
{
if( it->stype == UniversalIO::AI )
{
int val = card->getAnalogChannel(it->subdev, it->channel, it->range, it->aref);
int val = card->getAnalogChannel(it->subdev, it->channel, it->range, it->aref, it->adelay);
iolog3 << myname << "(iopoll): read AI "
<< " sid=" << it->si.id
......@@ -869,6 +869,7 @@ namespace uniset
inf->disable_testmode = IOBase::initIntProp(it, "disable_testmode", prop_prefix, false);
inf->aref = 0;
inf->range = 0;
inf->adelay = 10000;
if( inf->stype == UniversalIO::AI || inf->stype == UniversalIO::AO )
{
......@@ -891,6 +892,8 @@ namespace uniset
<< ". Must be aref=[0..3]" << endl;
return false;
}
inf->adelay = IOBase::initIntProp(it, "adelay", prop_prefix, false);
}
iolog3 << myname << "(readItem): add: " << inf->stype << " " << inf << endl;
......@@ -1019,7 +1022,7 @@ namespace uniset
else if( it->stype == UniversalIO::AI )
{
card->configureChannel(it->subdev, it->channel, ComediInterface::AI);
it->df.init( card->getAnalogChannel(it->subdev, it->channel, it->range, it->aref) );
it->df.init( card->getAnalogChannel(it->subdev, it->channel, it->range, it->aref, it->adelay) );
}
else if( it->stype == UniversalIO::AO )
card->configureChannel(it->subdev, it->channel, ComediInterface::AO);
......
......@@ -276,6 +276,8 @@ namespace uniset
3 - analog ref = other (undefined)
*/
int aref;
int adelay; /*! Задержка на чтение аналоговых входов с мультиплексированием ( в мкс ) */
/*! Измерительный диапазон
0 - -10В - 10В
......
......@@ -72,6 +72,7 @@ int subdev = 0;
int chan = 0;
int range = 0;
int aref = AREF_GROUND;
int adelay = 10 * 1000; // 10 мкс
static struct option longopts[] =
{
......@@ -79,6 +80,7 @@ static struct option longopts[] =
{ "read", required_argument, 0, 'r' },
{ "subdev", required_argument, 0, 's' },
{ "aref", required_argument, 0, 'a' },
{ "adelay", required_argument, 0, 'y' },
{ "range", required_argument, 0, 'x' },
{ "device", required_argument, 0, 'd' },
{ "open_xml", required_argument, 0, 'o' },
......@@ -143,6 +145,10 @@ int main(int argc, char* argv[])
range = uni_atoi(optarg);
break;
case 'y':
adelay = atoi(optarg);
break;
case 'a':
aref = uni_atoi(optarg);
break;
......@@ -202,7 +208,7 @@ int main(int argc, char* argv[])
while(1)
{
if(comedi_data_read_delayed(card, subdev, chan, range, aref, &data, 10000) < 0)
if(comedi_data_read_delayed(card, subdev, chan, range, aref, &data, adelay) < 0)
{
fprintf(stderr, "can't read from channel %d\n", chan);
exit(EXIT_FAILURE);
......
......@@ -28,6 +28,7 @@
int subdev = 0;
int range = 0;
int aref = AREF_GROUND;
int adelay = 10 * 1000; // 10 мкс
int chan[50];
int blink_msec = 300;
......@@ -42,6 +43,7 @@ static struct option longopts[] =
{ "device", required_argument, 0, 'd' },
{ "verbose", no_argument, 0, 'v' },
{ "aref", required_argument, 0, 'z' },
{ "adelay", required_argument, 0, 'y' },
{ "range", required_argument, 0, 'x' },
{ "config", required_argument, 0, 'c' },
{ "autoconf", no_argument, 0, 'a' },
......@@ -174,6 +176,10 @@ int main(int argc, char* argv[])
range = atoi(optarg);
break;
case 'y':
adelay = atoi(optarg);
break;
case 'z':
aref = atoi(optarg);
break;
......@@ -312,7 +318,7 @@ int main(int argc, char* argv[])
if( autoconf )
insn_config(card, subdev, chan[k], 100, range, aref);
int ret = comedi_data_read_delayed(card, subdev, chan[k], range, aref, &data, 10000);
int ret = comedi_data_read_delayed(card, subdev, chan[k], range, aref, &data, adelay);
if( ret < 0)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment