Ejemplo n.º 1
1
	Optional<DateTime> TOMLValue::getOpt<DateTime>() const
	{
		if (!isDateTime())
		{
			return none;
		}

		return Optional<DateTime>(in_place, getDateTime());
	}
Ejemplo n.º 2
0
void modCalcAzel::slotComputeCoords()
{
	SkyPoint sp;
	double epoch0 = getEpoch( epochName->text() );
	KStarsDateTime dt;
	dt.setFromEpoch( epoch0 );
	long double jd = getDateTime().djd();
	long double jd0 = dt.djd();

	dms LST( getDateTime().gst().Degrees() + getLongitude().Degrees() );

	if(radioApCoords->isChecked()) {
		sp = getEquCoords();
		sp.apparentCoord(jd0, jd);
		dms lat(getLatitude());
		sp.EquatorialToHorizontal( &LST, &lat );
		showHorCoords( sp );

	} else {
		sp = getHorCoords();
		dms lat(getLatitude());
		sp.HorizontalToEquatorial( &LST, &lat );
		showEquCoords( sp );
	}

}
Ejemplo n.º 3
0
bool ldt_TAppUpdate(int argc, const char * argv[], void * data)
{
    TAppUpdate_t request;
    time_t t;
    int i;

    LDTTransactionData_t *ldtTransactionData = (LDTTransactionData_t *)data;
    for (i = 0; i < argc; i++) 
    {
        if ( !isValid(argv[i], TAppUpdateArguments[i - 1]) )
            return false;
    }

    i = 0;
    
    request.serviceProviderId = atoi (argv[i++]);
    setOptionIntValue(&request.isEntryPointIdSet, &request.entryPointId, atoi (argv[i++]));
    setOptionIntValue(&request.isActionSequenceNoSet, &request.actionSequenceNo, atoi (argv[i++]));
    t = getDateTime(argv[i++]);
    setOptionDateC19Value(&request.isExpiryDateSet, request.expiryDate, t);
    setOptionIntValue(&request.isPassengerCodeSet, &request.passengerCode, atoi (argv[i++]));
    t = getDateTime(argv[i++]);
    setOptionDateC19Value(&request.isPassengerCodeExpirySet, request.passengerCodeExpiry, t);
    setOptionIntValue(&request.isPassengerControlSet, &request.passengerControl,  atoi (argv[i++]));
    setOptionIntValue(&request.isLanguageSet, &request.language, atoi (argv[i++]));

    if (MYKI_LDT_TAppUpdate(&request, ldtTransactionData) > 0);
    {
        return true;
    }

    return false;
}
Ejemplo n.º 4
0
	THREAD(SleepMode, arg)
	{
		struct _tm current_Time;
		getDateTime(&current_Time);
		int temp = current_Time.tm_min;
		int volume = 0;
		setGVolume(volume);
		NutThreadCreate("fs", StreamMusic, NULL, 512);
		for (;;) {
			
			getDateTime(&current_Time);
			if (temp > 45)
			{
				if (current_Time.tm_min >= temp - 45 && current_Time.tm_min < 45)
				{
					stopStream();
					break;
				}
			}
			else
			{
				if (current_Time.tm_min >= (temp + 15))
				{
					stopStream();
					break;
				}
			}
			NutSleep(20000);
			volume+=1;
			setGVolume(volume);
			printf("test3 min:%d", current_Time.tm_min);


		}
	}
