int main(void) { struct calendar birthday, today; int days; char* param; param = getParamString(); if (param == NULL){ printPage(ERROR, 0, NULL, NULL); return 0; } getParameter(param, &birthday); if (verifyDay(&birthday) == FAIL){ perror("Birthday verification failed"); printPage(INCORRECT, 0, NULL, NULL); return 0; } getToday(&today); if (verifyDay(&today) == FAIL){ perror("Today verification failed"); printPage(INCORRECT, 0, NULL, NULL); return 0; } if (isGreaterThan(birthday, today)){ // Birthday is future days = -computeDays(birthday, today); }else{ days = computeDays(today, birthday); } printPage(SUCCESS, days, &birthday, &today); return 0; }
void StructuredVolume::commit() { //! Some parameters can be changed after the volume has been allocated and filled. if (ispcEquivalent != NULL) return(updateEditableParameters()); //! Check for a file name. std::string filename = getParamString("filename", ""); //! The volume may be initialized from the contents of a file or from memory. if (!filename.empty()) VolumeFile::importVolume(filename, this); else getVolumeFromMemory(); //! Complete volume initialization. finish(); }
void LLPhysicsMotion::getString(std::ostringstream &oss) { oss << " mParamDriverName: " << mParamDriverName << std::endl << " mParamControllerName: " << mParamControllerName << std::endl << " mMotionDirectionVec: " << mMotionDirectionVec << std::endl << " mJointName: " << mJointName << std::endl << " mPosition_local: " << mPosition_local << std::endl << " mVelocityJoint_local: " << mVelocityJoint_local << std::endl << " mAccelerationJoint_local: " << mAccelerationJoint_local << std::endl << " mPositionLastUpdate_local: " << mPositionLastUpdate_local << std::endl << " mPosition_world: " << mPosition_world << std::endl << " mVelocity_local: " << mVelocity_local << std::endl; if(mParamDriver) { oss << " <DRIVER>" << std::endl; getParamString(2,mParamDriver,oss); LLDriverParam *driver_param = dynamic_cast<LLDriverParam *>(mParamDriver); if(driver_param) { for (LLDriverParam::entry_list_t::iterator iter = driver_param->mDriven.begin(); iter != driver_param->mDriven.end();++iter) { oss << " <DRIVEN>" << std::endl; getParamString(3,iter->mParam,oss); } } } else oss << " mParamDriver: (NULL)" << std::endl; oss << " Controllers:" << std::endl; for(controller_map_t::const_iterator it = mParamControllers.begin(); it!= mParamControllers.end(); ++it) { oss << " mParamControllers[\"" << it->first << "\"] = \"" << it->second << "\" =" << getParamValue(it->first) << std::endl; } }
void GhostBlockBrickedVolume::createEquivalentISPC() { // Get the voxel type. voxelType = getParamString("voxelType", "unspecified"); exitOnCondition(getVoxelType() == OSP_UNKNOWN, "unrecognized voxel type (must be set before calling " "ospSetRegion())"); // Get the volume dimensions. this->dimensions = getParam3i("dimensions", vec3i(0)); exitOnCondition(reduce_min(this->dimensions) <= 0, "invalid volume dimensions (must be set before calling " "ospSetRegion())"); // Create an ISPC GhostBlockBrickedVolume object and assign type-specific // function pointers. ispcEquivalent = ispc::GBBV_createInstance(this, (int)getVoxelType(), (const ispc::vec3i &)this->dimensions); }
void BlockBrickedVolume::createEquivalentISPC() { //! Get the voxel type. voxelType = getParamString("voxelType", "unspecified"); exitOnCondition(getVoxelType() == OSP_UNKNOWN, "unrecognized voxel type"); //! Create an ISPC BlockBrickedVolume object and assign type-specific function pointers. ispcEquivalent = ispc::BlockBrickedVolume_createInstance((int) getVoxelType()); //! Get the volume dimensions. volumeDimensions = getParam3i("dimensions", vec3i(0)); exitOnCondition(reduce_min(volumeDimensions) <= 0, "invalid volume dimensions"); //! Get the transfer function. transferFunction = (TransferFunction *) getParamObject("transferFunction", NULL); exitOnCondition(transferFunction == NULL, "no transfer function specified"); //! Get the value range. //! Voxel range not used for now. // vec2f voxelRange = getParam2f("voxelRange", vec2f(0.0f)); exitOnCondition(voxelRange == vec2f(0.0f), "no voxel range specified"); //! Get the gamma correction coefficient and exponent. vec2f gammaCorrection = getParam2f("gammaCorrection", vec2f(1.0f)); //! Set the volume dimensions. ispc::BlockBrickedVolume_setVolumeDimensions(ispcEquivalent, (const ispc::vec3i &) volumeDimensions); //! Set the value range (must occur before setting the transfer function). //ispc::BlockBrickedVolume_setValueRange(ispcEquivalent, (const ispc::vec2f &) voxelRange); //! Set the transfer function. ispc::BlockBrickedVolume_setTransferFunction(ispcEquivalent, transferFunction->getEquivalentISPC()); //! Set the recommended sampling rate for ray casting based renderers. ispc::BlockBrickedVolume_setSamplingRate(ispcEquivalent, getParam1f("samplingRate", 1.0f)); //! Set the gamma correction coefficient and exponent. ispc::BlockBrickedVolume_setGammaCorrection(ispcEquivalent, (const ispc::vec2f &) gammaCorrection); //! Allocate memory for the voxel data in the ISPC object. ispc::BlockBrickedVolume_allocateMemory(ispcEquivalent); }
string AdcCommand::toString(uint32_t sid /* = 0 */, bool nmdc /* = false */) const { return getHeaderString(sid, nmdc) + getParamString(nmdc); }
string AdcCommand::toString(const CID& aCID) const { return getHeaderString(aCID) + getParamString(false); }
string AdcCommand::toString() const { return getHeaderString() + getParamString(false); }
/** * \fn pla_cmdParse_GeneralCmdLine * \brief Parses the initial command line * * This function parses the initial command line, * and returns the BT & NAVC strings, * along with the common parameter. * * \note * \param CmdLine - Received command Line. * \param **bt_str - returned BT cmd line. * \param **nav_str - returned NAVC cmd line. * \return Port Number * \sa pla_cmdParse_GeneralCmdLine */ McpU32 pla_cmdParse_GeneralCmdLine(LPSTR CmdLine, char **bt_str, char **nav_str) { /* Currently, in Linux the serial port name is hardcoded in bthal_config.h. * So, put some number in order to prevent assert in a caller function */ McpU32 uPortNum = -1; char *pParam; char *paramParse; char pathfile[256] = ""; char logName[30] = ""; char logFile[256] = ""; char logIp[30] = ""; char portStr[30] = ""; unsigned long port = 0; char *pPort; int i=0; MCPF_UNUSED_PARAMETER(bt_str); pPort = strstr(CmdLine, "-p"); if(pPort != NULL) { uPortNum = atoi(pPort+2); sprintf((*nav_str), "%s%d", "-p", uPortNum); } /*Issue Fix -nav*/ if (0 != (pParam = strstr((const char *)CmdLine, "-nav"))) { paramParse = pParam; paramParse += 5; strcat (*nav_str, " "); while(*paramParse != '"') { pathfile[i] = *paramParse; paramParse++; i++; } strcat (*nav_str, pathfile); MCP_HAL_LOG_INFO(__FILE__, __LINE__, MCP_HAL_LOG_MODULE_TYPE_MCP_MAIN, ("pla_cmdParse_GeneralCmdLine111: NAV Cmd line \"%s\"", *nav_str)); } else { strcat (*nav_str, " "); strcat (*nav_str, PATHCONFIGFILE); } #ifdef ANDROID if (0 != (pParam = strstr((const char *)CmdLine, "--android_log"))) { getParamString(pParam, logName); MCP_HAL_LOG_EnableLogToAndroid((const char *)logName); } #endif if (0 != (pParam = strstr((const char *)CmdLine, "-logfile"))) { getParamString(pParam, logFile); MCP_HAL_LOG_EnableFileLogging((const char *)logFile); } else if (0 != strstr((const char *)CmdLine, "--log_to_stdout")) { MCP_HAL_LOG_EnableStdoutLogging(); } else if (0 != (pParam = strstr((const char *)CmdLine, "-log_ip"))) { getParamString(pParam, logIp); if (0 != (pParam = strstr((const char *)CmdLine, "-log_port"))) { getParamString(pParam, portStr); port = atoi((const char *)portStr); } if (strlen(logIp)>0 && port>0) { MCP_HAL_LOG_EnableUdpLogging(logIp, port); MCP_HAL_LOG_INFO(__FILE__, __LINE__, MCP_HAL_LOG_MODULE_TYPE_MCP_MAIN, ("pla_cmdParse_GeneralCmdLine: UDP logging, IP %s, port %d", logIp, port)); } } else if (0 != strstr((const char *)CmdLine, "--help")) { printf ("btipsd usage :\nbtipsd [options]\n-h, --help : Show this screen\n-r, --run_as_daemon : Run the mcpd as daemon in the background\n-l, --logfile [LOGFILENAME] : Log to specified file\n-d, --log_to_stdout : Log to STDOUT\n-log_ip [IP_ADDRESS] : Target UDP Listener IP for logging\n-log_port [PORT] : Target UDP Listener PORT for logging\n"); #ifdef ANDROID printf ("-no_android_log : Disable Android logging\n"); #endif return 0; } MCP_HAL_LOG_INFO(__FILE__, __LINE__, MCP_HAL_LOG_MODULE_TYPE_MCP_MAIN, ("pla_cmdParse_GeneralCmdLine: cmd line \"%s\"", CmdLine)); return uPortNum; }
int main(int argc, char *argv[]) { int i, j, k, l, turn; int count = 1; int cnt = 0; char *oneLine; char *twoLine; int seven[SIX] = {0,}; int temp_one[SIX] = {0,}; int temp_two[SIX] = {0,}; char *totalData = NULL; char *digit = NULL; ////////////////////////////////////////////////////////////// // 앞 뒤로 차이의 평균을 구해서 마지막 숫자에 가감함. // ////////////////////////////////////////////////////////// totalData = getParamString(); totalData = strstr(totalData, "1,"); if(totalData == NULL) { printError(); return 1; } digit = strtok(totalData, ","); if(digit == NULL) { printError(); return 1; } for(i = 0; i < SIX; i++) { // 후에 다음 데이터와 뺄셈으로 차이값을 누적함. digit = strtok(NULL, ","); // 각 데이터를 1~7번으로 나누어서 저장. if(digit == NULL) { printError(); return 1; } temp_one[i] = atoi(digit); } digit = strtok(NULL, "\n"); if(digit == NULL) { printError(); return 1; } while (1) { digit = strtok(NULL, ","); if(digit == NULL) { printError(); return 1; } if(atoi(digit) == 0) { break; } for(i = 0; i < SIX; i++) { digit = strtok(NULL, ","); // 두번째 데이터를 뽑아냄 if(digit == NULL) { printError(); return 1; } temp_two[i] = atoi(digit); } strtok(NULL, "\n"); if(digit == NULL) { printError(); return 1; } for(i = 0; i < SIX; i++) // 앞과 뒤의 데이터 차이값을 누적 { seven[i] += temp_two[i] - temp_one[i]; } memcpy(temp_one, temp_two, sizeof(int) * SIX); } printf("Content-Type: text/html\n\n\n"); printf("<HTML>\n<HEAD></HEAD>\n<BODY>\n"); printf("average : "); for (i = 0; i < SIX; i++) { printf("%d ", seven[i]); } printf("</br>"); printf("lotto number : "); for(j = 0; j < SIX; j++) { printf("%d ", temp_two[j] + seven[j]); } printf("</br>"); printf("</BODY>\n</HTML>\n"); return 0; }
//! Allocate storage and populate the volume. void AMRVolume::commit() { updateEditableParameters(); // Make the voxel value range visible to the application. if (findParam("voxelRange") == nullptr) setParam("voxelRange", voxelRange); else voxelRange = getParam2f("voxelRange", voxelRange); auto methodStringFromEnv = utility::getEnvVar<std::string>("OSPRAY_AMR_METHOD"); std::string methodString = methodStringFromEnv.value_or(getParamString("amrMethod","current")); if (methodString == "finest" || methodString == "finestLevel") ispc::AMR_install_finest(getIE()); else if (methodString == "current" || methodString == "currentLevel") ispc::AMR_install_current(getIE()); else if (methodString == "octant") ispc::AMR_install_octant(getIE()); if (data != nullptr) //TODO: support data updates return; brickInfoData = getParamData("brickInfo"); assert(brickInfoData); assert(brickInfoData->data); brickDataData = getParamData("brickData"); assert(brickDataData); assert(brickDataData->data); data = make_unique<amr::AMRData>(*brickInfoData,*brickDataData); accel = make_unique<amr::AMRAccel>(*data); // finding coarset cell size + finest level cell width float coarsestCellWidth = 0.f; float finestLevelCellWidth = data->brick[0].cellWidth; box3i rootLevelBox = empty; for (auto &b : data->brick) { if (b.level == 0) rootLevelBox.extend(b.box); finestLevelCellWidth = min(finestLevelCellWidth, b.cellWidth); coarsestCellWidth = max(coarsestCellWidth, b.cellWidth); } vec3i rootGridDims = rootLevelBox.size() + vec3i(1); ospLogF(1) << "found root level dimensions of " << rootGridDims; ospLogF(1) << "coarsest cell width is " << coarsestCellWidth << std::endl; auto rateFromEnv = utility::getEnvVar<float>("OSPRAY_AMR_SAMPLING_STEP"); float samplingStep = rateFromEnv.value_or(0.1f * coarsestCellWidth); box3f worldBounds = accel->worldBounds; const vec3f gridSpacing = getParam3f("gridSpacing", vec3f(1.f)); const vec3f gridOrigin = getParam3f("gridOrigin", vec3f(0.f)); voxelType = getParamString("voxelType", "unspecified"); auto voxelTypeID = getVoxelType(); switch (voxelTypeID) { case OSP_UCHAR: break; case OSP_SHORT: break; case OSP_USHORT: break; case OSP_FLOAT: break; case OSP_DOUBLE: break; default: throw std::runtime_error("amrVolume unsupported voxel type '" + voxelType + "'"); } ispc::AMRVolume_set(getIE(), (ispc::box3f&)worldBounds, samplingStep, (const ispc::vec3f&)gridOrigin, (const ispc::vec3f&)gridSpacing); ispc::AMRVolume_setAMR(getIE(), accel->node.size(), &accel->node[0], accel->leaf.size(), &accel->leaf[0], accel->level.size(), &accel->level[0], voxelTypeID, (ispc::box3f &)worldBounds); tasking::parallel_for(accel->leaf.size(),[&](size_t leafID) { ispc::AMRVolume_computeValueRangeOfLeaf(getIE(), leafID); }); }
OSPDataType AMRVolume::getVoxelType() { return (voxelType == "") ? typeForString(getParamString("voxelType", "unspecified")): typeForString(voxelType.c_str()); }