示例#1
0
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -    
void CapacityRegion::initBuild(xmlNodePtr cur)
{
  // Get input file
  xmlNodePtr region_node = XMLinput->get_xpath_element(cur,"model/CapacityRegion");

  const char* input_path = XMLinput->get_xpath_content(region_node,"input_file");

  FILE *input_file = fopen(input_path,"r");

  // Populate build schedule
  populateSchedule(input_file);
  // Close the files that you open
  fclose(input_file);
};
void MainWindow::processData(QString data)
{
    if (data == "NC")
    {
        this->setWindowTitle("IT Equipment Reservations - [NETWORK ERROR DETECTED]");
        ui->connectionIndicator->setText("API can not reach server");
    }
    else if ( data != EMPTY_DB_ENTRY )
    {                              // Work around for an error that happenes under very specific conditions
        ui->connectionIndicator->setText("Connected to server");
        this->setWindowTitle("IT Equipment Reservations");

        ui->deliveriesTable->selectRow(-1);
        ui->pickupsTable->selectRow(-1);

        QStringList dataList = data.split(INCOMING_RESULT_DELIMETER);

        switch( socketConn.lastQuery.first )
        {
            case DELIVERY_QUERY:

                switch( socketConn.lastQuery.second )
                {
                    case 1:
                        // Daily deliveries update
                        populateReservations(dataList);
                        break;
                    case 2:
                        // Grab Links table
                        populateLinks(dataList);
                        break;
                    case 3:
                        // Grab Inventory
                        populateInventory(dataList);
                        break;
                    case 4:
                        // Grab Schedule
                        populateSchedule(dataList);
                        break;
                    case 5:
                        // Grab Room Names
                        populateRooms(dataList);
                        break;
                    case 6:
                        // Grab Pickups
                        populatePickups(dataList);

                        break;

                    default:
                        qDebug() << "Error in delivery query [ lastQuery.second ]";
                        break;
                }

                break; // END DELIVERY QUERY CASE

            case DEVICE_QUERY:

                switch( socketConn.lastQuery.second )
                {
                    case 1:
                        // All Devices

                    default:
                        qDebug() << "Error in devie query [ lastQuery.second ]";
                        break;
                }

                break; // END DEVICE QUERY CASE

            case CONN_QUERY:

                switch( socketConn.lastQuery.second )
                {
                    case 1:
                        if (data == "y")
                        {
                            this->setWindowTitle("IT Equipment Reservations");
                            ui->connectionIndicator->setText("Connected to API");
                            connectedToApi = true;
                        }
                        else
                        {
                            this->setWindowTitle("IT Equipment Reservations - [NETWORK ERROR DETECTED]");
                            ui->connectionIndicator->setText("Not connected to API");
                            connectedToApi = false;
                        }
                    break;

                    case 2:
                        if (data == "y")
                        {
                            this->setWindowTitle("IT Equipment Reservations");
                            ui->connectionIndicator->setText("Connected to server");
                            apiConnectedToServer = true;
                        }
                        else
                        {
                            if(connectedToApi)
                            {
                                this->setWindowTitle("IT Equipment Reservations - [NETWORK ERROR DETECTED]");
                                ui->connectionIndicator->setText("API not connected to server");
                                apiConnectedToServer = false;
                            }
                            else
                            {
                                apiConnectedToServer = false;
                            }
                        }
                    break;

                    default:
                        qDebug() << "Error in conn query [ lastQuery.second ]";
                        break;
                }

                break; // END CONN QUERY

            default:
                qDebug() << "Error Processing Data";
                break;
        }
    }
    else
    {
        this->setWindowTitle("IT Equipment Reservations - [NETWORK ERROR DETECTED]");
        qDebug() << "No data returned from server";
        ui->connectionIndicator->setText("API Unreachable");
    }
}