示例#1
0
WaterTowerWidget::WaterTowerWidget(int id, QWidget *parent) :
    QGroupBox(parent),
    ui(new Ui::WaterTowerWidget),
    uuid(NotifyPanel::instance()->uuid())
{
    ui->setupUi(this);

    setTitle(readableName(id));
    waterTower = WaterTower::instance(id);
    connect(waterTower, SIGNAL(waterLevelChanged(int)), this, SLOT(waterLevelChanged(int)));
    connect(waterTower, SIGNAL(deviceConnected()), this, SLOT(deviceConnect()));
    connect(waterTower, SIGNAL(deviceDisconnected()), this, SLOT(deviceDisconnect()));
    connect(waterTower, SIGNAL(highWaterLevelAlarm()), this, SLOT(highWaterLevelAlarm()));

    waterTower->getWaterLevel();
    ui->avatarWidget->setAvatar(QPixmap(QString(qApp->applicationDirPath() + "/images/watertower-%1.png").arg(id)));
    ui->progressBar->setRange(0, waterTower->getHeight());
    ui->progressBar->setFormat("%v");
    deviceDisconnect();
    connect(waterTower, SIGNAL(waterLevelRangeChanged(int,int)), ui->progressBar, SLOT(setRange(int,int)));

    enableWidget = new QCheckBox();
    enableWidget->setChecked(waterTower->isEnabled());

    enableAlarmWidget = new QCheckBox();
    enableAlarmWidget->setChecked(waterTower->isAlarmEnabled());

    addressWidget = new QSpinBox();
    addressWidget->setRange(0, 15);
    addressWidget->setValue(waterTower->getAddress());
    connect(addressWidget, SIGNAL(valueChanged(int)), this, SLOT(addressChanged(int)));

    radiusWidget = new QSpinBox();
    radiusWidget->setRange(20, 300);
    radiusWidget->setValue(waterTower->getRadius());
    connect(radiusWidget, SIGNAL(valueChanged(int)), this, SLOT(radiusChanged(int)));

    levelSensorHeightWidget = new QSpinBox();
    levelSensorHeightWidget->setRange(20, 100);
    levelSensorHeightWidget->setValue(waterTower->getLevelSensorHeight());
    connect(levelSensorHeightWidget, SIGNAL(valueChanged(int)), this, SLOT(levelSensorHeightChanged(int)));

    levelSensorNumberWidget = new QSpinBox();
    levelSensorNumberWidget->setRange(1, 8);
    levelSensorNumberWidget->setValue(waterTower->getSensorNumber());
    connect(levelSensorNumberWidget, SIGNAL(valueChanged(int)), this, SLOT(levelSensorNumberChanged(int)));

    getSampleIntervalWidget();
    connect(sampleIntervalWidget, SIGNAL(valueChanged(int)), this, SLOT(sampleIntervalChanged(int)));
    connect(enableWidget, SIGNAL(clicked(bool)), this, SLOT(readyForUse(bool)));
    connect(enableAlarmWidget, SIGNAL(clicked(bool)), this, SLOT(enableAlarm(bool)));
}
示例#2
0
文件: System.cpp 项目: forivall/nil
  void System::refreshDevices()
  {
    identifyXInputDevices();

    for ( Device* device : mDevices )
      if ( device->getHandler() == Device::Handler_DirectInput )
      {
        device->saveStatus();
        device->setStatus( Device::Status_Pending );
      }

    auto hr = mDirectInput->EnumDevices( DI8DEVCLASS_GAMECTRL,
      diDeviceEnumCallback, this, DIEDFL_ATTACHEDONLY );
    if ( FAILED( hr ) )
      NIL_EXCEPT_DINPUT( hr, "Could not enumerate DirectInput devices!" );

    for ( Device* device : mDevices )
      if ( device->getHandler() == Device::Handler_DirectInput
        && device->getSavedStatus() == Device::Status_Connected
        && device->getStatus() == Device::Status_Pending )
        deviceDisconnect( device );

    XINPUT_STATE state;
    for ( Device* device : mDevices )
    {
      if ( device->getHandler() == Device::Handler_XInput )
      {
        auto xDevice = static_cast<XInputDevice*>( device );
        auto status = mXInput->mFunctions.pfnXInputGetState( xDevice->getXInputID(), &state );
        if ( status == ERROR_DEVICE_NOT_CONNECTED )
        {
          if ( xDevice->getStatus() == Device::Status_Connected )
            deviceDisconnect( xDevice );
          else if ( xDevice->getStatus() == Device::Status_Pending )
            xDevice->setStatus( Device::Status_Disconnected );
        }
        else if ( status == ERROR_SUCCESS )
        {
          if ( xDevice->getStatus() == Device::Status_Disconnected )
            deviceConnect( xDevice );
          else if ( xDevice->getStatus() == Device::Status_Pending )
            xDevice->setStatus( Device::Status_Connected );
        }
        else
          NIL_EXCEPT( "XInputGetState failed" );
      }
    }
  }
示例#3
0
文件: System.cpp 项目: forivall/nil
  void System::onRawRemoval( HANDLE handle )
  {
    for ( auto device : mDevices )
    {
      if ( device->getHandler() != Device::Handler_RawInput )
        continue;

      auto rawDevice = static_cast<RawInputDevice*>( device );

      if ( rawDevice->getRawHandle() == handle )
      {
        deviceDisconnect( rawDevice );
        return;
      }
    }
  }
示例#4
0
文件: System.cpp 项目: forivall/nil
  void System::update()
  {
    // Run PnP & raw events if there are any
    mMonitor->update();

    // Make sure that we disconnect failed devices,
    // and update the rest
    for ( Device* device : mDevices )
      if ( device->isDisconnectFlagged() )
        deviceDisconnect( device );
      else
        device->update();

    // Run queued G-key events if using the SDK
    if ( mLogitechGKeys->isInitialized() )
      mLogitechGKeys->update();
  }
示例#5
0
void MainWidget::createTrayIcon()
{    
    trayIcon = createTrayObject(this);
    trayIcon->init();

#ifndef Q_OS_WIN32
    trayIcon->setIcon("qcma_off");
#else
    trayIcon->setIcon("tray/qcma_off_16");
#endif
    trayIcon->show();

    connect(trayIcon, SIGNAL(openConfig()), this, SLOT(openConfig()));
    connect(trayIcon, SIGNAL(openManager()), this, SLOT(openManager()));
    connect(trayIcon, SIGNAL(refreshDatabase()), this, SLOT(refreshDatabase()));
    connect(trayIcon, SIGNAL(showAboutDialog()), this, SLOT(showAboutDialog()));
    connect(trayIcon, SIGNAL(showAboutQt()), this, SLOT(showAboutQt()));
    connect(trayIcon, SIGNAL(stopServer()), this, SLOT(stopServer()));

    connect(managerForm, SIGNAL(deviceConnected(QString)), this, SLOT(deviceConnect(QString)));
    connect(managerForm, SIGNAL(deviceDisconnected()), this, SLOT(deviceDisconnect()));
    connect(managerForm, SIGNAL(messageSent(QString)), this, SLOT(receiveMessage(QString)));
}