void EmcAdapter::gatherDeviceData()
{
  if (!mConnected)
  {
    if (!connect())
      sleep(5);
    else
      mAvail.available();
  }
  else
  {
    if (!mEmcStatusBuffer->valid())
    {
      disconnect();
      return;
    }
    
    if(mEmcStatusBuffer->peek() == EMC_STAT_TYPE) {
      memcpy(&mEmcStatus, mEmcStatusBuffer->get_address(), sizeof(EMC_STAT));
      actual();
      commanded();
      spindle();
      feedrate();
      program();
      machine();
      execution();
      alarms();
    }
  } 
}
示例#2
0
static void dbg_output(int level,const char* prefix, const char* format, va_list ap,
    const char* alarmComp = 0, const char* alarmInfo = 0)
{
    void (*relay)(int,const char*,const char*,const char*) = s_relay;
    void (*alarms)(const char*,int,const char*,const char*) = s_alarms;
    bool out = (s_output || s_intout || relay) && (prefix || format);
    bool alarm = alarmComp && format && (alarms || relay);
    if (!(out || alarm))
	return;
    char buf[OUT_BUFFER_SIZE];
    unsigned int n = Debugger::formatTime(buf,s_fmtstamp);
    unsigned int l = s_indent*2;
    if (l >= sizeof(buf)-n)
	l = sizeof(buf)-n-1;
    ::memset(buf+n,' ',l);
    n += l;
    buf[n] = 0;
    l = sizeof(buf)-n-2;
    if (prefix)
	::strncpy(buf+n,prefix,l);
    n = ::strlen(buf);
    l = sizeof(buf)-n-2;
    char* msg = buf+n;
    if (format) {
	::vsnprintf(msg,l,format,ap);
	buf[OUT_BUFFER_SIZE - 2] = 0;
    }
    if (relay) {
	relay(level,buf,alarmComp,alarmInfo);
	return;
    }
    if (out)
	common_output(level,buf);
    if (alarm)
	alarms(msg,level,alarmComp,alarmInfo);
}
示例#3
0
void AppManager::rescan()
{
    m_appList.clear();
    m_apps.clear();

    AppInfo settingsApp(QUuid(SETTINGS_APP_UUID), false, gettext("Settings"), gettext("System app"));
    m_appList.append(settingsApp.uuid());
    m_apps.insert(settingsApp.uuid(), settingsApp);
    AppInfo watchfaces(QUuid("18e443ce-38fd-47c8-84d5-6d0c775fbe55"), false, gettext("Watchfaces"), gettext("System app"));
    m_appList.append(watchfaces.uuid());
    m_apps.insert(watchfaces.uuid(), watchfaces);
    if (m_pebble->capabilities().testFlag(CapabilityHealth)) {
        AppInfo health(QUuid("36d8c6ed-4c83-4fa1-a9e2-8f12dc941f8c"), false, gettext("Health"), gettext("System app"), true);
        m_appList.append(health.uuid());
        m_apps.insert(health.uuid(), health);
    }
    AppInfo music(QUuid("1f03293d-47af-4f28-b960-f2b02a6dd757"), false, gettext("Music"), gettext("System app"));
    m_appList.append(music.uuid());
    m_apps.insert(music.uuid(), music);
    if(m_pebble->capabilities().testFlag(CapabilityWeather)) {
        AppInfo weather(WeatherApp::appUUID, false, gettext("Weather"), gettext("System app"), true);
        m_appList.append(weather.uuid());
        m_apps.insert(weather.uuid(), weather);
    }
    if(m_pebble->capabilities().testFlag(CapabilitySendSMS)) {
        AppInfo sendsms(SendTextApp::appUUID, false, SendTextApp::appName, gettext("System app"), true);
        m_appList.append(sendsms.uuid());
        m_apps.insert(sendsms.uuid(), sendsms);
    }
    AppInfo notifications(QUuid("b2cae818-10f8-46df-ad2b-98ad2254a3c1"), false, gettext("Notifications"), gettext("System app"));
    m_appList.append(notifications.uuid());
    m_apps.insert(notifications.uuid(), notifications);
    AppInfo alarms(QUuid("67a32d95-ef69-46d4-a0b9-854cc62f97f9"), false, gettext("Alarms"), gettext("System app"));
    m_appList.append(alarms.uuid());
    m_apps.insert(alarms.uuid(), alarms);
    AppInfo ticToc(QUuid("8f3c8686-31a1-4f5f-91f5-01600c9bdc59"), true, "Tic Toc", gettext("Default watchface"));
    m_appList.append(ticToc.uuid());
    m_apps.insert(ticToc.uuid(), ticToc);

    QDir dir(m_pebble->storagePath() + "/apps/");
    qDebug() << "Scanning Apps dir" << dir.absolutePath();
    Q_FOREACH(const QString &path, dir.entryList(QDir::Dirs | QDir::Readable)) {
        QString appPath = dir.absoluteFilePath(path);
        if (dir.exists(path + "/appinfo.json")) {
            scanApp(appPath);
        } else if (QFileInfo(appPath).isFile()) {
            scanApp(appPath);
        }
    }

    QSettings settings(m_pebble->storagePath() + "/apps.conf", QSettings::IniFormat);
    QStringList storedList = settings.value("appList").toStringList();
    if (storedList.isEmpty()) {
        // User did not manually sort the app list yet... We can stop here.
        return;
    }
    // Run some sanity checks
    if (storedList.count() != m_appList.count()) {
        qWarning() << "Installed apps not matching order config. App sort order might be wrong.";
        return;
    }
    foreach (const QUuid &uuid, m_appList) {
        if (!storedList.contains(uuid.toString())) {
            qWarning() << "Installed apps and stored config order cannot be matched. App sort order might be wrong.";
            return;
        }
    }
    // All seems fine, repopulate m_appList
    m_appList.clear();
    foreach (const QString &storedId, storedList) {
        m_appList.append(QUuid(storedId));
    }