Esempio n. 1
0
Any VisibleEntity::toAny(const bool forceAll) const {
    Any a = Entity::toAny(forceAll);
    a.setName("VisibleEntity");

    AnyTableReader oldValues(a);
    bool visible;
    if (forceAll || (oldValues.getIfPresent("visible", visible) && visible != m_visible)) {
        a.set("visible", m_visible);
    }

    // Model and pose must already have been set, so no need to change anything
    return a;
}
Esempio n. 2
0
// RETURN: <0      => error
//         =0      => no error, no update
//         >0      => no error, update happened
//
int KPCMCIACard::refresh() {
//////////////////////////////////////////////
///////////// LINUX ONLY
///////////////////////////////////////////////
#ifdef __linux__
struct timeval tv;
cs_status_t status;
fd_set rfds;
int rc;
event_t event;
struct stat sb;
config_info_t cfg;
KPCMCIACard oldValues(*this);
int updated = 0;
oldValues._fd = -1;

#define CHECK_CHANGED(x, y) do { if (x.y != y) updated = 1; } while(0)

    /**
     *   Get any events on the pcmcia device
     */
tv.tv_sec = 0;  tv.tv_usec = 0;
     FD_ZERO(&rfds);
     FD_SET(_fd, &rfds);
     rc = select(_fd+1, &rfds, NULL, NULL, &tv);
     if (rc > 0) {
        rc = read(_fd, (void *)&event, 4);
        if (rc == 4) {
	   int thisEvent = -1;  // thisEvent is the index of event in event_tag
           for (unsigned int j = 0; j < NTAGS; j++) {
              if (event_tag[j].event == event) {
                 thisEvent = j;
                 break;
              }
              if (thisEvent < 0) return -1;
           }
        } else {
           return -1;
        }
     } else return updated;

     if (event == CS_EVENT_EJECTION_REQUEST) {
        _interrupt = -1;
        _ports = "";
        _device = "";
        _module = "";
        _type = "";
        _iotype = 0;
        _inttype = 0;
        _cfgbase = 0;
        _cardname = i18n("Empty slot.");
        _vcc = _vpp = _vpp2 = 0;
        return updated;
     }

     /**
      *   Read in the stab file.
      */
     if (!stat(_stabPath.latin1(), &sb) && sb.st_mtime >= _last) {
        TQFile f(_stabPath.latin1());

        if (f.open(IO_ReadOnly)) {
          TQTextStream ts(&f);
          bool foundit = false;
          TQString _thisreg = "^Socket %1: ";
          TQRegExp thisreg ( _thisreg.arg(_num) );

          if (flock(f.handle(), LOCK_SH)) return updated;

          _last = sb.st_mtime;

          // find the card
          while(!foundit) {
            TQString s;
            if (ts.eof()) break;
            s = ts.readLine();
            if (s.contains(thisreg)) {
               _cardname = s.right(s.length() - s.find(':') - 1);
               _cardname = _cardname.stripWhiteSpace();
               foundit = true;
               CHECK_CHANGED(oldValues, _cardname);
            }
          }

          // read it in
          if (foundit && !ts.eof()) {  // FIXME: ts.eof() is a bad error!!
            TQString s = ts.readLine();
            int end;
            s.simplifyWhiteSpace();

            end = s.find(TQRegExp("[ \r\t\n]"));
            s = s.remove(0, end+1);

            end = s.find(TQRegExp("[ \r\t\n]"));
            _type = s;
            _type.truncate(end);
            s = s.remove(0, end+1);

            end = s.find(TQRegExp("[ \r\t\n]"));
            _module = s;
            _module.truncate(end);
            s = s.remove(0, end+1);

            end = s.find(TQRegExp("[ \r\t\n]"));
            s = s.remove(0, end+1);

            end = s.find(TQRegExp("[ \r\t\n]"));
            _device = s;
            _device.truncate(end);
            s = s.remove(0, end+1);
            CHECK_CHANGED(oldValues, _type);
            CHECK_CHANGED(oldValues, _module);
            CHECK_CHANGED(oldValues, _device);
          }

          flock(f.handle(), LOCK_UN);
          f.close();
        } else return -1;
     } else return updated;


     /**
      *   Get the card's status and configuration information
      */
     status.Function = 0;
     ioctl(_fd, DS_GET_STATUS, &status);
     memset(&cfg, 0, sizeof(cfg));
     ioctl(_fd, DS_GET_CONFIGURATION_INFO, &cfg);
     // status is looked up in the table at the top
     if (cfg.Attributes & CONF_VALID_CLIENT) {
        if (cfg.AssignedIRQ == 0)
          _interrupt = -1;
        else _interrupt = cfg.AssignedIRQ;

        if (cfg.NumPorts1 > 0) {
           int stop = cfg.BasePort1 + cfg.NumPorts1;
           if (cfg.NumPorts2 > 0) {
              if (stop == cfg.BasePort2) {
                 _ports.sprintf("%#x-%#x", cfg.BasePort1, stop+cfg.NumPorts2-1);
              } else {
                 _ports.sprintf("%#x-%#x, %#x-%#x", cfg.BasePort1, stop-1,
                               cfg.BasePort2, cfg.BasePort2+cfg.NumPorts2-1);
              }
           } else {
              _ports.sprintf("%#x-%#x", cfg.BasePort1, stop-1);
           }
        }
        CHECK_CHANGED(oldValues, _ports);
        CHECK_CHANGED(oldValues, _interrupt);
     }

     _vcc = cfg.Vcc;
     _vpp = cfg.Vpp1;
     _vpp2 = cfg.Vpp2;
     CHECK_CHANGED(oldValues, _vcc);
     CHECK_CHANGED(oldValues, _vpp);
     CHECK_CHANGED(oldValues, _vpp2);
     _inttype = cfg.IntType;
     CHECK_CHANGED(oldValues, _inttype);
     _iotype = cfg.IOAddrLines;
     CHECK_CHANGED(oldValues, _iotype);
     _cfgbase = cfg.ConfigBase;
     CHECK_CHANGED(oldValues, _cfgbase);

     if (status.CardState & CS_EVENT_CARD_DETECT)
        _status |= CARD_STATUS_PRESENT;
     if (status.CardState & CS_EVENT_CARD_REMOVAL)
        _status &= ~CARD_STATUS_PRESENT;
     if (event & CS_EVENT_CARD_REMOVAL)
        _status &= ~CARD_STATUS_PRESENT;

     if (!(status.CardState & CS_EVENT_PM_SUSPEND)) {
        if (status.CardState & CS_EVENT_READY_CHANGE) {
           _status |= CARD_STATUS_READY;
           _status &= ~(CARD_STATUS_BUSY|CARD_STATUS_SUSPEND);
        } else {
           _status |= CARD_STATUS_BUSY;
           _status &= ~(CARD_STATUS_READY|CARD_STATUS_SUSPEND);
        }
     } else if (status.CardState & CS_EVENT_PM_SUSPEND) {
        _status |= CARD_STATUS_SUSPEND;
        _status &= ~(CARD_STATUS_READY|CARD_STATUS_BUSY);
     }

     CHECK_CHANGED(oldValues, _status);

return updated;
#else
return 0;
#endif
}
Esempio n. 3
0
double ConverterChannel::convert ( double oldValue, casa::SpectralCoordinate spectralCoordinate ) {
    std::vector<double> oldValues(1);
    oldValues[0] = oldValue;
    casa::Vector<double> newValues = convert( oldValues, spectralCoordinate );
    return newValues[0];
}