int main(void) { _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); //Check for memoryLeaks. const char *path = "syntax/ass.asm"; startScanning(path); system("pause"); return 0; }
CLSSIS3820ScalerControlsView::CLSSIS3820ScalerControlsView(CLSSIS3820Scaler *scaler, QWidget *parent) : QWidget(parent) { // Initialize member variables. scaler_ = 0; // Create UI elements. acquisitionModeBox_ = new QComboBox; startButton_ = new QPushButton(QIcon(":/22x22/media-playback-start.png"), "Start"); startButton_->setMaximumHeight(25); stopButton_ = new QPushButton(QIcon(":/22x22/media-playback-stop.png"), "Stop"); stopButton_->setMaximumHeight(25); statusLabel_ = new QLabel; dwellTimeBox_ = new QDoubleSpinBox; dwellTimeBox_->setFixedWidth(100); dwellTimeBox_->setAlignment(Qt::AlignCenter); scansPerBufferBox_ = new QSpinBox; scansPerBufferBox_->setFixedWidth(100); scansPerBufferBox_->setAlignment(Qt::AlignCenter); totalScansBox_ = new QSpinBox; totalScansBox_->setFixedWidth(100); totalScansBox_->setAlignment(Qt::AlignCenter); // Create and set layouts. QHBoxLayout *buttonsLayout = new QHBoxLayout; buttonsLayout->addWidget(startButton_); buttonsLayout->addWidget(stopButton_); QVBoxLayout *statusLayout = new QVBoxLayout; statusLayout->addWidget(statusLabel_, 0, Qt::AlignCenter); statusLayout->addLayout(buttonsLayout); statusLayout->addWidget(acquisitionModeBox_, 0, Qt::AlignCenter); QGridLayout *controlsLayout = new QGridLayout(); controlsLayout->addWidget(new QLabel("Dwell Time: "), 0, 0, 1, 1, Qt::AlignRight); controlsLayout->addWidget(dwellTimeBox_, 0, 1); controlsLayout->addWidget(new QLabel("Scans per Buffer: "), 1, 0, 1, 1, Qt::AlignRight); controlsLayout->addWidget(scansPerBufferBox_, 1, 1); controlsLayout->addWidget(new QLabel("Total Scans: "), 2, 0, 1, 1, Qt::AlignRight); controlsLayout->addWidget(totalScansBox_, 2, 1); QHBoxLayout *layout = new QHBoxLayout; layout->addLayout(statusLayout); layout->addLayout(controlsLayout); setLayout(layout); // Make connections. connect(startButton_, SIGNAL(clicked()), this, SLOT(startScanning())); connect(stopButton_, SIGNAL(clicked()), this, SLOT(stopScanning())); connect(acquisitionModeBox_, SIGNAL(currentIndexChanged(int)), this, SLOT(setContinuous())); connect(dwellTimeBox_, SIGNAL(editingFinished()), this, SLOT(setDwellTime())); connect(scansPerBufferBox_, SIGNAL(editingFinished()), this, SLOT(setScansPerBuffer())); connect(totalScansBox_, SIGNAL(editingFinished()), this, SLOT(setTotalScans())); // Current settings. setScaler(scaler); refresh(); }
int main(int argc, char * argv[]) { int i; buffer_amount = 0; scanning_done = FALSE; // Let's try to guarantee proper usage if (argc != 3) { write(STDERR_FILENO, argc_error, strlen(argc_error)); exit(1); } file_list = fopen(argv[2],"r"); // If file is invalid or isn't loaded for some reason, there is no point of moving on if (file_list == NULL) { write(STDERR_FILENO, unable_to_open, strlen(unable_to_open)); exit(1); } // How many threads will be indexing int indexer_amount = atoi(argv[1]); scan_buffer = malloc(indexer_amount * 10 * sizeof(char *)); int j; for(j = 0; j < indexer_amount * 10; ++j){ scan_buffer[j] = malloc(513 * sizeof(char *)); } // Initialize hashtable int hash_init = init_index(); if (hash_init != 0){ write(STDERR_FILENO, hash_error, strlen(hash_error)); exit(1); } // Malloc scan_buffer scan_buffer_size = 10; scan_buffer = malloc(scan_buffer_size * sizeof(char *)); for (i = 0; i < scan_buffer_size; ++i) { scan_buffer[i] = malloc(513 * sizeof(char *)); } pthread_mutex_init(&mutex_one, NULL); pthread_mutex_init(&mutex_advanced, NULL); //TESTING PURPOSES ONLY (using old index.c) pthread_mutex_init(&mutex_test, NULL); pthread_cond_init(&empty_cond, NULL); pthread_cond_init(&fill_cond, NULL); pthread_cond_init(&indexed_cond, NULL); pthread_cond_init(&indexed_noticed_cond, NULL); finished_activations = 0; pthread_t index_threads[indexer_amount]; createIndexThreads(index_threads, indexer_amount); pthread_t search_thread; pthread_create(&search_thread, NULL, startSearch, NULL); startScanning(); for (i=0; i < indexer_amount; i++) { //printf("JOIN %d?\nINDEX Thread %u\n\n",i,index_threads[i]); if(pthread_join(index_threads[i], NULL)) printf("HERE's YOUR PROBLEM!\n"); } indexing_done = TRUE; while(quit_search != TRUE){ pthread_cond_signal(&indexed_cond); } pthread_join(search_thread, NULL); return 0; }
CLSSIS3820ScalerControlsView::CLSSIS3820ScalerControlsView(CLSSIS3820Scaler *scaler, QWidget *parent) : QWidget(parent) { // Initialize member variables. scaler_ = 0; // Create UI elements. modeChoice_ = new QComboBox; modeChoice_->addItems(QStringList() << "Single Shot" << "Continuous"); modeChoice_->setCurrentIndex(0); startButton_ = new QPushButton(QIcon(":/22x22/media-playback-start.png"), "Start"); startButton_->setMaximumHeight(25); stopButton_ = new QPushButton(QIcon(":/22x22/media-playback-stop.png"), "Stop"); stopButton_->setMaximumHeight(25); status_ = new QLabel; status_->setPixmap(QIcon(":/32x32/greenLEDOff.png").pixmap(25)); time_ = new QSpinBox; time_->setRange(0, 1000000); time_->setValue(1000); time_->setSuffix(" ms"); time_->setFixedWidth(100); time_->setAlignment(Qt::AlignCenter); scansPerBuffer_ = new QSpinBox; scansPerBuffer_->setRange(0, 10000); scansPerBuffer_->setValue(1); scansPerBuffer_->setFixedWidth(100); scansPerBuffer_->setAlignment(Qt::AlignCenter); totalScans_ = new QSpinBox; totalScans_->setRange(0, 10000); totalScans_->setValue(1); totalScans_->setFixedWidth(100); totalScans_->setAlignment(Qt::AlignCenter); // Create and set layouts. QHBoxLayout *startAndStopButtons = new QHBoxLayout; startAndStopButtons->addWidget(startButton_); startAndStopButtons->addWidget(stopButton_); QVBoxLayout *statusAndModeLayout = new QVBoxLayout; statusAndModeLayout->addWidget(status_, 0, Qt::AlignCenter); statusAndModeLayout->addLayout(startAndStopButtons); statusAndModeLayout->addWidget(modeChoice_, 0, Qt::AlignCenter); QHBoxLayout *timeLayout = new QHBoxLayout; timeLayout->addWidget(new QLabel("Dwell Time:"), 0, Qt::AlignRight); timeLayout->addWidget(time_); QHBoxLayout *scansPerBufferLayout = new QHBoxLayout; scansPerBufferLayout->addWidget(new QLabel("Scans per Buffer:"), 0, Qt::AlignRight); scansPerBufferLayout->addWidget(scansPerBuffer_); QHBoxLayout *totalScansLayout = new QHBoxLayout; totalScansLayout->addWidget(new QLabel("Total Scans"), 0, Qt::AlignRight); totalScansLayout->addWidget(totalScans_); QVBoxLayout *spinBoxLayout = new QVBoxLayout; spinBoxLayout->addLayout(timeLayout); spinBoxLayout->addLayout(scansPerBufferLayout); spinBoxLayout->addLayout(totalScansLayout); QHBoxLayout *layout = new QHBoxLayout; layout->addLayout(statusAndModeLayout); layout->addLayout(spinBoxLayout); setLayout(layout); // Make connections. connect(startButton_, SIGNAL(clicked()), this, SLOT(startScanning())); connect(stopButton_, SIGNAL(clicked()), this, SLOT(stopScanning())); connect(modeChoice_, SIGNAL(currentIndexChanged(int)), this, SLOT(setContinuous())); connect(time_, SIGNAL(editingFinished()), this, SLOT(setDwellTime())); connect(scansPerBuffer_, SIGNAL(editingFinished()), this, SLOT(setScansPerBuffer())); connect(totalScans_, SIGNAL(editingFinished()), this, SLOT(setTotalScans())); // Current settings. setScaler(scaler); }