Ejemplo n.º 5
0
int DiagramList::readList(const SensorData* data, std::vector<DiagramList*> &lists)
{
	const std::vector<SensorDataType::type> time_series_names (data->getTimeSeriesNames());
	int nLists(time_series_names.size());

	std::vector<size_t> time_steps;
	if (data->getStepSize()>0)
	{
		const size_t start    = data->getStartTime();
		const size_t end      = data->getEndTime();
		const size_t stepsize = data->getStepSize();
		for (size_t i = start; i <= end;  i+=stepsize)
			time_steps.push_back(i);
	}
	else
		time_steps = data->getTimeSteps();

	bool is_date (false);

	if (!(BaseLib::int2date(time_steps[0])).empty())
		is_date = true;


	size_t nValues (time_steps.size());

	for (int i = 0; i < nLists; i++)
	{
		DiagramList* l = new DiagramList;
		l->setName(QString::fromStdString(SensorData::convertSensorDataType2String(time_series_names[i])));
		l->setXLabel("Time");
		lists.push_back(l);

		const std::vector<float> *time_series = data->getTimeSeries(time_series_names[i]);

		if (is_date)
		{
			l->setXUnit("day");
			QDateTime startDate(getDateTime(QString::fromStdString(BaseLib::int2date(time_steps[0]))));
			lists[i]->setStartDate(startDate);
			int numberOfSecs(0);
			for (size_t j = 0; j < nValues; j++)
			{
				numberOfSecs = startDate.secsTo(getDateTime(QString::fromStdString(BaseLib::int2date(time_steps[j]))));
				lists[i]->addNextPoint(numberOfSecs, (*time_series)[j]);
			}
		}
		else
		{
			l->setXUnit("time step");
			for (size_t j = 0; j < nValues; j++)
				lists[i]->addNextPoint(time_steps[j], (*time_series)[j]);
		}

		lists[i]->update();
	}

	return nLists;
}
Ejemplo n.º 6
0
bool ldt_productSale(int argc, const char * argv[], void *data)
{
    ProductSale_t request;
    int ret;
    int i;

    CsDebug(9, (9, "ldt_productSale"));

    LDTTransactionData_t *ldtTransactionData = (LDTTransactionData_t *)data;
    for (i = 0; i < argc; i++) 
    {
        if ( !isValid(argv[i], ProductSaleArguments[i]) )
            return false;
    }

    i = 0;
    

    request.productId = atoi (argv[i++]);
    request.issuerId = atoi (argv[i++]);
    request.purchaseValue = atoi (argv[i++]);
    request.zoneLow = atoi (argv[i++]);
    request.zoneHigh = atoi (argv[i++]);
    request.startDateTime = getDateTime (argv[i++]);

    request.endDateTime = getDateTime (argv[i++]);
    request.serviceProviderId = atoi (argv[i++]);
    
    setOptionIntValue(&request.isActionSequenceNoSet, &request.actionSequenceNo, atoi (argv[i++]));
    setOptionIntValue(&request.isEntryPointIdSet, &request.entryPointId, atoi (argv[i++]));
    setOptionIntValue(&request.isRouteIdSet, &request.routeId, atoi (argv[i++]));
    setOptionIntValue(&request.isStopIdSet, &request.stopId, atoi (argv[i++]));
    setOptionIntValue(&request.isAutoloadSet, &request.isAutoload, atoi (argv[i++]));
    setOptionIntValue(&request.isOffpeakSet, &request.isOffpeak, atoi (argv[i++]));
    setOptionIntValue(&request.isProvisionalSet, &request.isProvisional, atoi (argv[i++]));
    setOptionIntValue(&request.isInstanceCountSet, &request.instanceCount, atoi (argv[i++]));


    ret = MYKI_LDT_ProductSale(&request, ldtTransactionData);
    if (ret == LDT_SUCCESS)
    {
        CsDebug(9, (9, "LDTcmd:ldt_productSale: Successfully called MYKI_LDT_ProductSale" ));
        return true;
    }
    else if (ret == LDT_PRECONDITION_NOT_MET)
    {
        CsErrx("LDTcmd:ldt_productSale: Failed to call MYKI_LDT_ProductSale due to precondition not met");
    }
    else
    {
        CsErrx("LDTcmd:ldt_productSale: Failed to call MYKI_LDT_ProductSaleReverse");
    }

    return false;
}
Ejemplo n.º 7
0
bool ldt_productSaleUpgrade(int argc, const char * argv[], void *data)
{
    ProductSale_t request;
    int i;

    LDTTransactionData_t *ldtTransactionData = (LDTTransactionData_t *)data;
    for (i = 0; i < argc; i++) 
    {
        if ( !isValid(argv[i], ProductSaleUpgradeArguments[i - 1]) )
            return false;
    }

    i = 0;
    
    request.serialNo = atoi (argv[i++]);
    request.productId = atoi (argv[i++]);
    request.purchaseValue = atoi (argv[i++]);
    request.zoneLow = atoi (argv[i++]);
    request.zoneHigh = atoi (argv[i++]);

    if (!strcmp(argv[i], UNKNOWN_VALUE_STR) == 0)
    {
        time_t t = getDateTime(argv[i]);
        setOptionDateTimeValue(&request.isStartDateTimeSet, request.startDateTime, t);
    }
    i++;
    if (!strcmp(argv[i], UNKNOWN_VALUE_STR) == 0)
    {
        time_t t = getDateTime(argv[i]);
        setOptionDateTimeValue(&request.isEndDateTimeSet, request.endDateTime, t);
    }
    i++;

    setOptionIntValue(&request.isProvisionalSet, &request.isProvisional, atoi (argv[i++]));

    request.serviceProviderId = atoi (argv[i++]);

    setOptionIntValue(&request.isEntryPointIdSet, &request.entryPointId, atoi (argv[i++]));
    setOptionIntValue(&request.isRouteIdSet, &request.routeId, atoi (argv[i++]));
    setOptionIntValue(&request.isStopIdSet, &request.stopId, atoi (argv[i++]));
    
    if (MYKI_LDT_ProductSaleUpgrade(&request, ldtTransactionData) > 0);
    {
        return true;
    }

    return false;
}
Ejemplo n.º 8
0
//创建销售商品信息的节点
void Widget::createNodes(QDomElement &date)
{
    QDomElement time=doc.createElement(QString("日期"));
    QDomAttr curTime=doc.createAttribute("time");
    curTime.setValue(getDateTime(Time));
    time.setAttributeNode(curTime);
    date.appendChild(time);
    QDomElement type=doc.createElement(QString("类型"));
    QDomElement brand=doc.createElement(QString("品牌"));
    QDomElement price=doc.createElement(QString("单价"));
    QDomElement num=doc.createElement(QString("数量"));
    QDomElement sum=doc.createElement(QString("金额"));
    QDomText text;
    text=doc.createTextNode(QString("%1")
                .arg(ui->sellTypeComboBox->currentText()));
    type.appendChild(text);
    text=doc.createTextNode(QString("%1")
                .arg(ui->sellBrandComboBox->currentText()));
    brand.appendChild(text);
    text=doc.createTextNode(QString("%1")
                .arg(ui->sellPriceLineEdit->text()));
    price.appendChild(text);
    text=doc.createTextNode(QString("%1")
                .arg(ui->sellNumSpinBox->value()));
    num.appendChild(text);
    text=doc.createTextNode(QString("%1")
                .arg(ui->sellSumLineEdit->text()));
    sum.appendChild(text);
    time.appendChild(text);
    time.appendChild(type);
    time.appendChild(brand);
    time.appendChild(price);
    time.appendChild(num);
    time.appendChild(sum);
}
Ejemplo n.º 9
0
QScriptValue NetworkAutomaticProxy::weekdayRange(QScriptContext *context, QScriptEngine *engine)
{
	Q_UNUSED(engine);

	if (context->argumentCount() < 1 || context->argumentCount() > 3)
	{
		return context->throwError(QLatin1String("Function weekdayRange takes 1 to 3 arguments!"));
	}

	const QString beginDay = context->argument(0).toString().toLower();
	const QString endDay = context->argument(1).toString().toLower();
	const int currentDay = getDateTime(context).date().dayOfWeek();
	int beginDayNumber = -1;
	int endDayNumber = -1;

	for (int i = 0; i < m_days.count(); ++i)
	{
		if (beginDay == m_days.at(i))
		{
			beginDayNumber = (i + 1);
		}

		if (endDay == m_days.at(i))
		{
			endDayNumber = (i + 1);
		}
	}

	if (endDayNumber == -1)
	{
		endDayNumber = beginDayNumber;
	}

	return ((beginDayNumber != -1 && endDayNumber != -1) && compareRange(beginDayNumber, endDayNumber, currentDay));
}
Ejemplo n.º 10
0
bool ldt_productUsageForceScanOff(int argc, const char * argv[], void * data)
{
    ProductUsage_t request;
    int i;

    LDTTransactionData_t *ldtTransactionData = (LDTTransactionData_t *)data;
    for (i = 0; i < argc; i++) 
    {
        if ( !isValid(argv[i], ProductUsageScanOffArguments[i - 1]) )
            return false;
    }

    i = 0;
    
    request.serialNo = atoi (argv[i++]);
    request.serviceProviderId = atoi (argv[i++]);
    request.entryPointId = atoi (argv[i++]);
    request.routeId = atoi (argv[i++]);
    request.stopId = atoi (argv[i++]);
    request.zone = atoi (argv[i++]);
    request.dateTime = getDateTime (argv[i++]);

    setOptionIntValue(&request.isOriginatingServiceProviderIdSet, &request.originatingServiceProviderId, atoi (argv[i++]));
    setOptionIntValue(&request.isOriginatingEntryPointIdSet, &request.originatingEntryPointId, atoi (argv[i++]));
    setOptionIntValue(&request.isOriginatingRouteIdSet, &request.originatingRouteId, atoi (argv[i++]));
    setOptionIntValue(&request.isOriginatingStopIdSet, &request.originatingStopId, atoi (argv[i++]));

    if (MYKI_LDT_ProductUsageForceScanOff(&request, ldtTransactionData) > 0);
    {
        return true;
    }

    return false;
}
Ejemplo n.º 11
0
bool ldt_productUsageScanOnEpass(int argc, const char * argv[], void * data)
{
    ProductUsage_t request;
    int i;

    LDTTransactionData_t *ldtTransactionData = (LDTTransactionData_t *)data;
    for (i = 0; i < argc; i++) 
    {
        if ( !isValid(argv[i], ProductUsageScanOnArguments[i - 1]) )
            return false;
    }

    i = 0;
    
    request.serialNo = atoi (argv[i++]);
    request.serviceProviderId = atoi (argv[i++]);
    request.entryPointId = atoi (argv[i++]);
    request.routeId = atoi (argv[i++]);
    request.stopId = atoi (argv[i++]);
    request.zone = atoi (argv[i++]);
    request.dateTime = getDateTime (argv[i++]);

    if (MYKI_LDT_ProductUsageScanOnEpass(&request, ldtTransactionData) > 0);
    {
        return true;
    }

    return false;
}
Ejemplo n.º 12
0
bool ldt_CappingUpdate(int argc, const char * argv[], void * data)
{
    CappingUpdate_t request;
    time_t t;
    int i;

    LDTTransactionData_t *ldtTransactionData = (LDTTransactionData_t *)data;
    for (i = 0; i < argc; i++) 
    {
        if ( !isValid(argv[i], CappingUpdateArguments[i - 1]) )
            return false;
    }

    i = 0;
    
    request.serviceProviderId = atoi (argv[i++]);
    setOptionIntValue(&request.isEntryPointIdSet, &request.entryPointId, atoi (argv[i++]));
    t = getDateTime(argv[i++]);
    setOptionDateC19Value(&request.isDailyExpirySet, request.dailyExpiry, t);
    setOptionIntValue(&request.isDailyZoneLowSet, &request.dailyZoneLow, atoi (argv[i++]));
    setOptionIntValue(&request.isDailyZoneHighSet, &request.dailyZoneHigh, atoi (argv[i++]));
    setOptionIntValue(&request.isDailyValueSet, &request.dailyValue, atoi (argv[i++]));
    setOptionIntValue(&request.isWeeklyExpirySet, &request.weeklyExpiry, atoi (argv[i++]));
    setOptionIntValue(&request.isWeeklyZoneHighSet, &request.weeklyZoneHigh, atoi (argv[i++]));
    setOptionIntValue(&request.isWeeklyValueSet, &request.weeklyValue, atoi (argv[i++]));

    if (MYKI_LDT_CappingUpdate(&request, ldtTransactionData) > 0);
    {
        return true;
    }
}
Ejemplo n.º 13
0
void output_saveResults(double reportTime)
//
//  Input:   reportTime = elapsed simulation time (millisec)
//  Output:  none
//  Purpose: writes computed results for current report time to binary file.
//
{
    int i;
    DateTime reportDate = getDateTime(reportTime);
    REAL8 date;

    if ( reportDate < ReportStart ) return;
    for (i=0; i<MAX_SYS_RESULTS; i++) SysResults[i] = 0.0f;
    date = reportDate;
    fwrite(&date, sizeof(REAL8), 1, Fout.file);
    if (Nobjects[SUBCATCH] > 0)
        output_saveSubcatchResults(reportTime, Fout.file);
    if (Nobjects[NODE] > 0)
        output_saveNodeResults(reportTime, Fout.file);
    if (Nobjects[LINK] > 0)
        output_saveLinkResults(reportTime, Fout.file);
    fwrite(SysResults, sizeof(REAL4), MAX_SYS_RESULTS, Fout.file);
    if ( Foutflows.mode == SAVE_FILE && RouteModel != NO_ROUTING )             //(5.0.014 - LR)
        iface_saveOutletResults(reportDate, Foutflows.file);
    Nperiods++;
}
Ejemplo n.º 14
0
void sendError(int sock, int code)
{
	char* responseFormat = NULL;

	switch (code) {
	case 400:
		responseFormat = "HTTP/1.1 400 Bad Request\nServer: newServerinc\nDate: %s\n\n400 Bad Request\n\n";
		break;
	case 403:
		responseFormat = "HTTP/1.1 403 Forbidden\nServer: newServerinc\nDate: %s\n\n403 Forbidden\n\n";
		break;
	case 404:
		responseFormat = "HTTP/1.1 404 Not Found\nServer: newServerinc\nDate: %s\n\n404 Not Found\n\n";
		break;
	default:
		responseFormat = "HTTP/1.1 400 Bad Request\nServer: newServerinc\nDate: %s\n\n400 Bad Request\n\n";
		break;
	}

	char* dateTime = getDateTime();
	char* response = calloc(strlen(responseFormat) + strlen(dateTime)-1,sizeof(char));
	sprintf(response,responseFormat, dateTime);
	write(sock , response , strlen(response));
	shutdown(sock,SHUT_RDWR);
	close(sock);
	free(response);
	free(dateTime);
}
Ejemplo n.º 15
0
// 将销售记录写入文档
void Widget::writeXml()
{
    // 先从文件读取
    if (docRead()) {
            QString currentDate = getDateTime(Date);
            QDomElement root = doc.documentElement();
            // 根据是否有日期节点进行处理
            if (!root.hasChildNodes()) {
                    QDomElement date = doc.createElement(QString("日期"));
                    QDomAttr curDate = doc.createAttribute("date");
                    curDate.setValue(currentDate);
                    date.setAttributeNode(curDate);
                    root.appendChild(date);
                    createNodes(date);
            } else {
                    QDomElement date = root.lastChild().toElement();
                    // 根据是否已经有今天的日期节点进行处理
                    if (date.attribute("date") == currentDate) {
                            createNodes(date);
                    } else {
                            QDomElement date = doc.createElement(QString("日期"));
                            QDomAttr curDate = doc.createAttribute("date");
                            curDate.setValue(currentDate);
                            date.setAttributeNode(curDate);
                            root.appendChild(date);
                            createNodes(date);
                    }
            }
            // 写入到文件
            docWrite();
    }
}
Ejemplo n.º 16
0
CNetwork::CNetwork(const CString &input_traf_file_name) :   CObject()
    ,   m_network_name("")
    ,   m_traf_input_file(input_traf_file_name)
    ,   m_sensors_output_file("")
    ,   m_out_type(NO)
    ,   m_link_list()
    ,   m_node_list()
    ,   m_tp_lengths()
{
    char buff[DTTMSZ];
    char path_buffer[_MAX_PATH];
    char drive[_MAX_DRIVE];
    char dir[_MAX_DIR];
    char base_name[_MAX_FNAME];
    errno_t err;

    err = _splitpath_s(m_traf_input_file, drive, _MAX_DRIVE, dir, _MAX_DIR, base_name, _MAX_FNAME, NULL, NULL);
    if (err != 0)
    {
        printf("Error splitting the path. Error code %d.\n", err);
        exit(1);
    }
    err = _makepath_s(path_buffer, _MAX_PATH, drive, dir, base_name, NULL);
    if (err != 0)
    {
        printf("Error creating path. Error code %d.\n", err);
        exit(1);
    }
    m_sensors_output_file  = path_buffer;
    m_sensors_output_file += _T(getDateTime(buff));
    m_sensors_cum_output_file = m_sensors_output_file;
}
Ejemplo n.º 17
0
double landuse_getExternalBuildup(Project* project, int i, int p, double buildup, double tStep)
//
//  Input:   i = landuse index
//           p = pollutant index
//           buildup = buildup at start of time step (mass/unit)
//           tStep = time step (sec)
//  Output:  returns pollutant buildup at end of time interval (mass/unit)
//  Purpose: finds pollutant buildup contributed by external loading over a
//           given time step.
//
{
    double maxBuildup = project->Landuse[i].buildupFunc[p].coeff[0];
    double sf = project->Landuse[i].buildupFunc[p].coeff[1];              // scaling factor
    int    ts = (int)floor(project->Landuse[i].buildupFunc[p].coeff[2]);  // time series index
    double rate = 0.0;

    // --- no buildup increment at start of simulation
    if (project->NewRunoffTime == 0.0) return 0.0;

    // --- get buildup rate (mass/unit/day) over the interval
    if ( ts >= 0 )
    {
        rate = sf * table_tseriesLookup(&project->Tseries[ts],
                                        getDateTime(project, project->NewRunoffTime), FALSE);
    }

    // --- compute buildup at end of time interval
    buildup = buildup + rate * tStep / SECperDAY;
    buildup = MIN(buildup, maxBuildup);
    return buildup;
}
Ejemplo n.º 18
0
void output_saveResults(Project* project, double reportTime)
//
//  Input:   reportTime = elapsed simulation time (millisec)
//  Output:  none
//  Purpose: writes computed results for current report time to binary file.
//
{
    int i;
    DateTime reportDate = getDateTime(project,reportTime);
    REAL8 date;

    if ( reportDate < project->ReportStart ) return;
    for (i=0; i<MAX_SYS_RESULTS; i++) project->SysResults[i] = 0.0f;
    date = reportDate;
    fwrite(&date, sizeof(REAL8), 1, project->Fout.file);
    if (project->Nobjects[SUBCATCH] > 0)
        output_saveSubcatchResults(project,reportTime, project->Fout.file);
    if (project->Nobjects[NODE] > 0)
        output_saveNodeResults(project,reportTime, project->Fout.file);
    if (project->Nobjects[LINK] > 0)
        output_saveLinkResults(project,reportTime, project->Fout.file);
    fwrite(project->SysResults, sizeof(REAL4), MAX_SYS_RESULTS, project->Fout.file);
    if ( project->Foutflows.mode == SAVE_FILE && !project->IgnoreRouting ) 
        iface_saveOutletResults(project,reportDate, project->Foutflows.file);
    project->Nperiods++;
}
Ejemplo n.º 19
0
ext::string OptionsCtrl::getDateTimeStr(HANDLE hDateTime)
{
	bool bNone = false;
	DWORD dwTimestamp = getDateTime(hDateTime, &bNone);

	return bNone ? _T("") : utils::formatDate(dwTimestamp);
}
Ejemplo n.º 20
0
/////////////////////////////////////////////////
///Отправка данных в БД и на удаленный сервер
/////////////////////////////////////////////////
void DataBase::sendGPSPICNow(QStringList GPS, QStringList PIC)
{

    QSqlQuery query;
    dataTrans = getDateTime();

    if (GPS.size()==0)
    {GPS.append("fail");}

    if (PIC.size()==0)
    {PIC.append("fail");}

    //отправка кординат в таблицу GPS
    if (GPS[0]!="fail")
    {
    query.exec("insert into vehicle_"+idmain+" values('"+ dataTrans+"',"+GPS[2]+","+GPS[3]+","
                      +"'false'"+","+idmain+",'"+GPS[0]+"', '"+GPS[1]+"')");}

    //отправка показаний датчиков в таблицу PIC
    if (PIC[0]!="fail")
    {
    query.exec( "INSERT INTO vehicle_pic_"+idmain+" (an, led, pot, temp, id, data,send)"+
                "VALUES ('{"+PIC[0]+"}', '{"+PIC[1]+"}', "+PIC[2]+","+PIC[3]+", "+idmain+", '"+ dataTrans+"','false')");
    }

    //отправка кординат и показаний датчиков на удвленный сервер
    rpcclient.sendNow(GPS,PIC,idmain,dataTrans);
    // ждем и молимся

}
Ejemplo n.º 21
0
void terrama2::core::DataStoragerTiff::store(DataSetSeries series, DataSetPtr outputDataSet) const
{
  if(!outputDataSet.get() || !series.syncDataSet.get())
  {
    QString errMsg = QObject::tr("Mandatory parameters not provided.");
    TERRAMA2_LOG_ERROR() << errMsg;
    throw DataStoragerException() << ErrorDescription(errMsg);
  }

  QUrl uri(QString::fromStdString(dataProvider_->uri));
  auto path = uri.path().toStdString();
  try
  {
    std::string mask = getMask(outputDataSet);

    auto dataset = series.syncDataSet->dataset();
    size_t rasterColumn = te::da::GetFirstPropertyPos(dataset.get(), te::dt::RASTER_TYPE);
    if(!isValidColumn(rasterColumn))
    {
      QString errMsg = QObject::tr("No raster attribute.");
      TERRAMA2_LOG_ERROR() << errMsg;
      throw DataStoragerException() << ErrorDescription(errMsg);
    }

    size_t timestampColumn = te::da::GetFirstPropertyPos(dataset.get(), te::dt::DATETIME_TYPE);

    dataset->moveBeforeFirst();
    while(dataset->moveNext())
    {
      std::shared_ptr<te::rst::Raster> raster(dataset->isNull(rasterColumn) ? nullptr : dataset->getRaster(rasterColumn).release());
      std::shared_ptr<te::dt::DateTime> timestamp;
      if(!isValidColumn(timestampColumn) || dataset->isNull(timestampColumn))
        timestamp = nullptr;
      else
        timestamp.reset(dataset->getDateTime(timestampColumn).release());

      if(!raster.get())
      {
        QString errMsg = QObject::tr("Null raster found.");
        TERRAMA2_LOG_ERROR() << errMsg;
        continue;
      }

      std::string filename = replaceMask(mask, timestamp, outputDataSet);

      std::string output = path + "/" + filename;
      te::rp::Copy2DiskRaster(*raster, output);
    }
  }
  catch(const DataStoragerException&)
  {
    throw;
  }
  catch(...)
  {
    //TODO: fix DataStoragerTiff catch
  }
}
Ejemplo n.º 22
0
bool CAsyncLog::write(const std::string& sMsg)
{

	if(!writeBuffer("[" + getDateTime() + "]" + sMsg))
	{
		return false;
	}
	return true;
}
Ejemplo n.º 23
0
bool ldt_productUpdateExtend(int argc, const char * argv[], void * data)
{
    ProductUpdate_t request;
    int i;

    LDTTransactionData_t *ldtTransactionData = (LDTTransactionData_t *)data;
    for (i = 0; i < argc; i++) 
    {
        if ( !isValid(argv[i], ProductUpdateExtendArguments[i - 1]) )
            return false;
    }

    i = 0;
    
    request.serialNo = atoi (argv[i++]);
    request.serviceProviderId = atoi (argv[i++]);
    setOptionIntValue(&request.isEntryPointIdSet, &request.entryPointId, atoi (argv[i++]));
    setOptionIntValue(&request.isZoneLowSet, &request.zoneLow, atoi (argv[i++]));
    setOptionIntValue(&request.isZoneHighSet, &request.zoneHigh, atoi (argv[i++]));
    setOptionIntValue(&request.isPurchaseValueSet, &request.purchaseValue, atoi (argv[i++]));
    if (!strcmp(argv[i], UNKNOWN_VALUE_STR) == 0)
    {
        time_t t = getDateTime(argv[i]);
        setOptionDateTimeValue(&request.isStartDateTimeSet, request.startDateTime, t);
    }
    i++;
    if (!strcmp(argv[i], UNKNOWN_VALUE_STR) == 0)
    {
        time_t t = getDateTime(argv[i]);
        setOptionDateTimeValue(&request.isEndDateTimeSet, request.endDateTime, t);
    }
    i++;
    setOptionIntValue(&request.isInstanceCountSet, &request.instanceCount, atoi (argv[i++]));
    setOptionIntValue(&request.isPremiumSet, &request.isPremium, atoi (argv[i++]));
    setOptionIntValue(&request.isClearBorderStatusSet, &request.clearBorderStatus, atoi (argv[i++]));


    if (MYKI_LDT_ProductUpdateExtend(&request, ldtTransactionData) > 0);
    {
        return true;
    }

    return false;
}
Ejemplo n.º 24
0
void andrq::loadMessages(const QString &path)
{
	QDir dir = path;
	QString account = dir.dirName();
	if(!dir.cd("history"))
		return;
	setProtocol("ICQ");
	setAccount(account);
	QFileInfoList files = dir.entryInfoList(QDir::Files);
	setMaxValue(files.size());
	for(int i = 0; i < files.size(); i++)
	{
		setValue(i + 1);
		QString uin = files[i].fileName();
		QFile file(files[i].absoluteFilePath());
		if(!file.open(QFile::ReadOnly))
			continue;
		setContact(uin);
		QDataStream in(&file);
		in.setByteOrder(QDataStream::LittleEndian);
		Message message;
		message.type=1;
		while(!in.atEnd())
		{
			qint32 type;
			in >> type;
			switch(type)
			{
			case -1: {
				quint8 kind;
				qint32 who;
				in >> kind >> who;
				QString from = QString::number(who);
				message.in = from == uin;
				message.time = getDateTime(in);
				qint32 tmp;
				in >> tmp;
				in.skipRawData(tmp);
				message.text = Qt::escape(getString(in, who)).replace("\n", "<br/>");
				if(kind==1)
					appendMessage(message);
				break; }
			case -2: {
				qint32 tmp;
				in >> tmp;
				in.skipRawData(tmp);
				break; }
			case -3:
				in.skipRawData(5);
				break;
			default:
				break;
			}
		}
	}
}
Ejemplo n.º 25
0
void urinalysis::setForms(int row, int)
{
    if(row < 0 || row >= m_currentTableIndexInAll.size())
    {
        return;
    }

    int index = m_currentTableIndexInAll[row];
    urinalysisInfo &info = m_allInfoVec[index];
    ui->nameLineEdit->setText(info.name);
    if(info.sex == "男")
    {
        ui->maleRadioButton->setChecked(true);
    }
    else
    {
        ui->femaleRadioButton->setChecked(true);
    }

    ui->ageComboBox->setCurrentText(QString::number(info.age));

    ui->patientIDLineEdit->setText(info.patientID);
    ui->sampleIDLineEdit->setText(QString::number(info.sampleID));
    ui->sampleTypeLineEdit->setText(info.sampleType);

    ui->officeLineEdit->setText(info.administrativeOffice.trimmed());
    ui->senderDoctorLineEdit->setText(info.senderDoctor.trimmed());

    ui->sampleDateEdit->setDateTime(getDateTime(info.sampleDate));
    ui->detectionDateEdit->setDateTime(getDateTime(info.detectionDate));

    ui->bedIDLineEdit->setText(QString::number(info.bedID));

    ui->ALBLineEdit->setText(QString::number(info.ALB));
    ui->CRELineEdit->setText(QString::number(info.CRE));

    ui->prooferLineEdit->setText(info.proofer.trimmed());
    ui->auditorLineEdit->setText(info.auditor.trimmed());

    ui->reportDateEdit->setDateTime(getDateTime(info.reportDate));

    ui->remarksLineEdit->setText("本报告仅对此次送检标本负责。");
}
Ejemplo n.º 26
0
void Widget::example(){
    QString text = tr("example");
    if(isRename()){
        if(isNewName()){
            text = getNewName();
        }
        if(isPrependExifDate()){
            text.prepend(getDateTime("").toString(ui->exifLineEdit->text()));
        }
        if(isAppendExifDate()){
            text.append(getDateTime("").toString(ui->exifLineEdit->text()));
        }
        if(!(getPrefix().isEmpty() && getSuffix().isEmpty())){
            text.prepend(getPrefix());
            text.append(getSuffix());
        }
    }

    ui->exampleLabel->setText(text);
}
Ejemplo n.º 27
0
void modCalcDayLength::slotComputePosTime()
{
	long double jd0 = getDateTime().djd();
	getGeoLocation();

	KSNumbers * num = new KSNumbers(jd0);
	KSSun *Sun = new KSSun(((KStars*) parent()->parent()->parent())->data());
	Sun->findPosition(num);

	QTime setQtime = Sun->riseSetTime( jd0 , geoPlace, false );
	QTime riseQtime = Sun->riseSetTime( jd0 , geoPlace, true );
	QTime transitQtime = Sun->transitTime(jd0 , geoPlace);

	dms setAz = Sun->riseSetTimeAz(jd0, geoPlace, false);
	dms riseAz = Sun->riseSetTimeAz(jd0, geoPlace, true);
	dms transAlt = Sun->transitAltitude(jd0, geoPlace);

	if (setQtime.isValid() ) {
		azSetBox->show( setAz );
		elTransitBox->show( transAlt );
		azRiseBox->show( riseAz );

		setTimeBox->showTime( setQtime );
		riseTimeBox->showTime( riseQtime );
		transitTimeBox->showTime( transitQtime );

		QTime dayLQtime = lengthOfDay (setQtime,riseQtime);

		dayLBox->showTime( dayLQtime );
	} else if (transAlt.Degrees() > 0. ) {
		azSetBox->setDMS(i18n("Circumpolar"));
		elTransitBox->show( transAlt );
		azRiseBox->setDMS(i18n("Circumpolar"));

		setTimeBox->showTime( setQtime );
		riseTimeBox->showTime( riseQtime );
		transitTimeBox->showTime( transitQtime );

		dayLBox->setEntry("24:00:00");

	} else if (transAlt.Degrees() < 0. ) {
		azSetBox->setDMS("does not rise");
		elTransitBox->setDMS("does not rise");
		azRiseBox->setDMS("does not rise");

		setTimeBox->clearFields();
		riseTimeBox->clearFields();
		transitTimeBox->clearFields();

		dayLBox->showTime( QTime(0,0,0) );
	}

	delete num;
}
Ejemplo n.º 28
0
bool ldt_productUpdateActivate(int argc, const char * argv[], void * data)
{
    ProductUpdate_t request;
    int i;

    LDTTransactionData_t *ldtTransactionData = (LDTTransactionData_t *)data;
    for (i = 0; i < argc; i++) 
    {
        if ( !isValid(argv[i], ProductUpdateActivateArguments[i - 1]) )
            return false;
    }

    i = 0;
    
    request.serialNo = atoi (argv[i++]);
    request.serviceProviderId = atoi (argv[i++]);
    request.entryPointId = atoi (argv[i++]);
    request.routeId = atoi (argv[i++]);
    request.stopId = atoi (argv[i++]);

    setOptionIntValue(&request.isInstanceCountSet, &request.instanceCount, atoi (argv[i++]));
    if (!strcmp(argv[i], UNKNOWN_VALUE_STR) == 0)
    {
        time_t t = getDateTime(argv[i]);
        setOptionDateTimeValue(&request.isStartDateTimeSet, request.startDateTime, t);
    }
    i++;
    if (!strcmp(argv[i], UNKNOWN_VALUE_STR) == 0)
    {
        time_t t = getDateTime(argv[i]);
        setOptionDateTimeValue(&request.isEndDateTimeSet, request.endDateTime, t);
    }
    i++;

    if (MYKI_LDT_ProductUpdateActivate(&request, ldtTransactionData) > 0);
    {
        return true;
    }

    return false;
}
Ejemplo n.º 29
0
int SetEvent::exec()
{
    int r;
    do
    {
        r = SetEventBase::exec();
        if (r)
        {
            if ((!IgnoreTime->isChecked() && !getDateTime().isValid()) ||
                    (IgnoreTime->isChecked() && !getDateTime().date().isValid()))
            {
                QMessageBox::warning(this, "Datetime is invalid", "Please, enter the valid datetime.");
            }
            else
                return r;
        }
        else
            return r;
    }
    while (1);
}
Ejemplo n.º 30
0
void getEvapRates(Project* project, double theta, double upperDepth)
//
//  Input:   theta      = moisture content of upper zone
//           upperDepth = depth of upper zone (ft)
//  Output:  none
//  Purpose: computes evapotranspiration out of upper & lower zones.
//
{
    int    p, month;
    double f;
    double lowerFrac, upperFrac;

    // --- no project->GW evaporation when infiltration is occurring
    project->UpperEvap = 0.0;
    project->LowerEvap = 0.0;
    if ( project->Infil > 0.0 ) return;

    // --- get monthly-adjusted upper zone evap fraction
    upperFrac = project->A.upperEvapFrac;
    f = 1.0;
    p = project->A.upperEvapPat;
    if ( p >= 0 )
    {
        month = datetime_monthOfYear(getDateTime(project,project->NewRunoffTime));
        f = project->Pattern[p].factor[month-1];
    }
    upperFrac *= f;

    // --- upper zone evaporation requires that soil moisture
    //     be above the wilting point
    if ( theta > project->A.wiltingPoint )
    {
        // --- actual evap is upper zone fraction applied to max. potential
        //     rate, limited by the available rate after any surface evap 
        project->UpperEvap = upperFrac * project->MaxEvap;
        project->UpperEvap = MIN(project->UpperEvap, project->AvailEvap);
    }

    // --- check if lower zone evaporation is possible
    if ( project->A.lowerEvapDepth > 0.0 )
    {
        // --- find the fraction of the lower evaporation depth that
        //     extends into the saturated lower zone
        lowerFrac = (project->A.lowerEvapDepth - upperDepth) / project->A.lowerEvapDepth;
        lowerFrac = MAX(0.0, lowerFrac);
        lowerFrac = MIN(lowerFrac, 1.0);

        // --- make the lower zone evap rate proportional to this fraction
        //     and the evap not used in the upper zone
        project->LowerEvap = lowerFrac * (1.0 - upperFrac) * project->MaxEvap;
        project->LowerEvap = MIN(project->LowerEvap, (project->AvailEvap - project->UpperEvap));
    }
}