void CUIAuctionNew::updateFavoriteList()
{
	if (m_pListFavorite == NULL)
		return;

	int		i;
	int		nMax = m_pAuction->getFavoriteCount();

	m_pTxtFavCount->SetText( CTString(0, "%d/%d", nMax, MAX_LIKE_REG_COUNT) );

	TradeAgentItem* pItem;	
	int			nListItemCnt;
	CUIManager* pUIMgr = CUIManager::getSingleton();	
	
	nListItemCnt = m_pListFavorite->getListItemCount();

	m_pListFavorite->SetItemShowNum(nMax);

	CUIListItem*	pListItem; 
	CUIListItem*	pTmpItem;

	pListItem = m_pListFavorite->GetListItemTemplate();

	for (i = 0; i < MAX_LIKE_REG_COUNT; ++i)
	{
		if (i >= nListItemCnt)
			m_pListFavorite->AddListItem((CUIListItem*)pListItem->Clone());

		pTmpItem = (CUIListItem*)m_pListFavorite->GetListItem(i);

		if (pTmpItem == NULL)
			continue;

		if (i >= nMax)
		{
			clearResult(eRESULT_TYPE_FAVORITE, pTmpItem);
			continue;
		}

		pItem = m_pAuction->getFavoriteItem(i);

		if (pItem == NULL)
		{
			continue;
		}

		updateResult(eRESULT_TYPE_FAVORITE, pItem, pTmpItem);
	}

	m_pListFavorite->setCurSel(-1);
	m_pListFavorite->UpdateList();

	//관심물품이 바뀌게 되면, 검색 갱신
	updateSearchList();

	if (nMax >= MAX_LIKE_REG_COUNT)
	{
		m_pBtnRegFav->SetEnable(FALSE);
	}
}
Example #2
0
// sequence operations
bool MorphChannel::update(Entity& result, const Entity& rest, unsigned int elapsed_time)
{
	if(updateSelf(elapsed_time))
		return updateResult(result, rest);
	
	return false;
}
Example #3
0
void QTestLibModel::TestItem::replace(TestItem *item, int first, int last)
{
    QLinkedList<TestItem*>::iterator firstIt = item->mChildren.begin();
    QLinkedList<TestItem*>::iterator lastIt = (last < 0) ? item->mChildren.end() : item->mChildren.begin();

    while (first-- > 0)
        firstIt++;
    while (last-- > 0)
        lastIt++;
    last++;
    while (++last < 0)
        lastIt--;

    while (firstIt != lastIt) {
        TestItem *child = *firstIt;
        firstIt = item->mChildren.erase(firstIt);
        item->mChildrenCount--;

        mChildren.append(child);
        child->mParent = this;
        mChildrenCount++;
    }

    updateResult(item->mResult);
}
Example #4
0
void dfs(int nowv, int cost)
{
	static int w = 0;
	//printf("Dfs: the %d times\n", w++);
	//printf("node: %d cost: %d\n", nowv, cost);

	if(cost > min_cost) return;
	
	visited[nowv] = true;
	visitnum++;

	if(nowv == end){
		//printf("\nFind one sulution!  nowv: %d visited: %d  and cost: %d\n", nowv, visitnum, cost);
		bool flag = checkSolution(cost);
		if(true == flag){
			printf("\nFind one sulution!  nowv: %d visited: %d  and cost: %d\n", nowv, visitnum, cost);
			updateResult(visitnum-1, cost); //  visitnum个点被访问,产生visitnum-1条边
		}
		visited[nowv] = false;
		visitnum--;
		return ; 
	}

	for(int nextv = 0; nextv < MAXV; nextv++){
		if(isValidE(nowv, nextv, cost)){
			possible_result[visitnum-1] = netMap[nowv][nextv].num;
			dfs(nextv, cost + netMap[nowv][nextv].cost);
		}
	}
	
	visitnum--;
	visited[nowv] = false;
}
vector<vector<int> > subsetsHelper(vector<int> v, vector<int> temp,
									vector<vector<int> > r, int s, int e, int index) {
	r = updateResult(r, temp, index);
	for(int i=s; i<=e; i++) {
		temp[index] = v[i];
		//printVector(temp);
		r = subsetsHelper(v, temp, r, s+1, e, index+1);
		s += 1;
	}
	return r;
}
void QAbstractFilterProxyModel::setSourceModel(QAbstractItemModel* sourceModel)
{
	if (d->filterModel->sourceModel()){
		disconnect(d->filterModel->sourceModel(), 0, this, 0);
	}
    QSortFilterProxyModel::setSourceModel(sourceModel);
    d->filterModel->setSourceModel(sourceModel);
	connect(d->filterModel->sourceModel(), SIGNAL(modelReset()), this, SLOT(updateResult()));
	connect(d->filterModel->sourceModel(), SIGNAL(rowsInserted(QModelIndex, int , int)), this, SLOT(updateResult()));
	connect(d->filterModel->sourceModel(), SIGNAL(rowsRemoved(QModelIndex, int , int)), this, SLOT(updateResult()));
    emitResultCountChanged();
}
void QAbstractFilterProxyModel::setFilterModel(QAbstractFilterModel* filterModel)
{
    if (d->filterModel){
        disconnect(d->filterModel);
    }
    d->filterModel = filterModel;
    connect(d->filterModel, SIGNAL(dataChanged(QModelIndex, QModelIndex)), this, SLOT(updateResult()));
    connect(d->filterModel, SIGNAL(modelReset()), this, SLOT(updateResult()));
    connect(d->filterModel, SIGNAL(modeChanged(QAdvancedItemViews::FilterProxyMode)), this, SLOT(updateResult()));
    connect(d->filterModel, SIGNAL(matchModeChanged(QAdvancedItemViews::FilterMatchMode)), this, SLOT(updateResult()));
    d->filterModel->setSourceModel(sourceModel());
}
Example #8
0
void ShotDialog::shotStartChange( const QString & value )
{
	float val = value.toDouble();
	bool isFloat = (value.indexOf(".")>=0);
	mShotEnd->setEnabled( !isFloat );
	if( isFloat )
		val = (int)(val + .99);
	if( val > mShotEnd->text().toDouble() )
		mShotEnd->setText( value );
	((QIntValidator*)mShotEnd->validator())->setBottom( (int)val );
	updateResult();
}
Example #9
0
int main(int argc, char **argv) {
    
    // #if TEST_MODE
    // // Initialize test data
    // int data[MAXSIZE] = { 2, 20, 37, 22, 6, 3 };
    
    // #else
    // // Receive input from user or open file
    // int data[MAXSIZE];
    // int cnt = getData(data);
    // printf("Inputted data count = %d\n", cnt);
    // #endif
    
    // Handle data and processing
    RESULT set = { 0, 0, 0, 0, 0, 0, 0 }; /*Initialize results to zero*/
    INT_NODE top;
    top.next = NULL;
    
    printf("Address of top      = [%p]\n", &top);
    printf("Address of top.next = [%p]\n", top.next);
    getRawData(&top);
    updateResult(&set, top.next);
    
    printRawData(top.next);
    
    printResult(&set);
    
    // updateResult(&set, top.next);
    // printResult(&set);
    
    // updateResult(&set, top.next);
    // printResult(&set);
    
    // Output to screen
    print_h1st0gram(top.next);

    return 0;
}
Example #10
0
void RecordWorkThread::run()
{
    recorderFlag = false;
    anares.clear();
    CurrentStaus cstatus;


    workbook *wb = new workbook();
    xf_t* xf = wb->xformat();
    worksheet* ws;
    ws = wb->sheet("sheet1");
    setTitle(ws,xf);
    int cnt = 1;
    int sheetNUM = 1;
    overflow = false;
    bool first = true;

    Util::SysLogD("charge type : %d %f %f %f\n ",charge_type,power_charge_normal,power_charge_peak,power_charge_valley);
    Util::SysLogD("normal : %d %d %d %d %d %d\n ",normal_period[0],normal_period[1],normal_period[2],normal_period[3],normal_period[4],normal_period[5]);
    Util::SysLogD("peak : %d %d %d %d %d %d\n ",peak_period[0],peak_period[1],peak_period[2],peak_period[3],peak_period[4],peak_period[5]);
    Util::SysLogD("valley : %d %d %d %d %d %d\n ",valley_period[0],valley_period[1],valley_period[2],valley_period[3],valley_period[4],valley_period[5]);
    while(!recorderFlag)
    {
        if(overflow)
        {
            usleep(300000);
        }
        usleep(300000);
        EnergyParam param = dataWoker->getEnergyParam();
        if(first)
        {
            anares.start_measure_time = param.time;
            first = false;
            mutex.lock();
            initStatus(&cstatus,&param);
            anares.vsp_cnt = cstatus.acc_vsp_cnt;
            mutex.unlock();
            writeParam(ws,xf,param,cnt);

        }
        if(cstatus.lastTime < param.time)
        {
            cnt++;
            mutex.lock();
            updateResult(&cstatus,&param);
            anares.vsp_cnt = cstatus.acc_vsp_cnt;
            mutex.unlock();
            writeParam(ws,xf,param,cnt);
        }

        acc_flow = anares.acc_flow;
        acc_power = anares.acc_power;
        load_radio = ((float)anares.load_time/(float)(anares.load_time + anares.unload_time))*100.0;
        if(cnt>SHEET_MAX_LINE)
        {
            if(sheetNUM < SHEET_MAX_INDEX)
            {
                char temp[10];
                sprintf(temp,"sheet%d",sheetNUM+1);
                ws = wb->sheet(temp);
                setTitle(ws,xf);
                sheetNUM++;
            }else {
                emit recordoverflow(1);
                overflow = true;
            }
            cnt = 0;
        }

    }

    if(cstatus.state == STAGE_LOAD )
    {
//        anares.load_cnt++;
//        anares.load_time += cstatus.duration;
        if(anares.max_load_time < cstatus.duration)
        {
            anares.max_load_time = cstatus.duration;
        }
    }else if(cstatus.state == STAGE_UNLOAD )
    {
//        anares.unload_cnt++;
//        anares.unload_time += cstatus.duration;
        if(anares.max_unload_time < cstatus.duration)
        {
            anares.max_unload_time = cstatus.duration;
        }
    }
    if(cstatus.acc_vsp_cnt>0)
        anares.ave_vsp = anares.ave_vsp/(float)cstatus.acc_vsp_cnt;
    anares.end_measure_time = cstatus.lastTime;

    anares.worktime = anares.load_time + anares.unload_time;
    anares.stanby_time = anares.end_measure_time - anares.start_measure_time - anares.worktime;

    Util::SysLogD("start and end time  : %d %d\n",anares.start_measure_time,anares.end_measure_time);
    Util::SysLogD("load and unload time  : %d %d\n",anares.load_time,anares.unload_time);
    Util::SysLogD("acc_flow : %f\n",anares.acc_flow);
    Util::SysLogD("cur : %d %d\n",max_cur_standby,max_cur_unload);
    Util::SysLogD("max time : %d %d\n",anares.max_load_time,anares.max_unload_time);
    Util::SysLogD("max time : %d %d\n",anares.max_load_time,anares.max_unload_time);
    Util::SysLogD("vas : %f %d\n",anares.ave_vsp,cstatus.acc_vsp_cnt);

    if(anares.worktime != 0)
    {
        anares.load_radio = ((float)anares.load_time)/(float)anares.worktime*100.0;
        anares.unload_radio = ((float)anares.unload_time)/(float)anares.worktime*100.0;
    }

    anares.acc_flow = anares.acc_flow/60;//m3/min
    anares.acc_power = anares.acc_power/3600;//kwh
    anares.load_power /= 3600;
    anares.unload_power /= 3600;

    if(charge_type == 1)
    {
        anares.acc_charge_normal =  anares.acc_charge_normal*power_charge_normal/3600;
        anares.acc_charge_peak =  anares.acc_charge_peak*power_charge_peak/3600;
        anares.acc_charge_valley =  anares.acc_charge_valley*power_charge_valley/3600;
        anares.acc_charge = anares.acc_charge_normal+anares.acc_charge_peak+anares.acc_charge_valley;
        anares.load_charge /= 3600;
        anares.unload_chargd /= 3600;

    }else if(charge_type == 0)
    {
        anares.acc_charge = anares.acc_power*power_charge;
        anares.load_charge = anares.load_power*power_charge;
        anares.unload_chargd = anares.unload_power*power_charge;
    }

    anares.permanent_magnet_frequency_conversion = anares.unload_power+anares.load_power*0.1;
    anares.first_order_energy_efficiency = -7.2*anares.acc_flow/60 + anares.acc_power;

    anares.permanent_magnet_frequency_conversion_day = anares.permanent_magnet_frequency_conversion * 12 / anares.worktime *3600;
    anares.permanent_magnet_frequency_conversion_month = anares.permanent_magnet_frequency_conversion * 30 * 12 / anares.worktime *3600;
    anares.permanent_magnet_frequency_conversion_year = anares.permanent_magnet_frequency_conversion * 365 * 30 * 12 / anares.worktime *3600;

    if(anares.first_order_energy_efficiency <0.00001)
    {
        anares.first_order_energy_efficiency = 0;
        anares.first_order_energy_efficiency_day = 0;
        anares.first_order_energy_efficiency_month = 0;
        anares.first_order_energy_efficiency_year = 0;
    }else
    {
        anares.first_order_energy_efficiency_day = anares.first_order_energy_efficiency * 12 / anares.worktime *3600;
        anares.first_order_energy_efficiency_month = anares.first_order_energy_efficiency * 30 * 12 / anares.worktime *3600;
        anares.first_order_energy_efficiency_year = anares.first_order_energy_efficiency * 365 * 30 * 12 / anares.worktime *3600;
    }

    anares.load_charge_radio = anares.load_charge/ anares.acc_charge *100.0;
    anares.unload_charge_radio = anares.unload_chargd/ anares.acc_charge *100.0;
    anares.ave_cost = anares.acc_charge / anares.acc_flow;
    anares.ave_power_cost = anares.acc_power / anares.acc_flow;

//    char temp[10];
//    sprintf(temp,"sheet%d",sheetNUM+1);
    ws = wb->sheet("分析结果");
    Util::writeResultWithFormat(ws,xf,anares);

    string path_post = title.toStdString();
    string path = path_pre + path_post; 
    wb->Dump(path);
    delete wb;
    Util::fileSync(path.c_str());
    Util::SysLogD("save file : %s\n",path.c_str());
    emit recordoverflow(2);
}
Example #11
0
void Preprocessor::run() {
    std::size_t decisionTreeDepth =
            options_.blocklistHeurCalculatorType_ ==
                    BlockListHeurType::decisionTree ?
            options_.blocklistDecisionTreeDepth_ : 0;

    std::unique_ptr<SaverThread> saverThread;
    if (!options_.saveProgress_.empty() && options_.saveInterval_ > 0) {
        saverThread = std::make_unique<SaverThread>(
                [this]() {
                        subStatusForEach_->synchronize( [this]() { save(); });
                },
                boost::posix_time::millisec(
                        static_cast<int>(options_.saveInterval_ * 1000.0f)));

    }

    util::TimeMeter timeMeter;
    if (!options_.preprocessFillBeforeCalculate_) {
        threadPool_.start();
    }

    for (; currentStoneNum_ <= options_.blockListStones_; ++currentStoneNum_) {
        incrementalCalculator_ = currentStoneNum_ == 2 ?
            calculator_ : decisionTreeDepth > 0 ?
                decisionTreeHeurCalculator(decisionTreeDepth, false, 1.0f) :
                vectorHeurCalculator(1.0f);

        for (auto& calculationInfo: calculationInfos_) {
            calculationInfo = std::make_unique<CalculationInfo>();
        }

        std::cerr << "Stones = " << currentStoneNum_ << std::endl;

        ComplexChecker actualChecker{checker_};
        actualChecker.append(checker());
        subStatusForEach_->start(currentStoneNum_, calculator_, actualChecker,
                Matrix<bool>{table_->width(), table_->height(), false},
                maxIndex_);
        std::cerr << "Waiting for processing to finish..." << std::endl;

        if (saverThread) {
            saverThread->start();
        }

        if (options_.preprocessFillBeforeCalculate_) {
            threadPool_.start();
        }

        subStatusForEach_->wait(true);

        if (options_.preprocessFillBeforeCalculate_) {
            threadPool_.wait();
        }

        if (saverThread) {
            saverThread->stop();
        }

        updateResult();
    }

    if (!options_.preprocessFillBeforeCalculate_) {
        threadPool_.wait();
    }

    iteratingTime_ = timeMeter.data();
    if (options_.maxHeurListSize_ > 0 &&
            heurList_.size() > options_.maxHeurListSize_) {
        IncrementList(heurList_.begin(),
                heurList_.begin() + options_.maxHeurListSize_).swap(heurList_);
    }

    std::cerr << "Heur list size = " << heurList_.size() << "\n" <<
            "Processor time spent on saving: " << savingTime_.processorTime <<
            "\nReal time spent on saving: " << savingTime_.realTime << "\n";
    dump_.flush();
}
Example #12
0
void ShotDialog::shotEndChange( const QString & value )
{
	((QDoubleValidator*)mShotStart->validator())->setTop( value.toDouble() );
	updateResult();
}