STDMETHODIMP CDocProvider::CanDiagnose(LONG lError, VARIANT_BOOL *pbDiagnose) { CResourceSwapper rs(_Module.m_hInstResource); return CWSErrorInfo::CanDiagnose(lError, pbDiagnose); }
int main(int argc, char **argv) { ros::init(argc, argv, "publish_warehouse_data", ros::init_options::AnonymousName); // time to wait in between publishing messages double delay = 0.001; boost::program_options::options_description desc; desc.add_options() ("help", "Show help message") ("host", boost::program_options::value<std::string>(), "Host for the MongoDB.") ("port", boost::program_options::value<std::size_t>(), "Port for the MongoDB.") ("scene", boost::program_options::value<std::string>(), "Name of scene to publish.") ("planning_requests", "Also publish the planning requests that correspond to the scene") ("planning_results", "Also publish the planning results that correspond to the scene") ("constraint", boost::program_options::value<std::string>(), "Name of constraint to publish.") ("state", boost::program_options::value<std::string>(), "Name of the robot state to publish.") ("delay", boost::program_options::value<double>()->default_value(delay), "Time to wait in between publishing messages (s)"); boost::program_options::variables_map vm; boost::program_options::store(boost::program_options::parse_command_line(argc, argv, desc), vm); boost::program_options::notify(vm); if (vm.count("help") || (!vm.count("scene") && !vm.count("constraint") && !vm.count("state"))) { std::cout << desc << std::endl; return 1; } try { delay = vm["delay"].as<double>(); } catch(...) { std::cout << desc << std::endl; return 2; } ros::AsyncSpinner spinner(1); spinner.start(); ros::NodeHandle nh; ros::Publisher pub_scene, pub_req, pub_res, pub_constr, pub_state; ros::Duration wait_time(delay); // publish the scene if (vm.count("scene")) { pub_scene = nh.advertise<moveit_msgs::PlanningScene>(PLANNING_SCENE_TOPIC, 10); bool req = vm.count("planning_requests"); bool res = vm.count("planning_results"); if (req) pub_req = nh.advertise<moveit_msgs::MotionPlanRequest>(PLANNING_REQUEST_TOPIC, 100); if (res) pub_res = nh.advertise<moveit_msgs::RobotTrajectory>(PLANNING_RESULTS_TOPIC, 100); moveit_warehouse::PlanningSceneStorage pss(vm.count("host") ? vm["host"].as<std::string>() : "", vm.count("port") ? vm["port"].as<std::size_t>() : 0); ros::spinOnce(); std::vector<std::string> scene_names; pss.getPlanningSceneNames(vm["scene"].as<std::string>(), scene_names); for (std::size_t i = 0 ; i < scene_names.size() ; ++i) { moveit_warehouse::PlanningSceneWithMetadata pswm; if (pss.getPlanningScene(pswm, scene_names[i])) { ROS_INFO("Publishing scene '%s'", pswm->lookupString(moveit_warehouse::PlanningSceneStorage::PLANNING_SCENE_ID_NAME).c_str()); pub_scene.publish(static_cast<const moveit_msgs::PlanningScene&>(*pswm)); ros::spinOnce(); // publish optional data associated to the scene if (req || res) { std::vector<moveit_warehouse::MotionPlanRequestWithMetadata> planning_queries; std::vector<std::string> query_names; pss.getPlanningQueries(planning_queries, query_names, pswm->name); ROS_INFO("There are %d planning queries associated to the scene", (int)planning_queries.size()); ros::WallDuration(0.5).sleep(); for (std::size_t i = 0 ; i < planning_queries.size() ; ++i) { if (req) { ROS_INFO("Publishing query '%s'", query_names[i].c_str()); pub_req.publish(static_cast<const moveit_msgs::MotionPlanRequest&>(*planning_queries[i])); ros::spinOnce(); } if (res) { std::vector<moveit_warehouse::RobotTrajectoryWithMetadata> planning_results; pss.getPlanningResults(planning_results, query_names[i], pswm->name); for (std::size_t j = 0 ; j < planning_results.size() ; ++j) { pub_res.publish(static_cast<const moveit_msgs::RobotTrajectory&>(*planning_results[j])); ros::spinOnce(); } } } } wait_time.sleep(); } } } // publish constraints if (vm.count("constraint")) { moveit_warehouse::ConstraintsStorage cs(vm.count("host") ? vm["host"].as<std::string>() : "", vm.count("port") ? vm["port"].as<std::size_t>() : 0); pub_constr = nh.advertise<moveit_msgs::Constraints>(CONSTRAINTS_TOPIC, 100); std::vector<std::string> cnames; cs.getKnownConstraints(vm["constraint"].as<std::string>(), cnames); for (std::size_t i = 0 ; i < cnames.size() ; ++i) { moveit_warehouse::ConstraintsWithMetadata cwm; if (cs.getConstraints(cwm, cnames[i])) { ROS_INFO("Publishing constraints '%s'", cwm->lookupString(moveit_warehouse::ConstraintsStorage::CONSTRAINTS_ID_NAME).c_str()); pub_constr.publish(static_cast<const moveit_msgs::Constraints&>(*cwm)); ros::spinOnce(); wait_time.sleep(); } } } // publish constraints if (vm.count("state")) { moveit_warehouse::RobotStateStorage rs(vm.count("host") ? vm["host"].as<std::string>() : "", vm.count("port") ? vm["port"].as<std::size_t>() : 0); pub_state = nh.advertise<moveit_msgs::RobotState>(STATES_TOPIC, 100); std::vector<std::string> rnames; rs.getKnownRobotStates(vm["state"].as<std::string>(), rnames); for (std::size_t i = 0 ; i < rnames.size() ; ++i) { moveit_warehouse::RobotStateWithMetadata rswm; if (rs.getRobotState(rswm, rnames[i])) { ROS_INFO("Publishing state '%s'", rswm->lookupString(moveit_warehouse::RobotStateStorage::STATE_NAME).c_str()); pub_state.publish(static_cast<const moveit_msgs::RobotState&>(*rswm)); ros::spinOnce(); wait_time.sleep(); } } } ros::WallDuration(1.0).sleep(); ROS_INFO("Done."); return 0; }
void CTMTreatmentActivitybyDept::ExportHoatdongdieutri(CString szFromDate, CString szToDate, CString szDoctor) { CHMSMainFrame *pMF = (CHMSMainFrame*) AfxGetMainWnd(); CRecord rs(&pMF->m_db); CString szSQL, tmpStr, tmpStr1, szFromDateLabel, szToDateLabel, szWhere,szAmount, szOutpatient, m_szStatus; CString szDate, szSysDate; szSysDate = pMF->GetSysDate(); CReport rpt; szSQL = GetQueryString(); BeginWaitCursor(); _fmsg(_T("%s"), szSQL); rs.ExecSQL(szSQL); if (rs.IsEOF()) { AfxMessageBox(_T("No Data")); return; } CExcel xls; xls.CreateSheet(1); xls.SetWorksheet(0); xls.SetColumnWidth(1, 40); xls.SetCellMergedColumns(0, 1, 2); xls.SetCellMergedColumns(0, 2, 2); xls.SetCellText(0, 1, pMF->m_CompanyInfo.sc_pname,4098,true,12,0); xls.SetCellText(0, 2, pMF->m_CompanyInfo.sc_name,4098,true,12,0); xls.SetCellMergedColumns(0,4,14); xls.SetCellText(0, 4, _T("\x42\xC1O \x43\xC1O HO\x1EA0T \x110\x1ED8NG TH\x45O L\x1AF\x1EE2T \x110I\x1EC0U TR\x1ECA"),4098,true,16,0); xls.SetCellMergedColumns(0,5,12); tmpStr.Format(_T("T\x1EEB ng\xE0y %s \x111\x1EBFn ng\xE0y %s"), CDate::Convert(m_szFromDate, yyyymmdd, ddmmyyyy), CDate::Convert(m_szToDate, yyyymmdd, ddmmyyyy)); xls.SetCellText(0, 5, tmpStr,4098,true,12,0); int nRow = 7, age=0; xls.SetCellText(0, nRow, _T("STT"), 528386,true); TranslateString(_T("Dept"), tmpStr); xls.SetCellText(1, nRow, tmpStr, 528386,true); TranslateString(_T("Bed"), tmpStr); xls.SetCellText(2, nRow, tmpStr, 528386,true); TranslateString(_T("\x110\x1EA7u k\x1EF3"), tmpStr); xls.SetCellText(3, nRow, tmpStr, 528386,true); TranslateString(_T("Total"), tmpStr); xls.SetCellText(4, nRow, tmpStr, 528386,true); TranslateString(_T("Children < 6 Age"), tmpStr); xls.SetCellText(5, nRow, tmpStr, 528386,true); TranslateString(_T("Tr\x1EBB < 24 ng\xE0y"), tmpStr); xls.SetCellText(6, nRow, tmpStr, 528386,true); TranslateString(_T("Emergency"), tmpStr); xls.SetCellText(7, nRow, tmpStr, 528386,true); TranslateString(_T("Ng\xE0y DT"), tmpStr); xls.SetCellText(8, nRow, tmpStr, 528386,true); TranslateString(_T("T\x1ED5ng s\x1ED1 t\x1EED vong"), tmpStr); xls.SetCellText(9, nRow, tmpStr, 528386,true); TranslateString(_T("Tr\x1EBB < 6 tu\x1ED5i t\x1EED vong"), tmpStr); xls.SetCellText(10, nRow, tmpStr, 528386,true); TranslateString(_T("T\x1EED vong 24 ng\xE0y"), tmpStr); xls.SetCellText(11, nRow, tmpStr, 528386,true); TranslateString(_T("T\x1EED vong tr\x1B0\x1EDB\x63 24 gi\x1EDD"), tmpStr); xls.SetCellText(12, nRow, tmpStr, 528386,true); TranslateString(_T("T\x1EED vong s\x61u 24 gi\x1EDD"), tmpStr); xls.SetCellText(13, nRow, tmpStr, 528386,true); TranslateString(_T("BHYT"), tmpStr); xls.SetCellText(14, nRow, tmpStr, 528386,true); TranslateString(_T("Hospital Transfer"), tmpStr); xls.SetCellText(15, nRow, tmpStr, 528386,true); TranslateString(_T("T\x1ED3n \x63u\x1ED1i k\x1EF3"), tmpStr); xls.SetCellText(16, nRow, tmpStr, 528386,true); int nIndex = 1, SongayDT=0; int i=0,nTotal[17]; for (i=0;i<=16;i++) { nTotal[i]=0; } while(!rs.IsEOF()) { nRow++; tmpStr.Format(_T("%d"), nIndex++); xls.SetCellText(0, nRow, tmpStr, FMT_INTEGER); rs.GetValue(_T("Deptname"), tmpStr); xls.SetCellText(1, nRow, tmpStr, FMT_TEXT); rs.GetValue(_T("Totalbed"), tmpStr); nTotal[2] += ToInt(tmpStr); xls.SetCellText(2, nRow, tmpStr, FMT_NUMBER1); rs.GetValue(_T("oldpatient"), tmpStr); nTotal[3] += ToInt(tmpStr); xls.SetCellText(3, nRow, tmpStr, FMT_NUMBER1); rs.GetValue(_T("Admission"), tmpStr); nTotal[4] += ToInt(tmpStr); xls.SetCellText(4, nRow, tmpStr, FMT_NUMBER1); rs.GetValue(_T("tre15"), tmpStr); nTotal[5] += ToInt(tmpStr); xls.SetCellText(5, nRow, tmpStr, FMT_NUMBER1); rs.GetValue(_T("Tre24Day"), tmpStr); nTotal[6] += ToInt(tmpStr); xls.SetCellText(6, nRow, tmpStr, FMT_NUMBER1); rs.GetValue(_T("emergency"), tmpStr); nTotal[7] += ToInt(tmpStr); xls.SetCellText(7, nRow, tmpStr, FMT_NUMBER1); rs.GetValue(_T("SongayDT"), tmpStr); rs.GetValue(_T("SongayDTO"), tmpStr1); if (m_bCheckBed) SongayDT=(ToInt(tmpStr)); else SongayDT=(ToInt(tmpStr) + ToInt(tmpStr1)); nTotal[8] += SongayDT; tmpStr.Format(_T("%ld"), SongayDT); xls.SetCellText(8, nRow, tmpStr, FMT_NUMBER1); rs.GetValue(_T("dead"), tmpStr); nTotal[9] += ToInt(tmpStr); xls.SetCellText(9, nRow, tmpStr, FMT_NUMBER1); rs.GetValue(_T("dead15"), tmpStr); nTotal[10] += ToInt(tmpStr); xls.SetCellText(10, nRow, tmpStr, FMT_NUMBER1); rs.GetValue(_T("Dead24Day"), tmpStr); nTotal[11] += ToInt(tmpStr); xls.SetCellText(11, nRow, tmpStr, FMT_NUMBER1); rs.GetValue(_T("Dead24h"), tmpStr); nTotal[12] += ToInt(tmpStr); xls.SetCellText(12, nRow, tmpStr, FMT_NUMBER1); rs.GetValue(_T("Dead24hf"), tmpStr); nTotal[13] += ToInt(tmpStr); xls.SetCellText(13, nRow, tmpStr, FMT_NUMBER1); rs.GetValue(_T("BHYT"), tmpStr); nTotal[14] += ToInt(tmpStr); xls.SetCellText(14, nRow, tmpStr, FMT_NUMBER1); rs.GetValue(_T("Chuyenvien"), tmpStr); nTotal[15] += ToInt(tmpStr); xls.SetCellText(15, nRow, tmpStr, FMT_NUMBER1); rs.GetValue(_T("remain"), tmpStr); nTotal[16] += ToInt(tmpStr); xls.SetCellText(16, nRow, tmpStr, FMT_NUMBER1); rs.MoveNext(); } nRow++; TranslateString(_T("Total"),tmpStr); xls.SetCellText(1, nRow, tmpStr, FMT_TEXT, true); for (int i =2; i <= 16; i++){ tmpStr.Format(_T("%d"),nTotal[i] ); xls.SetCellText(i, nRow, tmpStr, FMT_NUMBER1, true); } xls.Save(_T("Exports\\Bao cao hoat dong dieu tri theo luot dieu tri.xls")); EndWaitCursor(); }
MeshVisualizer::MeshVisualizer(const Flags flags): flags(flags), transformationProjectionMatrixUniform(0), viewportSizeUniform(1), colorUniform(2), wireframeColorUniform(3), wireframeWidthUniform(4), smoothnessUniform(5) { #ifndef MAGNUM_TARGET_GLES2 if(flags & Flag::Wireframe && !(flags & Flag::NoGeometryShader)) { #ifndef MAGNUM_TARGET_GLES MAGNUM_ASSERT_VERSION_SUPPORTED(Version::GL320); MAGNUM_ASSERT_EXTENSION_SUPPORTED(Extensions::GL::ARB::geometry_shader4); #elif !defined(MAGNUM_TARGET_WEBGL) MAGNUM_ASSERT_EXTENSION_SUPPORTED(Extensions::GL::EXT::geometry_shader); #endif } #else if(flags & Flag::Wireframe) MAGNUM_ASSERT_EXTENSION_SUPPORTED(Extensions::GL::OES::standard_derivatives); #endif #ifdef MAGNUM_BUILD_STATIC /* Import resources on static build, if not already */ if(!Utility::Resource::hasGroup("MagnumShaders")) importShaderResources(); #endif Utility::Resource rs("MagnumShaders"); #ifndef MAGNUM_TARGET_GLES const Version version = Context::current().supportedVersion({Version::GL320, Version::GL310, Version::GL300, Version::GL210}); CORRADE_INTERNAL_ASSERT(!flags || flags & Flag::NoGeometryShader || version >= Version::GL320); #elif !defined(MAGNUM_TARGET_WEBGL) const Version version = Context::current().supportedVersion({Version::GLES310, Version::GLES300, Version::GLES200}); CORRADE_INTERNAL_ASSERT(!flags || flags & Flag::NoGeometryShader || version >= Version::GLES310); #else const Version version = Context::current().supportedVersion({Version::GLES300, Version::GLES200}); #endif Shader vert = Implementation::createCompatibilityShader(rs, version, Shader::Type::Vertex); Shader frag = Implementation::createCompatibilityShader(rs, version, Shader::Type::Fragment); vert.addSource(flags & Flag::Wireframe ? "#define WIREFRAME_RENDERING\n" : "") .addSource(flags & Flag::NoGeometryShader ? "#define NO_GEOMETRY_SHADER\n" : "") #ifdef MAGNUM_TARGET_WEBGL .addSource("#define SUBSCRIPTING_WORKAROUND\n") #elif defined(MAGNUM_TARGET_GLES2) .addSource(Context::current().detectedDriver() & Context::DetectedDriver::ProbablyAngle ? "#define SUBSCRIPTING_WORKAROUND\n" : "") #endif .addSource(rs.get("generic.glsl")) .addSource(rs.get("MeshVisualizer.vert")); frag.addSource(flags & Flag::Wireframe ? "#define WIREFRAME_RENDERING\n" : "") .addSource(flags & Flag::NoGeometryShader ? "#define NO_GEOMETRY_SHADER\n" : "") .addSource(rs.get("MeshVisualizer.frag")); #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) std::optional<Shader> geom; if(flags & Flag::Wireframe && !(flags & Flag::NoGeometryShader)) { geom = Implementation::createCompatibilityShader(rs, version, Shader::Type::Geometry); geom->addSource(rs.get("MeshVisualizer.geom")); } #endif #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) if(geom) CORRADE_INTERNAL_ASSERT_OUTPUT(Shader::compile({vert, *geom, frag})); else #endif CORRADE_INTERNAL_ASSERT_OUTPUT(Shader::compile({vert, frag})); attachShaders({vert, frag}); #if !defined(MAGNUM_TARGET_GLES2) && !defined(MAGNUM_TARGET_WEBGL) if(geom) attachShader(*geom); #endif #ifndef MAGNUM_TARGET_GLES if(!Context::current().isExtensionSupported<Extensions::GL::ARB::explicit_attrib_location>(version)) #else if(!Context::current().isVersionSupported(Version::GLES300)) #endif { bindAttributeLocation(Position::Location, "position"); #if !defined(MAGNUM_TARGET_GLES) || defined(MAGNUM_TARGET_GLES2) #ifndef MAGNUM_TARGET_GLES if(!Context::current().isVersionSupported(Version::GL310)) #endif { bindAttributeLocation(VertexIndex::Location, "vertexIndex"); } #endif } CORRADE_INTERNAL_ASSERT_OUTPUT(link()); #ifndef MAGNUM_TARGET_GLES if(!Context::current().isExtensionSupported<Extensions::GL::ARB::explicit_uniform_location>(version)) #endif { transformationProjectionMatrixUniform = uniformLocation("transformationProjectionMatrix"); colorUniform = uniformLocation("color"); if(flags & Flag::Wireframe) { wireframeColorUniform = uniformLocation("wireframeColor"); wireframeWidthUniform = uniformLocation("wireframeWidth"); smoothnessUniform = uniformLocation("smoothness"); if(!(flags & Flag::NoGeometryShader)) viewportSizeUniform = uniformLocation("viewportSize"); } } /* Set defaults in OpenGL ES (for desktop they are set in shader code itself) */ #ifdef MAGNUM_TARGET_GLES setColor(Color3(1.0f)); if(flags & Flag::Wireframe) { setWireframeColor(Color3(0.0f)); setWireframeWidth(1.0f); setSmoothness(2.0f); } #endif }
NS_IMETHODIMP nsFirstLetterFrame::Reflow(nsPresContext* aPresContext, nsHTMLReflowMetrics& aMetrics, const nsHTMLReflowState& aReflowState, nsReflowStatus& aReflowStatus) { DO_GLOBAL_REFLOW_COUNT("nsFirstLetterFrame"); DISPLAY_REFLOW(aPresContext, this, aReflowState, aMetrics, aReflowStatus); nsresult rv = NS_OK; // Grab overflow list DrainOverflowFrames(aPresContext); nsIFrame* kid = mFrames.FirstChild(); // Setup reflow state for our child nsSize availSize(aReflowState.availableWidth, aReflowState.availableHeight); const nsMargin& bp = aReflowState.mComputedBorderPadding; nscoord lr = bp.left + bp.right; nscoord tb = bp.top + bp.bottom; NS_ASSERTION(availSize.width != NS_UNCONSTRAINEDSIZE, "should no longer use unconstrained widths"); availSize.width -= lr; if (NS_UNCONSTRAINEDSIZE != availSize.height) { availSize.height -= tb; } // Reflow the child if (!aReflowState.mLineLayout) { // When there is no lineLayout provided, we provide our own. The // only time that the first-letter-frame is not reflowing in a // line context is when its floating. nsHTMLReflowState rs(aPresContext, aReflowState, kid, availSize); nsLineLayout ll(aPresContext, nsnull, &aReflowState, nsnull); ll.BeginLineReflow(bp.left, bp.top, availSize.width, NS_UNCONSTRAINEDSIZE, PR_FALSE, PR_TRUE); rs.mLineLayout = ≪ ll.SetInFirstLetter(PR_TRUE); ll.SetFirstLetterStyleOK(PR_TRUE); kid->WillReflow(aPresContext); kid->Reflow(aPresContext, aMetrics, rs, aReflowStatus); ll.EndLineReflow(); ll.SetInFirstLetter(PR_FALSE); } else { // Pretend we are a span and reflow the child frame nsLineLayout* ll = aReflowState.mLineLayout; PRBool pushedFrame; ll->SetInFirstLetter( mStyleContext->GetPseudo() == nsCSSPseudoElements::firstLetter); ll->BeginSpan(this, &aReflowState, bp.left, availSize.width); ll->ReflowFrame(kid, aReflowStatus, &aMetrics, pushedFrame); ll->EndSpan(this); ll->SetInFirstLetter(PR_FALSE); } // Place and size the child and update the output metrics kid->SetRect(nsRect(bp.left, bp.top, aMetrics.width, aMetrics.height)); kid->FinishAndStoreOverflow(&aMetrics); kid->DidReflow(aPresContext, nsnull, NS_FRAME_REFLOW_FINISHED); aMetrics.width += lr; aMetrics.height += tb; aMetrics.ascent += bp.top; mBaseline = aMetrics.ascent; // Ensure that the overflow rect contains the child textframe's overflow rect. // Note that if this is floating, the overline/underline drawable area is in // the overflow rect of the child textframe. aMetrics.UnionOverflowAreasWithDesiredBounds(); ConsiderChildOverflow(aMetrics.mOverflowAreas, kid); // Create a continuation or remove existing continuations based on // the reflow completion status. if (NS_FRAME_IS_COMPLETE(aReflowStatus)) { if (aReflowState.mLineLayout) { aReflowState.mLineLayout->SetFirstLetterStyleOK(PR_FALSE); } nsIFrame* kidNextInFlow = kid->GetNextInFlow(); if (kidNextInFlow) { // Remove all of the childs next-in-flows static_cast<nsContainerFrame*>(kidNextInFlow->GetParent()) ->DeleteNextInFlowChild(aPresContext, kidNextInFlow, PR_TRUE); } } else { // Create a continuation for the child frame if it doesn't already // have one. if (!GetStyleDisplay()->IsFloating()) { nsIFrame* nextInFlow; rv = CreateNextInFlow(aPresContext, kid, nextInFlow); if (NS_FAILED(rv)) { return rv; } // And then push it to our overflow list const nsFrameList& overflow = mFrames.RemoveFramesAfter(kid); if (overflow.NotEmpty()) { SetOverflowFrames(aPresContext, overflow); } } else if (!kid->GetNextInFlow()) { // For floating first letter frames (if a continuation wasn't already // created for us) we need to put the continuation with the rest of the // text that the first letter frame was made out of. nsIFrame* continuation; rv = CreateContinuationForFloatingParent(aPresContext, kid, &continuation, PR_TRUE); } } FinishAndStoreOverflow(&aMetrics); NS_FRAME_SET_TRUNCATION(aReflowStatus, aReflowState, aMetrics); return rv; }
inline void update(int p){dmin[p]=Min(dmin[ls(p)]+prev[ls(p)],dmin[rs(p)]+prev[rs(p)]);}
void CEMQtyAtExam::OnExportSelect(){ _debug(_T("%s"), CString(typeid(this).name())); CHMSMainFrame *pMF = (CHMSMainFrame*) AfxGetMainWnd(); UpdateData(true); CRecord rs(&pMF->m_db); CString szSQL, szTemp, tmpStr; CExcel xls; BeginWaitCursor(); szSQL = GetQueryString(); rs.ExecSQL(szSQL); _fmsg(_T("%s"), szSQL); xls.CreateSheet(1); xls.SetWorksheet(0); xls.SetColumnWidth(0, 7); xls.SetColumnWidth(1, 30); xls.SetColumnWidth(2, 15 ); xls.SetColumnWidth(3, 15); xls.SetColumnWidth(4, 15); xls.SetColumnWidth(5, 15); int nRow = 0, nCol = 0; xls.SetCellMergedColumns(nCol, nRow, 4); xls.SetCellMergedColumns(nCol, nRow + 1, 4); xls.SetCellText(nCol, nRow, pMF->m_CompanyInfo.sc_pname, FMT_TEXT | FMT_CENTER, true, 10); xls.SetCellText(nCol, nRow + 1, pMF->m_CompanyInfo.sc_name, FMT_TEXT | FMT_CENTER, true, 10); xls.SetCellMergedColumns(nCol, nRow + 2, 4); xls.SetCellMergedColumns(nCol, nRow + 3, 4); xls.SetCellText(nCol, nRow + 2, _T("KH\xC1M T\x1EA0I \x43\xC1\x43 PH\xD2NG TH\x45O \x42\xC1\x43 S\x1EF8"), FMT_TEXT | FMT_CENTER, true, 13); tmpStr.Format(_T("T\x1EEB ng\xE0y: %s \x110\x1EBFn ng\xE0y: %s"), CDateTime::Convert(m_szFromDate, yyyymmdd|hhmmss, ddmmyyyy|hhmmss), CDateTime::Convert(m_szToDate, yyyymmdd|hhmmss, ddmmyyyy|hhmmss)); xls.SetCellText(nCol, nRow + 3, tmpStr, FMT_TEXT | FMT_CENTER, true, 11); xls.SetCellText(nCol, nRow + 4, _T("STT"), FMT_TEXT | FMT_CENTER, true, 11); xls.SetCellText(nCol + 1, nRow + 4, _T("\x42\xE1\x63 s\x1EF9"), FMT_TEXT | FMT_CENTER, true, 11); xls.SetCellText(nCol + 2, nRow + 4, _T("Ph\xF2ng kh\xE1m"), FMT_TEXT | FMT_CENTER, true, 11); xls.SetCellText(nCol + 3, nRow + 4, _T("Qu\xE2n"), FMT_TEXT | FMT_CENTER, true, 11); xls.SetCellText(nCol + 4, nRow + 4, _T("H\x1B0u"), FMT_TEXT | FMT_CENTER, true, 11); xls.SetCellText(nCol + 5, nRow + 4, _T("T\x1ED5ng"), FMT_TEXT | FMT_CENTER, true, 11); nRow += 5; int nIndex = 1; int nTotal1 = 0,nTotal2 = 0, nTotal3 = 0 ; while (!rs.IsEOF()) { szTemp.Format(_T("%d"), nIndex); xls.SetCellText(nCol, nRow, szTemp, FMT_INTEGER); szTemp = rs.GetValue(_T("doctorname")); xls.SetCellText(nCol + 1, nRow, szTemp, FMT_TEXT); szTemp = rs.GetValue(_T("bhquan")); nTotal1 += ToInt(szTemp); xls.SetCellText(nCol + 3, nRow, szTemp, FMT_NUMBER1); szTemp = rs.GetValue(_T("bhhuu")); nTotal2 += ToInt(szTemp); xls.SetCellText(nCol + 4, nRow, szTemp, FMT_NUMBER1); szTemp = rs.GetValue(_T("tongso")); nTotal3 += ToInt(szTemp); xls.SetCellText(nCol + 5, nRow, szTemp, FMT_NUMBER1); nIndex++; nRow++; rs.MoveNext(); } xls.SetCellMergedColumns(nCol, nRow, 2); xls.SetCellText(nCol, nRow, _T("T\x1ED5ng \x63\x1ED9ng"), FMT_TEXT | FMT_CENTER, true, 12); xls.SetCellText(nCol + 3, nRow, int2str(nTotal1), FMT_NUMBER1, true, 12 ); xls.SetCellText(nCol + 4, nRow, int2str(nTotal2), FMT_NUMBER1, true, 12 ); xls.SetCellText(nCol + 5, nRow, int2str(nTotal3), FMT_NUMBER1, true, 12 ); EndWaitCursor(); xls.Save(_T("Exports\\Tinh hinh kham benh theo bac sy.xls")); }
bool NetMgr::start() { auto connecters = ServerConfig::getRef().getConfigConnect(LogicServer); for (auto con : connecters) { SessionID cID = SessionManager::getRef().addConnecter(con._remoteIP, con._remotePort); SessionManager::getRef().getConnecterOptions(cID)._onSessionLinked = std::bind(&NetMgr::event_onLinked, this, _1); SessionManager::getRef().getConnecterOptions(cID)._onSessionClosed = std::bind(&NetMgr::event_onClosed, this, _1); SessionManager::getRef().getConnecterOptions(cID)._onBlockDispatch = [](TcpSessionPtr session, const char * begin, unsigned int len) { ReadStream rs(begin, len); MessageDispatcher::getRef().dispatch(session, rs.getProtoID(), rs); }; if (cID == InvalidSessionID) { LOGE("addConnecter error."); return false; } if (!SessionManager::getRef().openConnecter(cID)) { LOGE("openConnecter error."); return false; } } _innerAID = SessionManager::getRef().addAccepter(ServerConfig::getRef().getConfigListen(LogicServer)._ip, ServerConfig::getRef().getConfigListen(LogicServer)._port); if (_innerAID == InvalidAccepterID) { LOGE("addAccepter error"); return false; } SessionManager::getRef().getAccepterOptions(_innerAID)._whitelistIP = ServerConfig::getRef().getConfigListen(LogicServer)._whiteList; SessionManager::getRef().getAccepterOptions(_innerAID)._sessionOptions._onSessionLinked = std::bind(&NetMgr::event_onLinked, this, _1); SessionManager::getRef().getAccepterOptions(_innerAID)._sessionOptions._onSessionClosed = std::bind(&NetMgr::event_onClosed, this, _1); SessionManager::getRef().getAccepterOptions(_innerAID)._sessionOptions._onSessionPulse = std::bind(&NetMgr::event_onSessionPulse, this, _1); SessionManager::getRef().getAccepterOptions(_innerAID)._sessionOptions._onBlockDispatch = DispatchFunction; if (!SessionManager::getRef().openAccepter(_innerAID)) { LOGE("openAccepter error"); return false; } else { LOGI("openAccepter seccuss."); } if (ServerConfig::getRef().getConfigListen(LogicServer)._port != 0) { _wAID = SessionManager::getRef().addAccepter(ServerConfig::getRef().getConfigListen(LogicServer)._wip, ServerConfig::getRef().getConfigListen(LogicServer)._wport); if (_wAID != InvalidAccepterID) { SessionManager::getRef().getAccepterOptions(_wAID)._sessionOptions._onSessionLinked = std::bind(&NetMgr::event_onLinked, this, _1); SessionManager::getRef().getAccepterOptions(_wAID)._sessionOptions._onSessionClosed = std::bind(&NetMgr::event_onClosed, this, _1); SessionManager::getRef().getAccepterOptions(_wAID)._sessionOptions._onSessionPulse = std::bind(&NetMgr::event_onSessionPulse, this, _1); SessionManager::getRef().getAccepterOptions(_wAID)._sessionOptions._onBlockDispatch = DispatchFunction; SessionManager::getRef().openAccepter(_wAID); } } return true; }
BOOL CFoulerDoc::OpenXLS(CString sFile) { int i; double dData; CDatabase db; CString sSql; CString sItem; CString sDsn; CODBCFieldInfo fieldinfo; CMainFrame *pFrame = (CMainFrame*)AfxGetMainWnd(); if( pFrame->m_strExcelDriver.IsEmpty() ) return FALSE; sDsn.Format("ODBC;DRIVER={%s};DSN='';DBQ=%s",pFrame->m_strExcelDriver,sFile); TRY { db.Open(NULL,FALSE,TRUE,sDsn);// Open the db using the former created pseudo DSN CRecordset rs( &db );// Allocate the recordset sSql = "SELECT * FROM Data";// Build the SQL string rs.Open(CRecordset::forwardOnly,sSql,CRecordset::readOnly);// Execute that query (implicitly by opening the recordset) CFieldSelect dlg(&rs); if( dlg.DoModal() == IDCANCEL ) { rs.Close(); db.Close(); return FALSE; } BeginWaitCursor(); while( !rs.IsEOF() ) rs.MoveNext(); int iRecCount = (int)(rs.GetRecordCount()); rs.Close(); rs.Open(CRecordset::forwardOnly,sSql,CRecordset::readOnly); CProgressBar* pBar = new CProgressBar(); ClearData(); InsertData( iRecCount ); for( i=0 ; i<iRecCount ; i++ ) { rs.GetFieldValue(dlg.m_sField0,sItem); dData = atof(sItem)+dlg.m_dCo0; if( dlg.m_sField1 >= 0 && dlg.m_dCo1 != 0) { rs.GetFieldValue(dlg.m_sField1,sItem); dData += atof(sItem)*dlg.m_dCo1; } if( dlg.m_sField2 >= 0 && dlg.m_dCo2 != 0) { rs.GetFieldValue(dlg.m_sField2,sItem); dData += atof(sItem)*dlg.m_dCo2; } if( dlg.m_sField3 >= 0 && dlg.m_dCo3 != 0) { rs.GetFieldValue(dlg.m_sField3,sItem); dData += atof(sItem)*dlg.m_dCo3; } m_pOrgData[i]->SetItem( dData ); m_iSubGroupIndex++; if( m_iSubGroupIndex >= m_iSubGroupSize ) { m_iSubGroupIndex = 0; dData = 0; for( int j=i+1-m_iSubGroupSize ; j<i+1 ; j++ ) { dData += m_pOrgData[j]->GetItem(); } m_pData[i/m_iSubGroupSize]->SetItem(dData/m_iSubGroupSize); } rs.MoveNext(); pBar->SetPos( (i<<8)/iRecCount ); } delete pBar; rs.Close(); db.Close(); EndWaitCursor(); return TRUE; } CATCH(CDBException, e) { return FALSE;// A db exception occured. Pop out the details... } END_CATCH; }
static int analop_esil(RAnal *a, RAnalOp *op, ut64 addr, const ut8 *buf) { int ret = -1; ut8 opcode = buf[0]; if (!op) { return 2; } r_strbuf_init (&op->esil); r_strbuf_set (&op->esil, ""); switch (opcode >> 4) { case H8300_CMP_4BIT: //acc. to manual this is how it's done, could use == in esil r_strbuf_appendf(&op->esil, "0x%02x,r%u%c,-", imm, rdB(0)); //setZ setV("%o"); setN; setHb_B; setCb_B; maskB(0); setZ; return 0; case H8300_OR_4BIT: r_strbuf_appendf(&op->esil, "0x%02x,r%u%c,|=", imm, rdB(0)); //setZ setV("0"); setN; maskB(0); setZ; return 0; case H8300_XOR_4BIT: r_strbuf_appendf(&op->esil, "0x%02x,r%u%c,^=", imm, rdB(0)); //setZ setN; setV("0"); maskB(0); setZ; return 0; case H8300_AND_4BIT: r_strbuf_appendf(&op->esil, "0x%02x,r%u%c,&=", imm, rdB(0)); //setZ setN; setV("0"); maskB(0); setZ; return 0; case H8300_ADD_4BIT: r_strbuf_appendf(&op->esil, "0x%02x,r%u%c,+=", imm, rdB(0)); //setZ setV("%o"); setN; setH_B; setC_B; maskB(0); setZ; return 0; case H8300_ADDX_4BIT: r_strbuf_appendf(&op->esil, "0x%02x,C,+,r%u%c,+= ", imm, rdB(0), rdB(0)); //setZ setV("%o"); setN; setH_B; setC_B; maskB(0); setZ; return 0; case H8300_SUBX_4BIT: //Rd – imm – C → Rd r_strbuf_appendf(&op->esil, "0x%02x,r%u%c,-=,C,r%u%c,-=", imm, rdB(0), rdB(0)); //setZ setV("%o"); setN; setHb_B; setCb_B; maskB(0); setZ; return 0; case H8300_MOV_4BIT_2: /*TODO*/ case H8300_MOV_4BIT_3: /*TODO*/ case H8300_MOV_4BIT: /*TODO*/ return 0; default: break; }; switch (opcode) { case H8300_NOP: r_strbuf_set (&op->esil, ","); return 0; case H8300_SLEEP: /* TODO */ return 0; case H8300_STC: r_strbuf_appendf(&op->esil, "ccr,r%u%c,=", rdB(1)); return 0; case H8300_LDC: r_strbuf_appendf(&op->esil, "r%u%c,ccr,=", rdB(1)); return 0; case H8300_ORC: r_strbuf_appendf(&op->esil, "0x%02x,ccr,|=", imm); return 0; case H8300_XORC: r_strbuf_appendf(&op->esil, "0x%02x,ccr,^=", imm); return 0; case H8300_ANDC: r_strbuf_appendf(&op->esil, "0x%02x,ccr,&=", imm); return 0; case H8300_LDC_2: r_strbuf_appendf(&op->esil, "0x%02x,ccr,=", imm); return 0; case H8300_ADDB_DIRECT: r_strbuf_appendf(&op->esil, "r%u%c,r%u%c,+=", rsB(), rdB(1)); setH_B; setV("%o"); setC_B ; setN; //setZ; maskB(1); setZ; return 0; case H8300_ADDW_DIRECT: r_strbuf_appendf (&op->esil, "r%u,r%u,+=", rs(), rd()); setH_W; setV("%o"); setC_W; setN; mask(); setZ; return 0; case H8300_INC: r_strbuf_appendf(&op->esil, "1,r%u%c,+=", rdB(1)); //setZ setV("%o") ; setN; maskB(1); setZ; return 0; case H8300_ADDS: r_strbuf_appendf (&op->esil, "%d,r%u,+=", ((buf[1] & 0xf0) == 0x80) ? 2 : 1, rd()); return 0; case H8300_MOV_1: /*TODO check if flags are set internally or not*/ r_strbuf_appendf (&op->esil, "r%u%c,r%u%c,=", rsB(), rdB(1)); //setZ setN; maskB(1); setZ; return 0; case H8300_MOV_2: r_strbuf_appendf(&op->esil, "r%u,r%u,=", rs(), rd()); //setZ setN; mask(); setZ; return 0; case H8300_ADDX: //Rd + (Rs) + C → Rd r_strbuf_appendf (&op->esil, "r%u%c,C,+,r%u%c,+=", rsB(), rdB(1), rdB(1)); //setZ setV("%o"); setN; setH_B ; setC_B; maskB(1); setZ; return 0; case H8300_DAA: /*TODO*/ return 0; case H8300_SHL: /*TODO*/ return 0; case H8300_SHR: /*TODO*/ return 0; case H8300_ROTL: /*TODO*/ return 0; case H8300_ROTR: /*TODO*/ return 0; case H8300_OR: r_strbuf_appendf(&op->esil, "r%u%c,r%u%c,|=", rsB(), rdB(1)); //setZ setV("0"); setN; maskB(1); setZ; return 0; case H8300_XOR: r_strbuf_appendf(&op->esil, "r%u%c,r%u%c,^=", rsB(), rdB(1)); //setZ setV("0") ; setN; maskB(1); setZ; return 0; case H8300_AND: r_strbuf_appendf(&op->esil, "r%u%c,r%u%c,&=", rsB(), rdB(1)); //setZ setV("0"); setN; maskB(1); setZ; return 0; case H8300_NOT_NEG: if ((buf[1] & 0xf0) == 0x80) { //NEG r_strbuf_appendf(&op->esil, "r%u%c,0,-,r%u%c,=", rdB(1), rdB(1)); //setZ setHb_B; setV("%o") ; setCb_B ; setN; maskB(1); setZ; } else if ((buf[1] & 0xf0) == 0x00) { //NOT r_strbuf_appendf(&op->esil, "r%u%c,!=", rdB(1)); //setZ setV("0"); setN; maskB(1); setZ; } return 0; case H8300_SUB_1: r_strbuf_appendf(&op->esil, "r%u%c,r%u%c,-=", rsB(), rdB(1)); //setZ setHb_B; setV("%o"); setCb_B; setN; maskB(1); setZ; return 0; case H8300_SUBW: r_strbuf_appendf (&op->esil, "r%u,r%u,-=", rs(), rd()); setHb_W; setV ("%o"); setCb_W; setN; mask(); setZ; return 0; case H8300_DEC: r_strbuf_appendf (&op->esil, "1,r%u%c,-=", rdB(1)); //setZ setV("%o"); setN; maskB(1); setZ; return 0; case H8300_SUBS: r_strbuf_appendf(&op->esil, "%d,r%u,-=", ( (buf[1] & 0xf0) == 0x80) ? 2 : 1, rd()); return 0; case H8300_CMP_1: r_strbuf_appendf(&op->esil, "r%u%c,r%u%c,-", rsB(), rdB(1)); //setZ setHb_B; setV("%o"); setCb_B; setN; maskB(1); setZ; return 0; case H8300_CMP_2: r_strbuf_appendf(&op->esil, "r%u,r%u,-", rs(), rd()); //setZ setHb_W; setV("%o"); setCb_W; setN; mask(); setZ; return 0; case H8300_SUBX: //Rd – (Rs) – C → Rd r_strbuf_appendf(&op->esil, "r%u%c,r%u%c,-=,C,r%u%c,-=", rsB(), rdB(1), rdB(1)); //setZ setHb_B; setV("%o"); setCb_B; setN; maskB(1); setZ; return 0; case H8300_DAS: /*TODO*/ return 0; case H8300_BRA: r_strbuf_appendf(&op->esil, "0x%02x,pc,+=", buf[1]); return 0; case H8300_BRN: r_strbuf_appendf(&op->esil,","); return 0; case H8300_BHI: r_strbuf_appendf(&op->esil, "C,Z,|,!,?{0x%02x,pc,+=}", buf[1]); return 0; case H8300_BLS: r_strbuf_appendf(&op->esil, "C,Z,|,?{0x%02x,pc,+=}", buf[1]); return 0; case H8300_BCC: r_strbuf_appendf(&op->esil, "C,!,?{0x%02x,pc,+=}", buf[1]); return 0; case H8300_BCS: r_strbuf_appendf(&op->esil, "C,?{0x%02x,pc,+=}", buf[1]); return 0; case H8300_BNE: r_strbuf_appendf(&op->esil, "Z,!,?{0x%02x,pc,+=}", buf[1]); return 0; case H8300_BEQ: r_strbuf_appendf(&op->esil, "Z,?{0x%02x,pc,+=}", buf[1]); return 0; case H8300_BVC: r_strbuf_appendf(&op->esil, "V,!,?{0x%02x,pc,+=}", buf[1]); return 0; case H8300_BVS: r_strbuf_appendf(&op->esil, "V,?{0x%02x,pc,+=}", buf[1]); return 0; case H8300_BPL: r_strbuf_appendf(&op->esil, "N,!,?{0x%02x,pc,+=}", buf[1]); return 0; case H8300_BMI: r_strbuf_appendf(&op->esil, "N,?{0x%02x,pc,+=}", buf[1]); return 0; case H8300_BGE: r_strbuf_appendf(&op->esil, "N,V,^,!,?{0x%02x,pc,+=}", buf[1]); return 0; case H8300_BLT: r_strbuf_appendf(&op->esil, "N,V,^,?{0x%02x,pc,+=}", buf[1]); return 0; case H8300_BGT: r_strbuf_appendf(&op->esil, "Z,N,V,^,|,!,?{0x%02x,pc,+=}", buf[1]); return 0; case H8300_BLE: r_strbuf_appendf(&op->esil, "Z,N,V,^,|,?{0x%02x,pc,+=}", buf[1]); return 0; case H8300_MULXU: //Refer to pg. 100 of the manual linked at the beginning r_strbuf_appendf(&op->esil, "r%u%c,r%ul,*,r%u,=", rsB(), rd(), rd()); return 0; case H8300_DIVXU: /*TODO*/ return 0; case H8300_RTS: /*TODO*/ return 0; case H8300_BSR: /*TODO*/ return 0; case H8300_RTE: /*TODO*/ return 0; case H8300_JMP_1: /*TODO*/ return 0; case H8300_JMP_2: /*TODO*/ return 0; case H8300_JMP_3: /*TODO*/ return 0; case H8300_JSR_1: /*TODO*/ return 0; case H8300_JSR_2: /*TODO*/ return 0; case H8300_JSR_3: /*TODO*/ return 0; //NOTE - cases marked with TODO have mem. access also(not impl.) case H8300_BSET_1: /*TODO*/ //set rs&0x7th bit of rd. expr.- rd|= 1<<(rs&0x07) r_strbuf_appendf(&op->esil, "0x7,r%u%c,&,1,<<,r%u%c,|=", rsB(), rdB(1)); return 0; case H8300_BNOT_1: /*TODO*/ //invert rs&0x7th bit of rd. expr.- rd^= 1<<(rs&0x07) r_strbuf_appendf(&op->esil,"0x07,r%u%c,&,1,<<,r%u%c,^=", rsB(), rdB(1)); return 0; case H8300_BCLR_R2R8: /*TODO*/ //clear rs&0x7th bit of rd. expr.- rd&= !(1<<(rs&0x07)) r_strbuf_appendf(&op->esil, "0x7,r%u%c,&,1,<<,!,r%u%c,&=", rsB(), rdB(1)); return 0; case H8300_BTST_R2R8: /*TODO*/ //¬ (<Bit No.> of <EAd>) → Z, extract bit value and shift it back r_strbuf_appendf(&op->esil, "0x7,r%u%c,&,0x7,r%u%c,&,1,<<,r%u%c,&,>>,!,Z,=", rsB(), rsB(), rdB(1)); return 0; case H8300_BST_BIST: /*TODO*/ if (!(buf[1] & 0x80)) { //BST r_strbuf_appendf(&op->esil,"%d,C,<<,r%u%c,|=",rs(),rdB(1)); } else { //BIST r_strbuf_appendf (&op->esil, "%d,C,!,<<,r%u%c,|=", rs (), rdB (1)); } return 0; case H8300_MOV_R82IND16: /*TODO*/ return 0; case H8300_MOV_IND162R16: /*TODO*/ return 0; case H8300_MOV_R82ABS16: /*TODO*/ return 0; case H8300_MOV_ABS162R16: /*TODO*/ return 0; case H8300_MOV_R82RDEC16: /*TODO*/ return 0; case H8300_MOV_INDINC162R16: /*TODO*/ return 0; case H8300_MOV_R82DISPR16: /*TODO*/ return 0; case H8300_MOV_DISP162R16: /*TODO*/ return 0; case H8300_BSET_2: /*TODO*/ //set imm bit of rd. expr.- rd|= (1<<imm) r_strbuf_appendf(&op->esil, "%d,1,<<,r%u%c,|=", rs(), rdB(1)); return 0; case H8300_BNOT_2: /*TODO*/ //inv. imm bit of rd. expr.- rd^= (1<<imm) r_strbuf_appendf(&op->esil,"%d,1,<<,r%u%c,^=",rs(),rdB(1)); return 0; case H8300_BCLR_IMM2R8: //clear imm bit of rd. expr.- rd&= !(1<<imm) r_strbuf_appendf(&op->esil, "%d,1,<<,!,r%u%c,&=", rs(), rdB(1)); return 0; case H8300_BTST: /*TODO*/ //see BTST above r_strbuf_appendf(&op->esil, "%d,%d,1,<<,r%u%c,&,>>,!,Z,=", rs(), rs(), rdB(1)); return 0; case H8300_BOR_BIOR: /*TODO*/ if (!(buf[1] & 0x80)) { //BOR //C|=(rd&(1<<imm))>>imm r_strbuf_appendf(&op->esil, "%d,%d,1,<<,r%u%c,&,>>,C,|=", rs(), rs(), rdB(1)); } else { //BIOR //C|=!(rd&(1<<imm))>>imm r_strbuf_appendf (&op->esil, "%d,%d,1,<<,r%u%c,&,>>,!,C,|=", rs (), rs (), rdB (1)); } return 0; case H8300_BXOR_BIXOR: /*TODO*/ if (!(buf[1] & 0x80)) { //BXOR //C^=(rd&(1<<imm))>>imm r_strbuf_appendf(&op->esil, "%d,%d,1,<<,r%u%c,&,>>,C,^=", rs(), rs(), rdB(1)); } else { //BIXOR r_strbuf_appendf (&op->esil, "%d,%d,1,<<,r%u%c,&,>>,!,C,^=", rs (), rs (), rdB (1)); } return 0; case H8300_BAND_BIAND: /*TODO check functionality*/ //C&=(rd&(1<<imm))>>imm if (!(buf[1] & 0x80)) { //BAND r_strbuf_appendf(&op->esil, "%d,%d,1,<<,r%u%c,&,>>,C,&=", rs(), rs(), rdB(1)); } else { //BIAND r_strbuf_appendf (&op->esil, "%d,%d,1,<<,r%u%c,&,>>,!,C,&=", rs (), rs (), rdB (1)); } return 0; case H8300_BILD_IMM2R8: /*TODO*/ if (!(buf[1] & 0x80)) { //BLD r_strbuf_appendf(&op->esil, "%d,%d,1,<<,r%u%c,&,>>,C,=", rs(), rs(), rdB(1)); } else { //BILD r_strbuf_appendf (&op->esil, "%d,%d,1,<<,r%u%c,&,>>,!,C,=", rs (), rs (), rdB (1)); } return 0; case H8300_MOV_IMM162R16: /*TODO*/ return 0; case H8300_EEPMOV: /*TODO*/ return 0; case H8300_BIAND_IMM2IND16: /*TODO*/ return 0; case H8300_BCLR_R2IND16: /*TODO*/ return 0; case H8300_BIAND_IMM2ABS8: /*TODO*/ return 0; case H8300_BCLR_R2ABS8: /*TODO*/ return 0; default: break; }; return ret; }
MeshVisualizer::MeshVisualizer(const Flags flags): flags(flags), transformationProjectionMatrixUniform(0), viewportSizeUniform(1), colorUniform(2), wireframeColorUniform(3), wireframeWidthUniform(4), smoothnessUniform(5) { #ifndef MAGNUM_TARGET_GLES if(flags & Flag::Wireframe && !(flags & Flag::NoGeometryShader)) { MAGNUM_ASSERT_VERSION_SUPPORTED(Version::GL320); MAGNUM_ASSERT_EXTENSION_SUPPORTED(Extensions::GL::ARB::geometry_shader4); } #elif defined(MAGNUM_TARGET_GLES2) if(flags & Flag::Wireframe) MAGNUM_ASSERT_EXTENSION_SUPPORTED(Extensions::GL::OES::standard_derivatives); #endif Utility::Resource rs("MagnumShaders"); #ifndef MAGNUM_TARGET_GLES const Version version = Context::current()->supportedVersion({Version::GL320, Version::GL310, Version::GL300, Version::GL210}); CORRADE_INTERNAL_ASSERT_OUTPUT(flags & Flag::NoGeometryShader || version >= Version::GL320); #else const Version version = Context::current()->supportedVersion({Version::GLES300, Version::GLES200}); #endif Shader vert(version, Shader::Type::Vertex); vert.addSource(flags & Flag::Wireframe ? "#define WIREFRAME_RENDERING\n" : "") .addSource(flags & Flag::NoGeometryShader ? "#define NO_GEOMETRY_SHADER\n" : "") .addSource(rs.get("compatibility.glsl")) .addSource(rs.get("MeshVisualizer.vert")); CORRADE_INTERNAL_ASSERT_OUTPUT(vert.compile()); vert.compile(); attachShader(vert); #ifndef MAGNUM_TARGET_GLES if(flags & Flag::Wireframe && !(flags & Flag::NoGeometryShader)) { Shader geom(version, Shader::Type::Geometry); geom.addSource(rs.get("compatibility.glsl")) .addSource(rs.get("MeshVisualizer.geom")); CORRADE_INTERNAL_ASSERT_OUTPUT(geom.compile()); geom.compile(); attachShader(geom); } #endif Shader frag(version, Shader::Type::Fragment); frag.addSource(flags & Flag::Wireframe ? "#define WIREFRAME_RENDERING\n" : "") .addSource(flags & Flag::NoGeometryShader ? "#define NO_GEOMETRY_SHADER\n" : "") .addSource(rs.get("compatibility.glsl")) .addSource(rs.get("MeshVisualizer.frag")); CORRADE_INTERNAL_ASSERT_OUTPUT(frag.compile()); frag.compile(); attachShader(frag); #ifndef MAGNUM_TARGET_GLES if(!Context::current()->isExtensionSupported<Extensions::GL::ARB::explicit_attrib_location>(version)) #else if(!Context::current()->isVersionSupported(Version::GLES300)) #endif { bindAttributeLocation(Position::Location, "position"); #ifndef MAGNUM_TARGET_GLES if(!Context::current()->isVersionSupported(Version::GL310)) #endif { bindAttributeLocation(VertexIndex::Location, "vertexIndex"); } } CORRADE_INTERNAL_ASSERT_OUTPUT(link()); link(); #ifndef MAGNUM_TARGET_GLES if(!Context::current()->isExtensionSupported<Extensions::GL::ARB::explicit_uniform_location>(version)) #endif { transformationProjectionMatrixUniform = uniformLocation("transformationProjectionMatrix"); colorUniform = uniformLocation("color"); if(flags & Flag::Wireframe) { wireframeColorUniform = uniformLocation("wireframeColor"); wireframeWidthUniform = uniformLocation("wireframeWidth"); smoothnessUniform = uniformLocation("smoothness"); if(!(flags & Flag::NoGeometryShader)) viewportSizeUniform = uniformLocation("viewportSize"); } } /* Set defaults in OpenGL ES (for desktop they are set in shader code itself) */ #ifdef MAGNUM_TARGET_GLES setColor(Color3(1.0f)); if(flags & Flag::Wireframe) { setWireframeColor(Color3(0.0f)); setWireframeWidth(1.0f); setSmoothness(2.0f); } #endif }
/* * Product information screen */ void cr(void) { char *temp; temp = calloc(81, sizeof(char)); if (utf8) chartran_init((char *)"CP437", (char *)"UTF-8", 'B'); strncpy(pstr, clear_str(), 255); strncat(pstr, colour_str(DARKGRAY, BLACK), 255); /* Print top row */ strncat(pstr, (char *)"\xDA", 255); strncat(pstr, hLine_str(76), 255); strncat(pstr, (char *)"\xBF\r\n", 255); PUTSTR(chartran(pstr)); wl(); PUTSTR(chartran(pstr)); ls(); snprintf(temp, 80, "FTND Bulletin Board System %s (%s-%s)", VERSION, OsName(), OsCPU()); strncat(pstr, pout_str(YELLOW, BLACK, padleft(temp, 76, ' ')), 255); rs(); PUTSTR(chartran(pstr)); wl(); PUTSTR(chartran(pstr)); ls(); snprintf(temp, 81, "%s", COPYRIGHT); strncat(pstr, pout_str(LIGHTCYAN, BLACK, padleft(temp, 76, ' ')), 255); rs(); PUTSTR(chartran(pstr)); wl(); PUTSTR(chartran(pstr)); ls(); snprintf(temp, 81, "Compiled on %s at %s", __DATE__, __TIME__); strncat(pstr, pout_str(LIGHTRED, BLACK, padleft(temp, 76, ' ')), 255); rs(); PUTSTR(chartran(pstr)); wl(); PUTSTR(chartran(pstr)); ls(); strncat(pstr, pout_str(LIGHTCYAN, BLACK, (char *)"FTNd and ftnbbs was originally derived from MBSE BBS."), 255); rs(); PUTSTR(chartran(pstr)); ls(); strncat(pstr, pout_str(LIGHTCYAN, BLACK, (char *)"MBSE was written and designed by Michiel Broek. Many others gave "), 255); rs(); PUTSTR(chartran(pstr)); ls(); strncat(pstr, pout_str(LIGHTCYAN, BLACK, (char *)"valuable time in the form of new ideas and suggestions on how to make MBSE "), 255); rs(); PUTSTR(chartran(pstr)); ls(); strncat(pstr, pout_str(LIGHTCYAN, BLACK, (char *)"BBS a better BBS, which has also extended to the FTNd development "), 255); rs(); PUTSTR(chartran(pstr)); wl(); PUTSTR(chartran(pstr)); ls(); strncat(pstr, pout_str(WHITE, BLACK, (char *)"Available from https://ftn.rocasa.net or 1:120/544 "), 255); rs(); PUTSTR(chartran(pstr)); wl(); PUTSTR(chartran(pstr)); ls(); strncat(pstr, pout_str(LIGHTRED, BLACK, (char *)"JAM(mbp) - Copyright 1993 Joaquim Homrighausen, Andrew Milner, "), 255); rs(); PUTSTR(chartran(pstr)); ls(); strncat(pstr, pout_str(LIGHTRED, BLACK, (char *)" Mats Birch, Mats Wallin. "), 255); rs(); PUTSTR(chartran(pstr)); ls(); strncat(pstr, pout_str(LIGHTRED, BLACK, (char *)" ALL RIGHTS RESERVED. "), 255); rs(); PUTSTR(chartran(pstr)); wl(); PUTSTR(chartran(pstr)); ls(); strncat(pstr, pout_str(LIGHTBLUE, BLACK, (char *)"This is free software; released under the terms of the GNU General Public "), 255); rs(); PUTSTR(chartran(pstr)); ls(); strncat(pstr, pout_str(LIGHTBLUE, BLACK, (char *)"License as published by the Free Software Foundation. "), 255); rs(); PUTSTR(chartran(pstr)); wl(); PUTSTR(chartran(pstr)); strcpy(pstr, (char *)"\xC0"); strncat(pstr, hLine_str(76), 255); strncat(pstr, (char *)"\xD9\r\n", 255); PUTSTR(chartran(pstr)); free(temp); chartran_close(); Enter(1); Pause(); }
void Database::Execute(const ValueList& args, KValueRef result) { args.VerifyException("execute", "s"); if (!session) throw ValueException::FromString("Tried to call execute, but database was closed."); std::string sql(args.GetString(0)); GetLogger()->Debug("Execute called with %s", sql.c_str()); Statement select(*this->session); try { ValueBinding binding; select << sql; if (args.size()>1) { for (size_t c=1;c<args.size();c++) { KValueRef anarg = args.at(c); if (anarg->IsList()) { KListRef list = anarg->ToList(); for (size_t a=0;a<list->Size();a++) { KValueRef arg = list->At(a); binding.convert(select,arg); } } else { binding.convert(select,anarg); } } } Poco::UInt32 count = select.execute(); GetLogger()->Debug("sql returned: %d rows for result",count); this->SetInt("rowsAffected",count); // get the row insert id Statement ss(*this->session); ss << "select last_insert_rowid()", now; RecordSet rr(ss); Poco::DynamicAny value = rr.value(0); int i; value.convert(i); this->SetInt("lastInsertRowId",i); if (count > 0) { RecordSet rs(select); KObjectRef r = new ResultSet(rs); result->SetObject(r); } else { KObjectRef r = new ResultSet(); result->SetObject(r); } } catch (Poco::Data::DataException &e) { GetLogger()->Error("Exception executing: %s, Error was: %s", sql.c_str(), e.what()); throw ValueException::FromString(e.what()); } }
STDMETHODIMP CDocProvider::CanAutofix(LONG lError, VARIANT_BOOL *pbAutofix) { CResourceSwapper rs(_Module.m_hInstResource); return CWSErrorInfo::CanAutofix(lError, pbAutofix); }
virtual void on_draw() { typedef agg::renderer_base<pixfmt> renderer_base; typedef agg::renderer_scanline_aa_solid<renderer_base> renderer_solid; pixfmt pixf(rbuf_window()); renderer_base rb(pixf); renderer_solid rs(rb); rb.clear(agg::rgba(1.0, 1.0, 1.0)); agg::rasterizer_scanline_aa<> ras; agg::scanline_p8 sl; double x_start = 125.0; double x_end = initial_width() - 15.0; double y_start = 10.0; double y_end = initial_height() - 10.0; double x_center = (x_start + x_end) / 2; unsigned i; agg::path_storage p; agg::conv_stroke<agg::path_storage> pl(p); agg::conv_transform<agg::conv_stroke<agg::path_storage> > tr(pl, trans_affine_resizing()); for(i = 0; i <= 16; i++) { double x = x_start + (x_end - x_start) * i / 16.0; p.remove_all(); p.move_to(x+0.5, y_start); p.line_to(x+0.5, y_end); ras.add_path(tr); rs.color(agg::rgba8(0, 0, 0, i == 8 ? 255 : 100)); agg::render_scanlines(ras, sl, rs); } double ys = y_start + (y_end - y_start) / 6.0; p.remove_all(); p.move_to(x_start, ys); p.line_to(x_end, ys); ras.add_path(tr); rs.color(agg::rgba8(0, 0, 0)); agg::render_scanlines(ras, sl, rs); pl.width(1.0); for(i = 0; i < m_num_filters; i++) { if(m_filters[i]->status()) { m_filter_func[i]->set_radius(m_radius.value()); unsigned j; double radius = m_filter_func[i]->radius(); unsigned n = unsigned(radius * 256 * 2); double dy = y_end - ys; double xs = (x_end + x_start)/2.0 - (radius * (x_end - x_start) / 16.0); double dx = (x_end - x_start) * radius / 8.0; p.remove_all(); p.move_to(xs+0.5, ys + dy * m_filter_func[i]->calc_weight(-radius)); for(j = 1; j < n; j++) { p.line_to(xs + dx * j / n + 0.5, ys + dy * m_filter_func[i]->calc_weight(j / 256.0 - radius)); } ras.add_path(tr); rs.color(agg::rgba8(100, 0, 0)); agg::render_scanlines(ras, sl, rs); p.remove_all(); unsigned xint; int ir = int(ceil(radius) + 0.1); for(xint = 0; xint < 256; xint++) { int xfract; double sum = 0; for(xfract = -ir; xfract < ir; xfract++) { double xf = xint/256.0 + xfract; if(xf >= -radius || xf <= radius) { sum += m_filter_func[i]->calc_weight(xf); } } double x = x_center + ((-128.0 + xint) / 128.0) * radius * (x_end - x_start) / 16.0; double y = ys + sum * 256 - 256; if(xint == 0) p.move_to(x, y); else p.line_to(x, y); } ras.add_path(tr); rs.color(agg::rgba8(0, 100, 0)); agg::render_scanlines(ras, sl, rs); agg::image_filter_lut normalized(*m_filter_func[i]); const agg::int16* weights = normalized.weight_array(); xs = (x_end + x_start)/2.0 - (normalized.diameter() * (x_end - x_start) / 32.0); unsigned nn = normalized.diameter() * 256; p.remove_all(); p.move_to(xs+0.5, ys + dy * weights[0] / agg::image_filter_scale); for(j = 1; j < nn; j++) { p.line_to(xs + dx * j / n + 0.5, ys + dy * weights[j] / agg::image_filter_scale); } ras.add_path(tr); rs.color(agg::rgba8(0, 0, 100, 255)); agg::render_scanlines(ras, sl, rs); } } for(i = 0; i < m_num_filters; i++) { agg::render_ctrl(ras, sl, rb, *m_filters[i]); } if(m_sinc.status() || m_lanczos.status() || m_blackman.status()) { agg::render_ctrl(ras, sl, rb, m_radius); } }
/* reads `count' bytes from `offset', corrects possible errors with erasure detection, and verifies the integrity of read data using verity hash tree; returns the number of corrections in `errors' */ static ssize_t verity_read(fec_handle *f, uint8_t *dest, size_t count, uint64_t offset, size_t *errors) { check(f); check(dest); check(offset < f->data_size); check(offset + count <= f->data_size); check(f->verity.hash); check(errors); debug("[%" PRIu64 ", %" PRIu64 ")", offset, offset + count); rs_unique_ptr rs(NULL, free_rs_char); std::unique_ptr<uint8_t[]> ecc_data; if (f->ecc.start && ecc_init(f, rs, ecc_data) == -1) { return -1; } uint64_t curr = offset / FEC_BLOCKSIZE; size_t coff = (size_t)(offset - curr * FEC_BLOCKSIZE); size_t left = count; uint8_t data[FEC_BLOCKSIZE]; uint64_t max_hash_block = (f->verity.hash_data_blocks * FEC_BLOCKSIZE - SHA256_DIGEST_LENGTH) / SHA256_DIGEST_LENGTH; while (left > 0) { check(curr <= max_hash_block); uint8_t *hash = &f->verity.hash[curr * SHA256_DIGEST_LENGTH]; uint64_t curr_offset = curr * FEC_BLOCKSIZE; bool expect_zeros = is_zero(f, curr_offset); /* if we are in read-only mode and expect to read a zero block, skip reading and just return zeros */ if (f->mode & O_RDONLY && expect_zeros) { memset(data, 0, FEC_BLOCKSIZE); goto valid; } /* copy raw data without error correction */ if (!raw_pread(f, data, FEC_BLOCKSIZE, curr_offset)) { error("failed to read: %s", strerror(errno)); return -1; } if (likely(verity_check_block(f, hash, data))) { goto valid; } /* we know the block is supposed to contain zeros, so return zeros instead of trying to correct it */ if (expect_zeros) { memset(data, 0, FEC_BLOCKSIZE); goto corrected; } if (!f->ecc.start) { /* fatal error without ecc */ error("[%" PRIu64 ", %" PRIu64 "): corrupted block %" PRIu64, offset, offset + count, curr); return -1; } else { debug("[%" PRIu64 ", %" PRIu64 "): corrupted block %" PRIu64, offset, offset + count, curr); } /* try to correct without erasures first, because checking for erasure locations is slower */ if (__ecc_read(f, rs.get(), data, curr_offset, false, ecc_data.get(), errors) == FEC_BLOCKSIZE && verity_check_block(f, hash, data)) { goto corrected; } /* try to correct with erasures */ if (__ecc_read(f, rs.get(), data, curr_offset, true, ecc_data.get(), errors) == FEC_BLOCKSIZE && verity_check_block(f, hash, data)) { goto corrected; } error("[%" PRIu64 ", %" PRIu64 "): corrupted block %" PRIu64 " (offset %" PRIu64 ") cannot be recovered", offset, offset + count, curr, curr_offset); dump("decoded block", curr, data, FEC_BLOCKSIZE); errno = EIO; return -1; corrected: /* update the corrected block to the file if we are in r/w mode */ if (f->mode & O_RDWR && !raw_pwrite(f, data, FEC_BLOCKSIZE, curr_offset)) { error("failed to write: %s", strerror(errno)); return -1; } valid: size_t copy = FEC_BLOCKSIZE - coff; if (copy > left) { copy = left; } memcpy(dest, &data[coff], copy); dest += copy; left -= copy; coff = 0; ++curr; } return count; }
bool CollisionModel3DImpl::collision(CollisionModel3D* other, int AccuracyDepth, int MaxProcessingTime, float* other_transform) { m_ColType=Models; CollisionModel3DImpl* o=static_cast<CollisionModel3DImpl*>(other); if (!m_Final) throw Inconsistency(); if (!o->m_Final) throw Inconsistency(); Matrix3D t=( other_transform==NULL ? o->m_Transform : *((Matrix3D*)other_transform) ); if (m_Static) t *= m_InvTransform; else t *= m_Transform.Inverse(); RotationState rs(t); if (AccuracyDepth<0) AccuracyDepth=0xFFFFFF; if (MaxProcessingTime==0) MaxProcessingTime=0xFFFFFF; DWORD EndTime,BeginTime = GetTickCount(); int num=Max(m_Triangles.size(),o->m_Triangles.size()); int Allocated=Max(64,(num>>4)); std::vector<Check> checks(Allocated); int queue_idx=1; Check& c=checks[0]; c.m_first=&m_Root; c.depth=0; c.m_second=&o->m_Root; while (queue_idx>0) { if (queue_idx>(Allocated/2)) // enlarge the queue. { Check c; checks.insert(checks.end(),Allocated,c); Allocated*=2; } EndTime=GetTickCount(); if (EndTime >= (BeginTime+MaxProcessingTime)) throw TimeoutExpired(); // @@@ add depth check //Check c=checks.back(); Check& c=checks[--queue_idx]; BoxTreeNode* first=c.m_first; BoxTreeNode* second=c.m_second; assert(first!=NULL); assert(second!=NULL); if (first->intersect(*second,rs)) { int tnum1=first->getTrianglesNumber(); int tnum2=second->getTrianglesNumber(); if (tnum1>0 && tnum2>0) { { for(int i=0;i<tnum2;i++) { BoxedTriangle* bt2=second->getTriangle(i); Triangle tt(Transform(bt2->v1,rs.t),Transform(bt2->v2,rs.t),Transform(bt2->v3,rs.t)); for(int j=0;j<tnum1;j++) { BoxedTriangle* bt1=first->getTriangle(j); if (tt.intersect(*bt1)) { m_ColTri1=*bt1; m_iColTri1=getTriangleIndex(bt1); m_ColTri2=tt; m_iColTri2=o->getTriangleIndex(bt2); return true; } } } } } else if (first->getSonsNumber()==0) { BoxTreeNode* s1=second->getSon(0); BoxTreeNode* s2=second->getSon(1); assert(s1!=NULL); assert(s2!=NULL); Check& c1=checks[queue_idx++]; c1.m_first=first; c1.m_second=s1; Check& c2=checks[queue_idx++]; c2.m_first=first; c2.m_second=s2; } else if (second->getSonsNumber()==0) { BoxTreeNode* f1=first->getSon(0); BoxTreeNode* f2=first->getSon(1); assert(f1!=NULL); assert(f2!=NULL); Check& c1=checks[queue_idx++]; c1.m_first=f1; c1.m_second=second; Check& c2=checks[queue_idx++]; c2.m_first=f2; c2.m_second=second; } else { float v1=first->getVolume(); float v2=second->getVolume(); if (v1>v2) { BoxTreeNode* f1=first->getSon(0); BoxTreeNode* f2=first->getSon(1); assert(f1!=NULL); assert(f2!=NULL); Check& c1=checks[queue_idx++]; c1.m_first=f1; c1.m_second=second; Check& c2=checks[queue_idx++]; c2.m_first=f2; c2.m_second=second; } else { BoxTreeNode* s1=second->getSon(0); BoxTreeNode* s2=second->getSon(1); assert(s1!=NULL); assert(s2!=NULL); Check& c1=checks[queue_idx++]; c1.m_first=first; c1.m_second=s1; Check& c2=checks[queue_idx++]; c2.m_first=first; c2.m_second=s2; } } } } return false; }
int main(int argc, char* argv[]) { // load the mesh Mesh xmesh, ymesh; H2DReader mloader; mloader.load("bracket.mesh", &xmesh); // create initial mesh for the vertical displacement component, // identical to the mesh for the horizontal displacement // (bracket.mesh becomes a master mesh) ymesh.copy(&xmesh); // initialize the shapeset and the cache H1Shapeset shapeset; PrecalcShapeset xpss(&shapeset); PrecalcShapeset ypss(&shapeset); // create the x displacement space H1Space xdisp(&xmesh, &shapeset); xdisp.set_bc_types(bc_types); xdisp.set_bc_values(bc_values); xdisp.set_uniform_order(P_INIT); // create the y displacement space H1Space ydisp(MULTI ? &ymesh : &xmesh, &shapeset); ydisp.set_bc_types(bc_types); ydisp.set_bc_values(bc_values); ydisp.set_uniform_order(P_INIT); // enumerate basis functions int ndofs = xdisp.assign_dofs(); ndofs += ydisp.assign_dofs(ndofs); // initialize the weak formulation WeakForm wf(2); wf.add_biform(0, 0, callback(bilinear_form_0_0), SYM); // note that only one symmetric part is wf.add_biform(0, 1, callback(bilinear_form_0_1), SYM); // added in the case of symmetric bilinear wf.add_biform(1, 1, callback(bilinear_form_1_1), SYM); // forms wf.add_liform_surf(1, callback(linear_form_surf_1), marker_top); // visualization of solution and meshes OrderView xoview("X polynomial orders", 0, 0, 500, 500); OrderView yoview("Y polynomial orders", 510, 0, 500, 500); ScalarView sview("Von Mises stress [Pa]", 1020, 0, 500, 500); // matrix solver UmfpackSolver umfpack; // DOF and CPU convergence graphs SimpleGraph graph_dof, graph_cpu; // adaptivity loop int it = 1; bool done = false; double cpu = 0.0; Solution x_sln_coarse, y_sln_coarse; Solution x_sln_fine, y_sln_fine; do { info("\n---- Adaptivity step %d ---------------------------------------------\n", it++); // time measurement begin_time(); //calculating the number of degrees of freedom ndofs = xdisp.assign_dofs(); ndofs += ydisp.assign_dofs(ndofs); printf("xdof=%d, ydof=%d\n", xdisp.get_num_dofs(), ydisp.get_num_dofs()); // solve the coarse mesh problem LinSystem ls(&wf, &umfpack); ls.set_spaces(2, &xdisp, &ydisp); ls.set_pss(2, &xpss, &ypss); ls.assemble(); ls.solve(2, &x_sln_coarse, &y_sln_coarse); // time measurement cpu += end_time(); // view the solution -- this can be slow; for illustration only VonMisesFilter stress_coarse(&x_sln_coarse, &y_sln_coarse, mu, lambda); sview.set_min_max_range(0, 3e4); sview.show(&stress_coarse); xoview.show(&xdisp); yoview.show(&ydisp); // time measurement begin_time(); // solve the fine mesh problem RefSystem rs(&ls); rs.assemble(); rs.solve(2, &x_sln_fine, &y_sln_fine); // calculate element errors and total error estimate H1OrthoHP hp(2, &xdisp, &ydisp); hp.set_biform(0, 0, bilinear_form_0_0<scalar, scalar>, bilinear_form_0_0<Ord, Ord>); hp.set_biform(0, 1, bilinear_form_0_1<scalar, scalar>, bilinear_form_0_1<Ord, Ord>); hp.set_biform(1, 0, bilinear_form_1_0<scalar, scalar>, bilinear_form_1_0<Ord, Ord>); hp.set_biform(1, 1, bilinear_form_1_1<scalar, scalar>, bilinear_form_1_1<Ord, Ord>); double err_est = hp.calc_error_2(&x_sln_coarse, &y_sln_coarse, &x_sln_fine, &y_sln_fine) * 100; info("Estimate of error: %g%%", err_est); // time measurement cpu += end_time(); // add entry to DOF convergence graph graph_dof.add_values(xdisp.get_num_dofs() + ydisp.get_num_dofs(), err_est); graph_dof.save("conv_dof.dat"); // add entry to CPU convergence graph graph_cpu.add_values(cpu, err_est); graph_cpu.save("conv_cpu.dat"); // if err_est too large, adapt the mesh if (err_est < ERR_STOP) done = true; else { hp.adapt(THRESHOLD, STRATEGY, ADAPT_TYPE, ISO_ONLY, MESH_REGULARITY, CONV_EXP, MAX_ORDER, SAME_ORDERS); ndofs = xdisp.assign_dofs(); ndofs += ydisp.assign_dofs(ndofs); if (ndofs >= NDOF_STOP) done = true; } } while (!done); verbose("Total running time: %g sec", cpu); // show the fine solution - this is the final result VonMisesFilter stress_fine(&x_sln_fine, &y_sln_fine, mu, lambda); sview.set_title("Final solution"); sview.set_min_max_range(0, 3e4); sview.show(&stress_fine); // wait for all views to be closed View::wait(); return 0; }
/*void CEMQtyAtExam::OnDoctorAddNew(){ CHMSMainFrame *pMF = (CHMSMainFrame*) AfxGetMainWnd(); } */ void CEMQtyAtExam::OnPrintSelect() { CHMSMainFrame *pMF = (CHMSMainFrame*) AfxGetMainWnd(); UpdateData(true); CReport rpt; CString szSQL, szTemp, tmpStr; CRecord rs(&pMF->m_db); szSQL = GetQueryString(); BeginWaitCursor(); rs.ExecSQL(szSQL); _fmsg(_T("%s"), szSQL); if (rs.IsEOF()) { ShowMessage(150, MB_ICONSTOP); return; } if(!rpt.Init(_T("Reports/HMS/HE_SOLUONGKHAMTAICACPHONG.RPT")) ) return ; rpt.GetReportHeader()->SetValue(_T("HeathService"), pMF->m_CompanyInfo.sc_pname); rpt.GetReportHeader()->SetValue(_T("HospitalName"), pMF->m_CompanyInfo.sc_name); tmpStr.Format(rpt.GetReportHeader()->GetValue(_T("ReportDate")), CDateTime::Convert(m_szFromDate, yyyymmdd|hhmmss, ddmmyyyy|hhmmss), CDateTime::Convert(m_szToDate, yyyymmdd|hhmmss, ddmmyyyy|hhmmss)); rpt.GetReportHeader()->SetValue(_T("ReportDate"), tmpStr); int nIndex = 1; CReportSection* rptDetail; int nTotal1 = 0, nTotal2 = 0, nTotal3 = 0; while(!rs.IsEOF()) { rptDetail = rpt.AddDetail(); tmpStr.Format(_T("%d"), nIndex++); rptDetail->SetValue(_T("1"), tmpStr); szTemp = rs.GetValue(_T("doctorname")); rptDetail->SetValue(_T("2"), szTemp); szTemp = rs.GetValue(_T("bhquan")); nTotal1 += ToInt(szTemp); rptDetail->SetValue(_T("3"), szTemp); szTemp = rs.GetValue(_T("bhhuu")); nTotal2 += ToInt(szTemp); rptDetail->SetValue(_T("4"), szTemp); szTemp = rs.GetValue(_T("tongso")); nTotal3 += ToInt(szTemp); rptDetail->SetValue(_T("5"), szTemp); rs.MoveNext(); } rpt.GetReportFooter()->SetValue(_T("s3"), nTotal1); rpt.GetReportFooter()->SetValue(_T("s4"), nTotal2); rpt.GetReportFooter()->SetValue(_T("s5"), nTotal3); CString szDate; tmpStr = pMF->GetSysDate(); szDate.Format(rpt.GetReportFooter()->GetValue(_T("PrintDate")), tmpStr.Mid(8, 2), tmpStr.Mid(5, 2), tmpStr.Left(4)); rpt.GetReportFooter()->SetValue(_T("PrintDate"), szDate); rpt.PrintPreview(); EndWaitCursor(); }
// Insert a record and try to perform an in-place update on it. TEST( RecordStoreTestHarness, UpdateWithDamages ) { scoped_ptr<HarnessHelper> harnessHelper( newHarnessHelper() ); scoped_ptr<RecordStore> rs( harnessHelper->newNonCappedRecordStore() ); if (!rs->updateWithDamagesSupported()) return; { scoped_ptr<OperationContext> opCtx( harnessHelper->newOperationContext() ); ASSERT_EQUALS( 0, rs->numRecords( opCtx.get() ) ); } string data = "00010111"; RecordId loc; const RecordData rec(data.c_str(), data.size() + 1); { scoped_ptr<OperationContext> opCtx( harnessHelper->newOperationContext() ); { WriteUnitOfWork uow( opCtx.get() ); StatusWith<RecordId> res = rs->insertRecord( opCtx.get(), rec.data(), rec.size(), false ); ASSERT_OK( res.getStatus() ); loc = res.getValue(); uow.commit(); } } { scoped_ptr<OperationContext> opCtx( harnessHelper->newOperationContext() ); ASSERT_EQUALS( 1, rs->numRecords( opCtx.get() ) ); } { scoped_ptr<OperationContext> opCtx( harnessHelper->newOperationContext() ); { mutablebson::DamageVector dv( 3 ); dv[0].sourceOffset = 5; dv[0].targetOffset = 0; dv[0].size = 2; dv[1].sourceOffset = 3; dv[1].targetOffset = 2; dv[1].size = 3; dv[2].sourceOffset = 0; dv[2].targetOffset = 5; dv[2].size = 3; WriteUnitOfWork uow( opCtx.get() ); ASSERT_OK( rs->updateWithDamages( opCtx.get(), loc, rec, data.c_str(), dv ) ); uow.commit(); } } data = "11101000"; { scoped_ptr<OperationContext> opCtx( harnessHelper->newOperationContext() ); { RecordData record = rs->dataFor( opCtx.get(), loc ); ASSERT_EQUALS( data, record.data() ); } } }
void pose_estimation_from_line_correspondence(Eigen::MatrixXf start_points, Eigen::MatrixXf end_points, Eigen::MatrixXf directions, Eigen::MatrixXf points, Eigen::MatrixXf &rot_cw, Eigen::VectorXf &pos_cw) { int n = start_points.cols(); if(n != directions.cols()) { return; } if(n<4) { return; } float condition_err_threshold = 1e-3; Eigen::VectorXf cosAngleThreshold(3); cosAngleThreshold << 1.1, 0.9659, 0.8660; Eigen::MatrixXf optimumrot_cw(3,3); Eigen::VectorXf optimumpos_cw(3); std::vector<float> lineLenVec(n,1); vfloat3 l1; vfloat3 l2; vfloat3 nc1; vfloat3 Vw1; vfloat3 Xm; vfloat3 Ym; vfloat3 Zm; Eigen::MatrixXf Rot(3,3); std::vector<vfloat3> nc_bar(n,vfloat3(0,0,0)); std::vector<vfloat3> Vw_bar(n,vfloat3(0,0,0)); std::vector<vfloat3> n_c(n,vfloat3(0,0,0)); Eigen::MatrixXf Rx(3,3); int line_id; for(int HowToChooseFixedTwoLines = 1 ; HowToChooseFixedTwoLines <=3 ; HowToChooseFixedTwoLines++) { if(HowToChooseFixedTwoLines==1) { #pragma omp parallel for for(int i = 0; i < n ; i++ ) { // to correct float lineLen = 10; lineLenVec[i] = lineLen; } std::vector<float>::iterator result; result = std::max_element(lineLenVec.begin(), lineLenVec.end()); line_id = std::distance(lineLenVec.begin(), result); vfloat3 temp; temp = start_points.col(0); start_points.col(0) = start_points.col(line_id); start_points.col(line_id) = temp; temp = end_points.col(0); end_points.col(0) = end_points.col(line_id); end_points.col(line_id) = temp; temp = directions.col(line_id); directions.col(0) = directions.col(line_id); directions.col(line_id) = temp; temp = points.col(0); points.col(0) = points.col(line_id); points.col(line_id) = temp; lineLenVec[line_id] = lineLenVec[1]; lineLenVec[1] = 0; l1 = start_points.col(0) - end_points.col(0); l1 = l1/l1.norm(); } for(int i = 1; i < n; i++) { std::vector<float>::iterator result; result = std::max_element(lineLenVec.begin(), lineLenVec.end()); line_id = std::distance(lineLenVec.begin(), result); l2 = start_points.col(line_id) - end_points.col(line_id); l2 = l2/l2.norm(); lineLenVec[line_id] = 0; MatrixXf cosAngle(3,3); cosAngle = (l1.transpose()*l2).cwiseAbs(); if(cosAngle.maxCoeff() < cosAngleThreshold[HowToChooseFixedTwoLines]) { break; } } vfloat3 temp; temp = start_points.col(1); start_points.col(1) = start_points.col(line_id); start_points.col(line_id) = temp; temp = end_points.col(1); end_points.col(1) = end_points.col(line_id); end_points.col(line_id) = temp; temp = directions.col(1); directions.col(1) = directions.col(line_id); directions.col(line_id) = temp; temp = points.col(1); points.col(1) = points.col(line_id); points.col(line_id) = temp; lineLenVec[line_id] = lineLenVec[1]; lineLenVec[1] = 0; // The rotation matrix R_wc is decomposed in way which is slightly different from the description in the paper, // but the framework is the same. // R_wc = (Rot') * R * Rot = (Rot') * (Ry(theta) * Rz(phi) * Rx(psi)) * Rot nc1 = x_cross(start_points.col(1),end_points.col(1)); nc1 = nc1/nc1.norm(); Vw1 = directions.col(1); Vw1 = Vw1/Vw1.norm(); //the X axis of Model frame Xm = x_cross(nc1,Vw1); Xm = Xm/Xm.norm(); //the Y axis of Model frame Ym = nc1; //the Z axis of Model frame Zm = x_cross(Xm,Zm); Zm = Zm/Zm.norm(); //Rot * [Xm, Ym, Zm] = I. Rot.col(0) = Xm; Rot.col(1) = Ym; Rot.col(2) = Zm; Rot = Rot.transpose(); //rotate all the vector by Rot. //nc_bar(:,i) = Rot * nc(:,i) //Vw_bar(:,i) = Rot * Vw(:,i) #pragma omp parallel for for(int i = 0 ; i < n ; i++) { vfloat3 nc = x_cross(start_points.col(1),end_points.col(1)); nc = nc/nc.norm(); n_c[i] = nc; nc_bar[i] = Rot * nc; Vw_bar[i] = Rot * directions.col(i); } //Determine the angle psi, it is the angle between z axis and Vw_bar(:,1). //The rotation matrix Rx(psi) rotates Vw_bar(:,1) to z axis float cospsi = (Vw_bar[1])[2];//the angle between z axis and Vw_bar(:,1); cospsi=[0,0,1] * Vw_bar(:,1);. float sinpsi= sqrt(1 - cospsi*cospsi); Rx.row(0) = vfloat3(1,0,0); Rx.row(1) = vfloat3(0,cospsi,-sinpsi); Rx.row(2) = vfloat3(0,sinpsi,cospsi); vfloat3 Zaxis = Rx * Vw_bar[1]; if(1-fabs(Zaxis[3]) > 1e-5) { Rx = Rx.transpose(); } //estimate the rotation angle phi by least square residual. //i.e the rotation matrix Rz(phi) vfloat3 Vm2 = Rx * Vw_bar[1]; float A2 = Vm2[0]; float B2 = Vm2[1]; float C2 = Vm2[2]; float x2 = (nc_bar[1])[0]; float y2 = (nc_bar[1])[1]; float z2 = (nc_bar[1])[2]; Eigen::PolynomialSolver<double, Eigen::Dynamic> solver; Eigen::VectorXf coeff(9); std::vector<float> coef(9,0); //coefficients of equation (7) Eigen::VectorXf polyDF = VectorXf::Zero(16); //%dF = ployDF(1) * t^15 + ployDF(2) * t^14 + ... + ployDF(15) * t + ployDF(16); //construct the polynomial F' #pragma omp parallel for for(int i = 3 ; i < n ; i++) { vfloat3 Vm3 = Rx*Vw_bar[i]; float A3 = Vm3[0]; float B3 = Vm3[1]; float C3 = Vm3[2]; float x3 = (nc_bar[i])[0]; float y3 = (nc_bar[i])[1]; float z3 = (nc_bar[i])[2]; float u11 = -z2*A2*y3*B3 + y2*B2*z3*A3; float u12 = -y2*A2*z3*B3 + z2*B2*y3*A3; float u13 = -y2*B2*z3*B3 + z2*B2*y3*B3 + y2*A2*z3*A3 - z2*A2*y3*A3; float u14 = -y2*B2*x3*C3 + x2*C2*y3*B3; float u15 = x2*C2*y3*A3 - y2*A2*x3*C3; float u21 = -x2*A2*y3*B3 + y2*B2*x3*A3; float u22 = -y2*A2*x3*B3 + x2*B2*y3*A3; float u23 = x2*B2*y3*B3 - y2*B2*x3*B3 - x2*A2*y3*A3 + y2*A2*x3*A3; float u24 = y2*B2*z3*C3 - z2*C2*y3*B3; float u25 = y2*A2*z3*C3 - z2*C2*y3*A3; float u31 = -x2*A2*z3*A3 + z2*A2*x3*A3; float u32 = -x2*B2*z3*B3 + z2*B2*x3*B3; float u33 = x2*A2*z3*B3 - z2*A2*x3*B3 + x2*B2*z3*A3 - z2*B2*x3*A3; float u34 = z2*A2*z3*C3 + x2*A2*x3*C3 - z2*C2*z3*A3 - x2*C2*x3*A3; float u35 = -z2*B2*z3*C3 - x2*B2*x3*C3 + z2*C2*z3*B3 + x2*C2*x3*B3; float u36 = -x2*C2*z3*C3 + z2*C2*x3*C3; float a4 = u11*u11 + u12*u12 - u13*u13 - 2*u11*u12 + u21*u21 + u22*u22 - u23*u23 -2*u21*u22 - u31*u31 - u32*u32 + u33*u33 + 2*u31*u32; float a3 =2*(u11*u14 - u13*u15 - u12*u14 + u21*u24 - u23*u25 - u22*u24 - u31*u34 + u33*u35 + u32*u34); float a2 =-2*u12*u12 + u13*u13 + u14*u14 - u15*u15 + 2*u11*u12 - 2*u22*u22 + u23*u23 + u24*u24 - u25*u25 +2*u21*u22+ 2*u32*u32 - u33*u33 - u34*u34 + u35*u35 -2*u31*u32- 2*u31*u36 + 2*u32*u36; float a1 =2*(u12*u14 + u13*u15 + u22*u24 + u23*u25 - u32*u34 - u33*u35 - u34*u36); float a0 = u12*u12 + u15*u15+ u22*u22 + u25*u25 - u32*u32 - u35*u35 - u36*u36 - 2*u32*u36; float b3 =2*(u11*u13 - u12*u13 + u21*u23 - u22*u23 - u31*u33 + u32*u33); float b2 =2*(u11*u15 - u12*u15 + u13*u14 + u21*u25 - u22*u25 + u23*u24 - u31*u35 + u32*u35 - u33*u34); float b1 =2*(u12*u13 + u14*u15 + u22*u23 + u24*u25 - u32*u33 - u34*u35 - u33*u36); float b0 =2*(u12*u15 + u22*u25 - u32*u35 - u35*u36); float d0 = a0*a0 - b0*b0; float d1 = 2*(a0*a1 - b0*b1); float d2 = a1*a1 + 2*a0*a2 + b0*b0 - b1*b1 - 2*b0*b2; float d3 = 2*(a0*a3 + a1*a2 + b0*b1 - b1*b2 - b0*b3); float d4 = a2*a2 + 2*a0*a4 + 2*a1*a3 + b1*b1 + 2*b0*b2 - b2*b2 - 2*b1*b3; float d5 = 2*(a1*a4 + a2*a3 + b1*b2 + b0*b3 - b2*b3); float d6 = a3*a3 + 2*a2*a4 + b2*b2 - b3*b3 + 2*b1*b3; float d7 = 2*(a3*a4 + b2*b3); float d8 = a4*a4 + b3*b3; std::vector<float> v { a4, a3, a2, a1, a0, b3, b2, b1, b0 }; Eigen::VectorXf vp; vp << a4, a3, a2, a1, a0, b3, b2, b1, b0 ; //coef = coef + v; coeff = coeff + vp; polyDF[0] = polyDF[0] + 8*d8*d8; polyDF[1] = polyDF[1] + 15* d7*d8; polyDF[2] = polyDF[2] + 14* d6*d8 + 7*d7*d7; polyDF[3] = polyDF[3] + 13*(d5*d8 + d6*d7); polyDF[4] = polyDF[4] + 12*(d4*d8 + d5*d7) + 6*d6*d6; polyDF[5] = polyDF[5] + 11*(d3*d8 + d4*d7 + d5*d6); polyDF[6] = polyDF[6] + 10*(d2*d8 + d3*d7 + d4*d6) + 5*d5*d5; polyDF[7] = polyDF[7] + 9 *(d1*d8 + d2*d7 + d3*d6 + d4*d5); polyDF[8] = polyDF[8] + 8 *(d1*d7 + d2*d6 + d3*d5) + 4*d4*d4 + 8*d0*d8; polyDF[9] = polyDF[9] + 7 *(d1*d6 + d2*d5 + d3*d4) + 7*d0*d7; polyDF[10] = polyDF[10] + 6 *(d1*d5 + d2*d4) + 3*d3*d3 + 6*d0*d6; polyDF[11] = polyDF[11] + 5 *(d1*d4 + d2*d3)+ 5*d0*d5; polyDF[12] = polyDF[12] + 4 * d1*d3 + 2*d2*d2 + 4*d0*d4; polyDF[13] = polyDF[13] + 3 * d1*d2 + 3*d0*d3; polyDF[14] = polyDF[14] + d1*d1 + 2*d0*d2; polyDF[15] = polyDF[15] + d0*d1; } Eigen::VectorXd coefficientPoly = VectorXd::Zero(16); for(int j =0; j < 16 ; j++) { coefficientPoly[j] = polyDF[15-j]; } //solve polyDF solver.compute(coefficientPoly); const Eigen::PolynomialSolver<double, Eigen::Dynamic>::RootsType & r = solver.roots(); Eigen::VectorXd rs(r.rows()); Eigen::VectorXd is(r.rows()); std::vector<float> min_roots; for(int j =0;j<r.rows();j++) { rs[j] = fabs(r[j].real()); is[j] = fabs(r[j].imag()); } float maxreal = rs.maxCoeff(); for(int j = 0 ; j < rs.rows() ; j++ ) { if(is[j]/maxreal <= 0.001) { min_roots.push_back(rs[j]); } } std::vector<float> temp_v(15); std::vector<float> poly(15); for(int j = 0 ; j < 15 ; j++) { temp_v[j] = j+1; } for(int j = 0 ; j < 15 ; j++) { poly[j] = polyDF[j]*temp_v[j]; } Eigen::Matrix<double,16,1> polynomial; Eigen::VectorXd evaluation(min_roots.size()); for( int j = 0; j < min_roots.size(); j++ ) { evaluation[j] = poly_eval( polynomial, min_roots[j] ); } std::vector<float> minRoots; for( int j = 0; j < min_roots.size(); j++ ) { if(!evaluation[j]<=0) { minRoots.push_back(min_roots[j]); } } if(minRoots.size()==0) { cout << "No solution" << endl; return; } int numOfRoots = minRoots.size(); //for each minimum, we try to find a solution of the camera pose, then //choose the one with the least reprojection residual as the optimum of the solution. float minimalReprojectionError = 100; // In general, there are two solutions which yields small re-projection error // or condition error:"n_c * R_wc * V_w=0". One of the solution transforms the // world scene behind the camera center, the other solution transforms the world // scene in front of camera center. While only the latter one is correct. // This can easily be checked by verifying their Z coordinates in the camera frame. // P_c(Z) must be larger than 0 if it's in front of the camera. for(int rootId = 0 ; rootId < numOfRoots ; rootId++) { float cosphi = minRoots[rootId]; float sign1 = sign_of_number(coeff[0] * pow(cosphi,4) + coeff[1] * pow(cosphi,3) + coeff[2] * pow(cosphi,2) + coeff[3] * cosphi + coeff[4]); float sign2 = sign_of_number(coeff[5] * pow(cosphi,3) + coeff[6] * pow(cosphi,2) + coeff[7] * cosphi + coeff[8]); float sinphi= -sign1*sign2*sqrt(abs(1-cosphi*cosphi)); Eigen::MatrixXf Rz(3,3); Rz.row(0) = vfloat3(cosphi,-sinphi,0); Rz.row(1) = vfloat3(sinphi,cosphi,0); Rz.row(2) = vfloat3(0,0,1); //now, according to Sec4.3, we estimate the rotation angle theta //and the translation vector at a time. Eigen::MatrixXf RzRxRot(3,3); RzRxRot = Rz*Rx*Rot; //According to the fact that n_i^C should be orthogonal to Pi^c and Vi^c, we //have: scalarproduct(Vi^c, ni^c) = 0 and scalarproduct(Pi^c, ni^c) = 0. //where Vi^c = Rwc * Vi^w, Pi^c = Rwc *(Pi^w - pos_cw) = Rwc * Pi^w - pos; //Using the above two constraints to construct linear equation system Mat about //[costheta, sintheta, tx, ty, tz, 1]. Eigen::MatrixXf Matrice(2*n-1,6); #pragma omp parallel for for(int i = 0 ; i < n ; i++) { float nxi = (nc_bar[i])[0]; float nyi = (nc_bar[i])[1]; float nzi = (nc_bar[i])[2]; Eigen::VectorXf Vm(3); Vm = RzRxRot * directions.col(i); float Vxi = Vm[0]; float Vyi = Vm[1]; float Vzi = Vm[2]; Eigen::VectorXf Pm(3); Pm = RzRxRot * points.col(i); float Pxi = Pm(1); float Pyi = Pm(2); float Pzi = Pm(3); //apply the constraint scalarproduct(Vi^c, ni^c) = 0 //if i=1, then scalarproduct(Vi^c, ni^c) always be 0 if(i>1) { Matrice(2*i-3, 0) = nxi * Vxi + nzi * Vzi; Matrice(2*i-3, 1) = nxi * Vzi - nzi * Vxi; Matrice(2*i-3, 5) = nyi * Vyi; } //apply the constraint scalarproduct(Pi^c, ni^c) = 0 Matrice(2*i-2, 0) = nxi * Pxi + nzi * Pzi; Matrice(2*i-2, 1) = nxi * Pzi - nzi * Pxi; Matrice(2*i-2, 2) = -nxi; Matrice(2*i-2, 3) = -nyi; Matrice(2*i-2, 4) = -nzi; Matrice(2*i-2, 5) = nyi * Pyi; } //solve the linear system Mat * [costheta, sintheta, tx, ty, tz, 1]' = 0 using SVD, JacobiSVD<MatrixXf> svd(Matrice, ComputeThinU | ComputeThinV); Eigen::MatrixXf VMat = svd.matrixV(); Eigen::VectorXf vec(2*n-1); //the last column of Vmat; vec = VMat.col(5); //the condition that the last element of vec should be 1. vec = vec/vec[5]; //the condition costheta^2+sintheta^2 = 1; float normalizeTheta = 1/sqrt(vec[0]*vec[1]+vec[1]*vec[1]); float costheta = vec[0]*normalizeTheta; float sintheta = vec[1]*normalizeTheta; Eigen::MatrixXf Ry(3,3); Ry << costheta, 0, sintheta , 0, 1, 0 , -sintheta, 0, costheta; //now, we get the rotation matrix rot_wc and translation pos_wc Eigen::MatrixXf rot_wc(3,3); rot_wc = (Rot.transpose()) * (Ry * Rz * Rx) * Rot; Eigen::VectorXf pos_wc(3); pos_wc = - Rot.transpose() * vec.segment(2,4); //now normalize the camera pose by 3D alignment. We first translate the points //on line in the world frame Pw to points in the camera frame Pc. Then we project //Pc onto the line interpretation plane as Pc_new. So we could call the point //alignment algorithm to normalize the camera by aligning Pc_new and Pw. //In order to improve the accuracy of the aligment step, we choose two points for each //lines. The first point is Pwi, the second point is the closest point on line i to camera center. //(Pw2i = Pwi - (Pwi'*Vwi)*Vwi.) Eigen::MatrixXf Pw2(3,n); Pw2.setZero(); Eigen::MatrixXf Pc_new(3,n); Pc_new.setZero(); Eigen::MatrixXf Pc2_new(3,n); Pc2_new.setZero(); for(int i = 0 ; i < n ; i++) { vfloat3 nci = n_c[i]; vfloat3 Pwi = points.col(i); vfloat3 Vwi = directions.col(i); //first point on line i vfloat3 Pci; Pci = rot_wc * Pwi + pos_wc; Pc_new.col(i) = Pci - (Pci.transpose() * nci) * nci; //second point is the closest point on line i to camera center. vfloat3 Pw2i; Pw2i = Pwi - (Pwi.transpose() * Vwi) * Vwi; Pw2.col(i) = Pw2i; vfloat3 Pc2i; Pc2i = rot_wc * Pw2i + pos_wc; Pc2_new.col(i) = Pc2i - ( Pc2i.transpose() * nci ) * nci; } MatrixXf XXc(Pc_new.rows(), Pc_new.cols()+Pc2_new.cols()); XXc << Pc_new, Pc2_new; MatrixXf XXw(points.rows(), points.cols()+Pw2.cols()); XXw << points, Pw2; int nm = points.cols()+Pw2.cols(); cal_campose(XXc,XXw,nm,rot_wc,pos_wc); pos_cw = -rot_wc.transpose() * pos_wc; //check the condition n_c^T * rot_wc * V_w = 0; float conditionErr = 0; for(int i =0 ; i < n ; i++) { float val = ( (n_c[i]).transpose() * rot_wc * directions.col(i) ); conditionErr = conditionErr + val*val; } if(conditionErr/n < condition_err_threshold || HowToChooseFixedTwoLines ==3) { //check whether the world scene is in front of the camera. int numLineInFrontofCamera = 0; if(HowToChooseFixedTwoLines<3) { for(int i = 0 ; i < n ; i++) { vfloat3 P_c = rot_wc * (points.col(i) - pos_cw); if(P_c[2]>0) { numLineInFrontofCamera++; } } } else { numLineInFrontofCamera = n; } if(numLineInFrontofCamera > 0.5*n) { //most of the lines are in front of camera, then check the reprojection error. int reprojectionError = 0; for(int i =0; i < n ; i++) { //line projection function vfloat3 nc = rot_wc * x_cross(points.col(i) - pos_cw , directions.col(i)); float h1 = nc.transpose() * start_points.col(i); float h2 = nc.transpose() * end_points.col(i); float lineLen = (start_points.col(i) - end_points.col(i)).norm()/3; reprojectionError += lineLen * (h1*h1 + h1*h2 + h2*h2) / (nc[0]*nc[0]+nc[1]*nc[1]); } if(reprojectionError < minimalReprojectionError) { optimumrot_cw = rot_wc.transpose(); optimumpos_cw = pos_cw; minimalReprojectionError = reprojectionError; } } } } if(optimumrot_cw.rows()>0) { break; } } pos_cw = optimumpos_cw; rot_cw = optimumrot_cw; }
//----------------------------------------------------------------------------------// bool CTradesCache::ProcessTradeForAnalytics(CTradePtr spTrade){ if (spTrade.get()){ long lStep = 0; IRisks retRisks; try{ retRisks = spTrade->m_spContract->Calculate(NULL, NULL); } catch (_com_error& err){ std::ostringstream out_stream; out_stream << "Analytical data for trade ["; out_stream << spTrade->m_nTradeID; out_stream<< "] has not been ready at this moment. It will be respocessed one more time by queue."; TRACE_COM_ERROR(LOG4CPLUS_WARN, VS::Log, err, std::string(out_stream.str())); return false; } try{ //format xml to pass to DB lStep = 1; _bstr_t bstrXML; bstrXML.Attach(GetXMLString(&retRisks, spTrade)); lStep = 2; //save to DB InitializeDB(); CStoredProc<CClientRecordset> rs(GetDBConnection(), L"usp_ContractAnalytics_Save"); rs << bstrXML; lStep = 3; rs.Open(); lStep = 4; rs.Close(); return true; } catch (_com_error& err){ std::ostringstream out_stream; out_stream<<"Exception occured while ProcessTradeForAnalytics().\n\tStep = " << lStep; out_stream<<"\n\tTradeID = " << spTrade->m_nTradeID; TRACE_COM_ERROR(LOG4CPLUS_ERROR, VS::Log, err, std::string(out_stream.str())); return false; } catch (...){ std::ostringstream out_stream; out_stream<<"Unknown C++ exception occured while ProcessTradeForAnalytics().\n\tStep = " << lStep; out_stream<<"\n\tTradeID = " << spTrade->m_nTradeID; TRACE_UNKNOWN_ERROR(LOG4CPLUS_ERROR, VS::Log, std::string(out_stream.str())); return false; } } return false; };
virtual void on_draw() { typedef agg::pixfmt_bgr24 pixfmt; typedef agg::renderer_base<pixfmt> renderer_base; typedef agg::renderer_scanline_aa_solid<renderer_base> renderer_solid; pixfmt pixf(rbuf_window()); renderer_base rb(pixf); renderer_solid rs(rb); rb.clear(agg::rgba(1.0, 1.0, 1.0)); agg::trans_affine src_mtx; src_mtx *= agg::trans_affine_translation(-initial_width()/2, -initial_height()/2); src_mtx *= agg::trans_affine_rotation(10.0 * agg::pi / 180.0); src_mtx *= agg::trans_affine_translation(initial_width()/2, initial_height()/2); src_mtx *= trans_affine_resizing(); agg::trans_affine img_mtx = src_mtx; img_mtx.invert(); typedef agg::span_allocator<agg::rgba8> span_alloc; unsigned i; unsigned char brightness_alpha_array[agg::span_conv_brightness_alpha_rgb8::array_size]; for(i = 0; i < agg::span_conv_brightness_alpha_rgb8::array_size; i++) { brightness_alpha_array[i] = agg::int8u(m_alpha.value(double(i) / double(agg::span_conv_brightness_alpha_rgb8::array_size)) * 255.0); } agg::span_conv_brightness_alpha_rgb8 color_alpha(brightness_alpha_array); typedef agg::span_interpolator_linear<> interpolator_type; typedef agg::span_image_filter_rgb_bilinear<agg::rgba8, agg::order_bgr, interpolator_type> span_gen; typedef agg::span_converter<span_gen, agg::span_conv_brightness_alpha_rgb8> span_conv; typedef agg::renderer_scanline_aa<renderer_base, span_conv> renderer; span_alloc sa; interpolator_type interpolator(img_mtx); span_gen sg(sa, rbuf_img(0), agg::rgba(1,1,1,0), interpolator); span_conv sc(sg, color_alpha); renderer ri(rb, sc); agg::ellipse ell; agg::rasterizer_scanline_aa<> ras; agg::scanline_u8 sl; for(i = 0; i < 50; i++) { ell.init(m_x[i], m_y[i], m_rx[i], m_ry[i], 50); rs.color(m_colors[i]); ras.add_path(ell); agg::render_scanlines(ras, sl, rs); } ell.init(initial_width() / 2.0, initial_height() / 2.0, initial_width() / 1.9, initial_height() / 1.9, 200); agg::conv_transform<agg::ellipse> tr(ell, src_mtx); ras.add_path(tr); agg::render_scanlines(ras, sl, ri); agg::render_ctrl(ras, sl, rs, m_alpha); }
int main(int argc, char* argv[]) { // load the mesh Mesh mesh; H2DReader mloader; mloader.load("square_quad.mesh", &mesh); // mloader.load("square_tri.mesh", &mesh); for (int i=0; i<INIT_REF_NUM; i++) mesh.refine_all_elements(); // initialize the shapeset and the cache H1Shapeset shapeset; PrecalcShapeset pss(&shapeset); // create finite element space H1Space space(&mesh, &shapeset); space.set_bc_types(bc_types); space.set_bc_values(bc_values); space.set_uniform_order(P_INIT); // enumerate basis functions space.assign_dofs(); // initialize the weak formulation WeakForm wf(1); wf.add_biform(0, 0, callback(bilinear_form), SYM); wf.add_liform(0, callback(linear_form)); // matrix solver UmfpackSolver solver; // prepare selector RefinementSelectors::H1NonUniformHP selector(ISO_ONLY, ADAPT_TYPE, CONV_EXP, H2DRS_DEFAULT_ORDER, &shapeset); // convergence graph wrt. the number of degrees of freedom GnuplotGraph graph; graph.set_log_y(); graph.set_captions("Error Convergence for the Inner Layer Problem", "Degrees of Freedom", "Error [%]"); graph.add_row("exact error", "k", "-", "o"); graph.add_row("error estimate", "k", "--"); // convergence graph wrt. CPU time GnuplotGraph graph_cpu; graph_cpu.set_captions("Error Convergence for the Inner Layer Problem", "CPU Time", "Error Estimate [%]"); graph_cpu.add_row("exact error", "k", "-", "o"); graph_cpu.add_row("error estimate", "k", "--"); graph_cpu.set_log_y(); // adaptivity loop int it = 1, ndofs; bool done = false; double cpu = 0.0; Solution sln_coarse, sln_fine; do { info("\n---- Adaptivity step %d ---------------------------------------------\n", it++); // time measurement begin_time(); // solve the coarse mesh problem LinSystem ls(&wf, &solver); ls.set_spaces(1, &space); ls.set_pss(1, &pss); ls.assemble(); ls.solve(1, &sln_coarse); // time measurement cpu += end_time(); // calculate error wrt. exact solution ExactSolution exact(&mesh, fndd); double error = h1_error(&sln_coarse, &exact) * 100; // time measurement begin_time(); // solve the fine mesh problem RefSystem rs(&ls); rs.assemble(); rs.solve(1, &sln_fine); // calculate error estimate wrt. fine mesh solution H1AdaptHP hp(1, &space); double err_est = hp.calc_error(&sln_coarse, &sln_fine) * 100; info("Exact solution error: %g%%", error); info("Estimate of error: %g%%", err_est); // add entry to DOF convergence graph graph.add_values(0, space.get_num_dofs(), error); graph.add_values(1, space.get_num_dofs(), err_est); graph.save("conv_dof.gp"); // add entry to CPU convergence graph graph_cpu.add_values(0, cpu, error); graph_cpu.add_values(1, cpu, err_est); graph_cpu.save("conv_cpu.gp"); // if err_est too large, adapt the mesh if (err_est < ERR_STOP) done = true; else { hp.adapt(THRESHOLD, STRATEGY, &selector, MESH_REGULARITY); ndofs = space.assign_dofs(); if (ndofs >= NDOF_STOP) done = true; } // time measurement cpu += end_time(); } while (done == false); verbose("Total running time: %g sec", cpu); #define ERROR_SUCCESS 0 #define ERROR_FAILURE -1 int n_dof_allowed = 4000; printf("n_dof_actual = %d\n", ndofs); printf("n_dof_allowed = %d\n", n_dof_allowed); if (ndofs <= n_dof_allowed) { printf("Success!\n"); return ERROR_SUCCESS; } else { printf("Failure!\n"); return ERROR_FAILURE; } }
bool SQL_RAW::callProtocol(std::string input_str, std::string &result, const bool async_method, const unsigned int unique_id) { try { #ifdef DEBUG_TESTING extension_ptr->console->info("extDB2: SQL_RAW: Trace: Input: {0}", input_str); #endif #ifdef DEBUG_LOGGING extension_ptr->logger->info("extDB2: SQL_RAW: Trace: Input: {0}", input_str); #endif Poco::Data::Session session = extension_ptr->getDBSession_mutexlock(*database_ptr); Poco::Data::RecordSet rs(session, input_str); result = "[1,["; std::string temp_str; temp_str.reserve(result.capacity()); std::size_t cols = rs.columnCount(); if (cols >= 1) { result += "["; bool more = rs.moveFirst(); while (more) { for (std::size_t col = 0; col < cols; ++col) { if (rs[col].isEmpty()) { temp_str.clear(); } else { temp_str = rs[col].convert<std::string>(); } auto datatype = rs.columnType(col); if ((datatype == Poco::Data::MetaColumn::FDT_DATE) || (datatype == Poco::Data::MetaColumn::FDT_TIME) || (datatype == Poco::Data::MetaColumn::FDT_TIMESTAMP)) { if (temp_str.empty()) { result += "\"\""; } else { boost::erase_all(temp_str, "\""); result += "\"" + temp_str + "\""; } } else if ((stringDataTypeCheck) && (rs.columnType(col) == Poco::Data::MetaColumn::FDT_STRING)) { if (temp_str.empty()) { result += ("\"\""); } else { boost::erase_all(temp_str, "\""); result += "\"" + temp_str + "\""; } } else { if (temp_str.empty()) { result += "\"\""; } else { result += temp_str; } } if (col < (cols - 1)) { result += ","; } } more = rs.moveNext(); if (more) { result += "],["; } } result += "]"; } result += "]]"; #ifdef DEBUG_TESTING extension_ptr->console->info("extDB2: SQL_RAW: Trace: Result: {0}", result); #endif #ifdef DEBUG_LOGGING extension_ptr->logger->info("extDB2: SQL_RAW: Trace: Result: {0}", result); #endif } catch (Poco::InvalidAccessException& e) { #ifdef DEBUG_TESTING extension_ptr->console->error("extDB2: SQL_RAW: Error InvalidAccessException: {0}", e.displayText()); extension_ptr->console->error("extDB2: SQL_RAW: Error InvalidAccessException: SQL: {0}", input_str); #endif extension_ptr->logger->error("extDB2: SQL_RAW: Error InvalidAccessException: {0}", e.displayText()); extension_ptr->logger->error("extDB2: SQL_RAW: Error InvalidAccessException: SQL: {0}", input_str); result = "[0,\"Error DBLocked Exception\"]"; } catch (Poco::Data::NotConnectedException& e) { #ifdef DEBUG_TESTING extension_ptr->console->error("extDB2: SQL_RAW: Error NotConnectedException: {0}", e.displayText()); extension_ptr->console->error("extDB2: SQL_RAW: Error NotConnectedException: SQL: {0}", input_str); #endif extension_ptr->logger->error("extDB2: SQL_RAW: Error NotConnectedException: {0}", e.displayText()); extension_ptr->logger->error("extDB2: SQL_RAW: Error NotConnectedException: SQL: {0}", input_str); result = "[0,\"Error DBLocked Exception\"]"; } catch (Poco::NotImplementedException& e) { #ifdef DEBUG_TESTING extension_ptr->console->error("extDB2: SQL_RAW: Error NotImplementedException: {0}", e.displayText()); extension_ptr->console->error("extDB2: SQL_RAW: Error NotImplementedException: SQL: {0}", input_str); #endif extension_ptr->logger->error("extDB2: SQL_RAW: Error NotImplementedException: {0}", e.displayText()); extension_ptr->logger->error("extDB2: SQL_RAW: Error NotImplementedException: SQL: {0}", input_str); result = "[0,\"Error DBLocked Exception\"]"; } catch (Poco::Data::SQLite::DBLockedException& e) { #ifdef DEBUG_TESTING extension_ptr->console->error("extDB2: SQL_RAW: Error DBLockedException: {0}", e.displayText()); extension_ptr->logger->error("extDB2: SQL_RAW: Error DBLockedException: SQL: {0}", input_str); #endif extension_ptr->logger->error("extDB2: SQL_RAW: Error DBLockedException: {0}", e.displayText()); extension_ptr->logger->error("extDB2: SQL_RAW: Error DBLockedException: SQL: {0}", input_str); result = "[0,\"Error DBLocked Exception\"]"; } catch (Poco::Data::MySQL::ConnectionException& e) { #ifdef DEBUG_TESTING extension_ptr->console->error("extDB2: SQL_RAW: Error ConnectionException: {0}", e.displayText()); extension_ptr->logger->error("extDB2: SQL_RAW: Error ConnectionException: SQL: {0}", input_str); #endif extension_ptr->logger->error("extDB2: SQL_RAW: Error ConnectionException: {0}", e.displayText()); extension_ptr->logger->error("extDB2: SQL_RAW: Error ConnectionException: SQL: {0}", input_str); result = "[0,\"Error Connection Exception\"]"; } catch(Poco::Data::MySQL::StatementException& e) { #ifdef DEBUG_TESTING extension_ptr->console->error("extDB2: SQL_RAW: Error StatementException: {0}", e.displayText()); extension_ptr->logger->error("extDB2: SQL_RAW: Error StatementException: SQL: {0}", input_str); #endif extension_ptr->logger->error("extDB2: SQL_RAW: Error StatementException: {0}", e.displayText()); extension_ptr->logger->error("extDB2: SQL_RAW: Error StatementException: SQL: {0}", input_str); result = "[0,\"Error Statement Exception\"]"; } catch (Poco::Data::ConnectionFailedException& e) { #ifdef DEBUG_TESTING extension_ptr->console->error("extDB2: SQL_RAW: Error ConnectionFailedException: {0}", e.displayText()); extension_ptr->console->error("extDB2: SQL_RAW: Error ConnectionFailedException: SQL {0}", input_str); #endif extension_ptr->logger->error("extDB2: SQL_RAW: Error ConnectionFailedException: {0}", e.displayText()); extension_ptr->logger->error("extDB2: SQL_RAW: Error ConnectionFailedException: SQL {0}", input_str); result = "[0,\"Error ConnectionFailedException\"]"; } catch (Poco::Data::DataException& e) { #ifdef DEBUG_TESTING extension_ptr->console->error("extDB2: SQL_RAW: Error DataException: {0}", e.displayText()); extension_ptr->logger->error("extDB2: SQL_RAW: Error DataException: SQL: {0}", input_str); #endif extension_ptr->logger->error("extDB2: SQL_RAW: Error DataException: {0}", e.displayText()); extension_ptr->logger->error("extDB2: SQL_RAW: Error DataException: SQL: {0}", input_str); result = "[0,\"Error Data Exception\"]"; } catch (Poco::Exception& e) { #ifdef DEBUG_TESTING extension_ptr->console->error("extDB2: SQL_RAW: Error Exception: {0}", e.displayText()); extension_ptr->console->error("extDB2: SQL_RAW: Error Exception: SQL: {0}", input_str); #endif extension_ptr->logger->error("extDB2: SQL_RAW: Error Exception: {0}", e.displayText()); extension_ptr->logger->error("extDB2: SQL_RAW: Error Exception: SQL: {0}", input_str); result = "[0,\"Error Exception\"]"; } return true; }
OopMapSet* Runtime1::generate_code_for(StubID id, StubAssembler* sasm) { OopMapSet* oop_maps = NULL; // for better readability const bool must_gc_arguments = true; const bool dont_gc_arguments = false; // stub code & info for the different stubs switch (id) { case forward_exception_id: { oop_maps = generate_handle_exception(id, sasm); } break; case new_instance_id: case fast_new_instance_id: case fast_new_instance_init_check_id: { Register G5_klass = G5; // Incoming Register O0_obj = O0; // Outgoing if (id == new_instance_id) { __ set_info("new_instance", dont_gc_arguments); } else if (id == fast_new_instance_id) { __ set_info("fast new_instance", dont_gc_arguments); } else { assert(id == fast_new_instance_init_check_id, "bad StubID"); __ set_info("fast new_instance init check", dont_gc_arguments); } if ((id == fast_new_instance_id || id == fast_new_instance_init_check_id) && UseTLAB && FastTLABRefill) { Label slow_path; Register G1_obj_size = G1; Register G3_t1 = G3; Register G4_t2 = G4; assert_different_registers(G5_klass, G1_obj_size, G3_t1, G4_t2); // Push a frame since we may do dtrace notification for the // allocation which requires calling out and we don't want // to stomp the real return address. __ save_frame(0); if (id == fast_new_instance_init_check_id) { // make sure the klass is initialized __ ldub(G5_klass, in_bytes(InstanceKlass::init_state_offset()), G3_t1); __ cmp(G3_t1, InstanceKlass::fully_initialized); __ br(Assembler::notEqual, false, Assembler::pn, slow_path); __ delayed()->nop(); } #ifdef ASSERT // assert object can be fast path allocated { Label ok, not_ok; __ ld(G5_klass, in_bytes(Klass::layout_helper_offset()), G1_obj_size); // make sure it's an instance (LH > 0) __ cmp_and_br_short(G1_obj_size, 0, Assembler::lessEqual, Assembler::pn, not_ok); __ btst(Klass::_lh_instance_slow_path_bit, G1_obj_size); __ br(Assembler::zero, false, Assembler::pn, ok); __ delayed()->nop(); __ bind(not_ok); __ stop("assert(can be fast path allocated)"); __ should_not_reach_here(); __ bind(ok); } #endif // ASSERT // if we got here then the TLAB allocation failed, so try // refilling the TLAB or allocating directly from eden. Label retry_tlab, try_eden; __ tlab_refill(retry_tlab, try_eden, slow_path); // preserves G5_klass __ bind(retry_tlab); // get the instance size __ ld(G5_klass, in_bytes(Klass::layout_helper_offset()), G1_obj_size); __ tlab_allocate(O0_obj, G1_obj_size, 0, G3_t1, slow_path); __ initialize_object(O0_obj, G5_klass, G1_obj_size, 0, G3_t1, G4_t2); __ verify_oop(O0_obj); __ mov(O0, I0); __ ret(); __ delayed()->restore(); __ bind(try_eden); // get the instance size __ ld(G5_klass, in_bytes(Klass::layout_helper_offset()), G1_obj_size); __ eden_allocate(O0_obj, G1_obj_size, 0, G3_t1, G4_t2, slow_path); __ incr_allocated_bytes(G1_obj_size, G3_t1, G4_t2); __ initialize_object(O0_obj, G5_klass, G1_obj_size, 0, G3_t1, G4_t2); __ verify_oop(O0_obj); __ mov(O0, I0); __ ret(); __ delayed()->restore(); __ bind(slow_path); // pop this frame so generate_stub_call can push it's own __ restore(); } oop_maps = generate_stub_call(sasm, I0, CAST_FROM_FN_PTR(address, new_instance), G5_klass); // I0->O0: new instance } break; case counter_overflow_id: // G4 contains bci, G5 contains method oop_maps = generate_stub_call(sasm, noreg, CAST_FROM_FN_PTR(address, counter_overflow), G4, G5); break; case new_type_array_id: case new_object_array_id: { Register G5_klass = G5; // Incoming Register G4_length = G4; // Incoming Register O0_obj = O0; // Outgoing Address klass_lh(G5_klass, Klass::layout_helper_offset()); assert(Klass::_lh_header_size_shift % BitsPerByte == 0, "bytewise"); assert(Klass::_lh_header_size_mask == 0xFF, "bytewise"); // Use this offset to pick out an individual byte of the layout_helper: const int klass_lh_header_size_offset = ((BytesPerInt - 1) // 3 - 2 selects byte {0,1,0,0} - Klass::_lh_header_size_shift / BitsPerByte); if (id == new_type_array_id) { __ set_info("new_type_array", dont_gc_arguments); } else { __ set_info("new_object_array", dont_gc_arguments); } #ifdef ASSERT // assert object type is really an array of the proper kind { Label ok; Register G3_t1 = G3; __ ld(klass_lh, G3_t1); __ sra(G3_t1, Klass::_lh_array_tag_shift, G3_t1); int tag = ((id == new_type_array_id) ? Klass::_lh_array_tag_type_value : Klass::_lh_array_tag_obj_value); __ cmp_and_brx_short(G3_t1, tag, Assembler::equal, Assembler::pt, ok); __ stop("assert(is an array klass)"); __ should_not_reach_here(); __ bind(ok); } #endif // ASSERT if (UseTLAB && FastTLABRefill) { Label slow_path; Register G1_arr_size = G1; Register G3_t1 = G3; Register O1_t2 = O1; assert_different_registers(G5_klass, G4_length, G1_arr_size, G3_t1, O1_t2); // check that array length is small enough for fast path __ set(C1_MacroAssembler::max_array_allocation_length, G3_t1); __ cmp(G4_length, G3_t1); __ br(Assembler::greaterUnsigned, false, Assembler::pn, slow_path); __ delayed()->nop(); // if we got here then the TLAB allocation failed, so try // refilling the TLAB or allocating directly from eden. Label retry_tlab, try_eden; __ tlab_refill(retry_tlab, try_eden, slow_path); // preserves G4_length and G5_klass __ bind(retry_tlab); // get the allocation size: (length << (layout_helper & 0x1F)) + header_size __ ld(klass_lh, G3_t1); __ sll(G4_length, G3_t1, G1_arr_size); __ srl(G3_t1, Klass::_lh_header_size_shift, G3_t1); __ and3(G3_t1, Klass::_lh_header_size_mask, G3_t1); __ add(G1_arr_size, G3_t1, G1_arr_size); __ add(G1_arr_size, MinObjAlignmentInBytesMask, G1_arr_size); // align up __ and3(G1_arr_size, ~MinObjAlignmentInBytesMask, G1_arr_size); __ tlab_allocate(O0_obj, G1_arr_size, 0, G3_t1, slow_path); // preserves G1_arr_size __ initialize_header(O0_obj, G5_klass, G4_length, G3_t1, O1_t2); __ ldub(klass_lh, G3_t1, klass_lh_header_size_offset); __ sub(G1_arr_size, G3_t1, O1_t2); // body length __ add(O0_obj, G3_t1, G3_t1); // body start __ initialize_body(G3_t1, O1_t2); __ verify_oop(O0_obj); __ retl(); __ delayed()->nop(); __ bind(try_eden); // get the allocation size: (length << (layout_helper & 0x1F)) + header_size __ ld(klass_lh, G3_t1); __ sll(G4_length, G3_t1, G1_arr_size); __ srl(G3_t1, Klass::_lh_header_size_shift, G3_t1); __ and3(G3_t1, Klass::_lh_header_size_mask, G3_t1); __ add(G1_arr_size, G3_t1, G1_arr_size); __ add(G1_arr_size, MinObjAlignmentInBytesMask, G1_arr_size); __ and3(G1_arr_size, ~MinObjAlignmentInBytesMask, G1_arr_size); __ eden_allocate(O0_obj, G1_arr_size, 0, G3_t1, O1_t2, slow_path); // preserves G1_arr_size __ incr_allocated_bytes(G1_arr_size, G3_t1, O1_t2); __ initialize_header(O0_obj, G5_klass, G4_length, G3_t1, O1_t2); __ ldub(klass_lh, G3_t1, klass_lh_header_size_offset); __ sub(G1_arr_size, G3_t1, O1_t2); // body length __ add(O0_obj, G3_t1, G3_t1); // body start __ initialize_body(G3_t1, O1_t2); __ verify_oop(O0_obj); __ retl(); __ delayed()->nop(); __ bind(slow_path); } if (id == new_type_array_id) { oop_maps = generate_stub_call(sasm, I0, CAST_FROM_FN_PTR(address, new_type_array), G5_klass, G4_length); } else { oop_maps = generate_stub_call(sasm, I0, CAST_FROM_FN_PTR(address, new_object_array), G5_klass, G4_length); } // I0 -> O0: new array } break; case new_multi_array_id: { // O0: klass // O1: rank // O2: address of 1st dimension __ set_info("new_multi_array", dont_gc_arguments); oop_maps = generate_stub_call(sasm, I0, CAST_FROM_FN_PTR(address, new_multi_array), I0, I1, I2); // I0 -> O0: new multi array } break; case register_finalizer_id: { __ set_info("register_finalizer", dont_gc_arguments); // load the klass and check the has finalizer flag Label register_finalizer; Register t = O1; __ load_klass(O0, t); __ ld(t, in_bytes(Klass::access_flags_offset()), t); __ set(JVM_ACC_HAS_FINALIZER, G3); __ andcc(G3, t, G0); __ br(Assembler::notZero, false, Assembler::pt, register_finalizer); __ delayed()->nop(); // do a leaf return __ retl(); __ delayed()->nop(); __ bind(register_finalizer); OopMap* oop_map = save_live_registers(sasm); int call_offset = __ call_RT(noreg, noreg, CAST_FROM_FN_PTR(address, SharedRuntime::register_finalizer), I0); oop_maps = new OopMapSet(); oop_maps->add_gc_map(call_offset, oop_map); // Now restore all the live registers restore_live_registers(sasm); __ ret(); __ delayed()->restore(); } break; case throw_range_check_failed_id: { __ set_info("range_check_failed", dont_gc_arguments); // arguments will be discarded // G4: index oop_maps = generate_exception_throw(sasm, CAST_FROM_FN_PTR(address, throw_range_check_exception), true); } break; case throw_index_exception_id: { __ set_info("index_range_check_failed", dont_gc_arguments); // arguments will be discarded // G4: index oop_maps = generate_exception_throw(sasm, CAST_FROM_FN_PTR(address, throw_index_exception), true); } break; case throw_div0_exception_id: { __ set_info("throw_div0_exception", dont_gc_arguments); oop_maps = generate_exception_throw(sasm, CAST_FROM_FN_PTR(address, throw_div0_exception), false); } break; case throw_null_pointer_exception_id: { __ set_info("throw_null_pointer_exception", dont_gc_arguments); oop_maps = generate_exception_throw(sasm, CAST_FROM_FN_PTR(address, throw_null_pointer_exception), false); } break; case handle_exception_id: { __ set_info("handle_exception", dont_gc_arguments); oop_maps = generate_handle_exception(id, sasm); } break; case handle_exception_from_callee_id: { __ set_info("handle_exception_from_callee", dont_gc_arguments); oop_maps = generate_handle_exception(id, sasm); } break; case unwind_exception_id: { // O0: exception // I7: address of call to this method __ set_info("unwind_exception", dont_gc_arguments); __ mov(Oexception, Oexception->after_save()); __ add(I7, frame::pc_return_offset, Oissuing_pc->after_save()); __ call_VM_leaf(L7_thread_cache, CAST_FROM_FN_PTR(address, SharedRuntime::exception_handler_for_return_address), G2_thread, Oissuing_pc->after_save()); __ verify_not_null_oop(Oexception->after_save()); // Restore SP from L7 if the exception PC is a method handle call site. __ mov(O0, G5); // Save the target address. __ lduw(Address(G2_thread, JavaThread::is_method_handle_return_offset()), L0); __ tst(L0); // Condition codes are preserved over the restore. __ restore(); __ jmp(G5, 0); __ delayed()->movcc(Assembler::notZero, false, Assembler::icc, L7_mh_SP_save, SP); // Restore SP if required. } break; case throw_array_store_exception_id: { __ set_info("throw_array_store_exception", dont_gc_arguments); oop_maps = generate_exception_throw(sasm, CAST_FROM_FN_PTR(address, throw_array_store_exception), true); } break; case throw_class_cast_exception_id: { // G4: object __ set_info("throw_class_cast_exception", dont_gc_arguments); oop_maps = generate_exception_throw(sasm, CAST_FROM_FN_PTR(address, throw_class_cast_exception), true); } break; case throw_incompatible_class_change_error_id: { __ set_info("throw_incompatible_class_cast_exception", dont_gc_arguments); oop_maps = generate_exception_throw(sasm, CAST_FROM_FN_PTR(address, throw_incompatible_class_change_error), false); } break; case slow_subtype_check_id: { // Support for uint StubRoutine::partial_subtype_check( Klass sub, Klass super ); // Arguments : // // ret : G3 // sub : G3, argument, destroyed // super: G1, argument, not changed // raddr: O7, blown by call Label miss; __ save_frame(0); // Blow no registers! __ check_klass_subtype_slow_path(G3, G1, L0, L1, L2, L4, NULL, &miss); __ mov(1, G3); __ ret(); // Result in G5 is 'true' __ delayed()->restore(); // free copy or add can go here __ bind(miss); __ mov(0, G3); __ ret(); // Result in G5 is 'false' __ delayed()->restore(); // free copy or add can go here } case monitorenter_nofpu_id: case monitorenter_id: { // G4: object // G5: lock address __ set_info("monitorenter", dont_gc_arguments); int save_fpu_registers = (id == monitorenter_id); // make a frame and preserve the caller's caller-save registers OopMap* oop_map = save_live_registers(sasm, save_fpu_registers); int call_offset = __ call_RT(noreg, noreg, CAST_FROM_FN_PTR(address, monitorenter), G4, G5); oop_maps = new OopMapSet(); oop_maps->add_gc_map(call_offset, oop_map); restore_live_registers(sasm, save_fpu_registers); __ ret(); __ delayed()->restore(); } break; case monitorexit_nofpu_id: case monitorexit_id: { // G4: lock address // note: really a leaf routine but must setup last java sp // => use call_RT for now (speed can be improved by // doing last java sp setup manually) __ set_info("monitorexit", dont_gc_arguments); int save_fpu_registers = (id == monitorexit_id); // make a frame and preserve the caller's caller-save registers OopMap* oop_map = save_live_registers(sasm, save_fpu_registers); int call_offset = __ call_RT(noreg, noreg, CAST_FROM_FN_PTR(address, monitorexit), G4); oop_maps = new OopMapSet(); oop_maps->add_gc_map(call_offset, oop_map); restore_live_registers(sasm, save_fpu_registers); __ ret(); __ delayed()->restore(); } break; case deoptimize_id: { __ set_info("deoptimize", dont_gc_arguments); OopMap* oop_map = save_live_registers(sasm); int call_offset = __ call_RT(noreg, noreg, CAST_FROM_FN_PTR(address, deoptimize), G4); oop_maps = new OopMapSet(); oop_maps->add_gc_map(call_offset, oop_map); restore_live_registers(sasm); DeoptimizationBlob* deopt_blob = SharedRuntime::deopt_blob(); assert(deopt_blob != NULL, "deoptimization blob must have been created"); AddressLiteral dest(deopt_blob->unpack_with_reexecution()); __ jump_to(dest, O0); __ delayed()->restore(); } break; case access_field_patching_id: { __ set_info("access_field_patching", dont_gc_arguments); oop_maps = generate_patching(sasm, CAST_FROM_FN_PTR(address, access_field_patching)); } break; case load_klass_patching_id: { __ set_info("load_klass_patching", dont_gc_arguments); oop_maps = generate_patching(sasm, CAST_FROM_FN_PTR(address, move_klass_patching)); } break; case load_mirror_patching_id: { __ set_info("load_mirror_patching", dont_gc_arguments); oop_maps = generate_patching(sasm, CAST_FROM_FN_PTR(address, move_mirror_patching)); } break; case load_appendix_patching_id: { __ set_info("load_appendix_patching", dont_gc_arguments); oop_maps = generate_patching(sasm, CAST_FROM_FN_PTR(address, move_appendix_patching)); } break; case dtrace_object_alloc_id: { // O0: object __ set_info("dtrace_object_alloc", dont_gc_arguments); // we can't gc here so skip the oopmap but make sure that all // the live registers get saved. save_live_registers(sasm); __ save_thread(L7_thread_cache); __ call(CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_object_alloc), relocInfo::runtime_call_type); __ delayed()->mov(I0, O0); __ restore_thread(L7_thread_cache); restore_live_registers(sasm); __ ret(); __ delayed()->restore(); } break; #if INCLUDE_ALL_GCS case g1_pre_barrier_slow_id: { // G4: previous value of memory BarrierSet* bs = Universe::heap()->barrier_set(); if (bs->kind() != BarrierSet::G1SATBCTLogging) { __ save_frame(0); __ set((int)id, O1); __ call_RT(noreg, noreg, CAST_FROM_FN_PTR(address, unimplemented_entry), I0); __ should_not_reach_here(); break; } __ set_info("g1_pre_barrier_slow_id", dont_gc_arguments); Register pre_val = G4; Register tmp = G1_scratch; Register tmp2 = G3_scratch; Label refill, restart; bool with_frame = false; // I don't know if we can do with-frame. int satb_q_index_byte_offset = in_bytes(JavaThread::satb_mark_queue_offset() + PtrQueue::byte_offset_of_index()); int satb_q_buf_byte_offset = in_bytes(JavaThread::satb_mark_queue_offset() + PtrQueue::byte_offset_of_buf()); __ bind(restart); // Load the index into the SATB buffer. PtrQueue::_index is a // size_t so ld_ptr is appropriate __ ld_ptr(G2_thread, satb_q_index_byte_offset, tmp); // index == 0? __ cmp_and_brx_short(tmp, G0, Assembler::equal, Assembler::pn, refill); __ ld_ptr(G2_thread, satb_q_buf_byte_offset, tmp2); __ sub(tmp, oopSize, tmp); __ st_ptr(pre_val, tmp2, tmp); // [_buf + index] := <address_of_card> // Use return-from-leaf __ retl(); __ delayed()->st_ptr(tmp, G2_thread, satb_q_index_byte_offset); __ bind(refill); __ save_frame(0); __ mov(pre_val, L0); __ mov(tmp, L1); __ mov(tmp2, L2); __ call_VM_leaf(L7_thread_cache, CAST_FROM_FN_PTR(address, SATBMarkQueueSet::handle_zero_index_for_thread), G2_thread); __ mov(L0, pre_val); __ mov(L1, tmp); __ mov(L2, tmp2); __ br(Assembler::always, /*annul*/false, Assembler::pt, restart); __ delayed()->restore(); } break; case g1_post_barrier_slow_id: { BarrierSet* bs = Universe::heap()->barrier_set(); if (bs->kind() != BarrierSet::G1SATBCTLogging) { __ save_frame(0); __ set((int)id, O1); __ call_RT(noreg, noreg, CAST_FROM_FN_PTR(address, unimplemented_entry), I0); __ should_not_reach_here(); break; } __ set_info("g1_post_barrier_slow_id", dont_gc_arguments); Register addr = G4; Register cardtable = G5; Register tmp = G1_scratch; Register tmp2 = G3_scratch; jbyte* byte_map_base = barrier_set_cast<CardTableModRefBS>(bs)->byte_map_base; Label not_already_dirty, restart, refill, young_card; #ifdef _LP64 __ srlx(addr, CardTableModRefBS::card_shift, addr); #else __ srl(addr, CardTableModRefBS::card_shift, addr); #endif AddressLiteral rs(byte_map_base); __ set(rs, cardtable); // cardtable := <card table base> __ ldub(addr, cardtable, tmp); // tmp := [addr + cardtable] __ cmp_and_br_short(tmp, G1SATBCardTableModRefBS::g1_young_card_val(), Assembler::equal, Assembler::pt, young_card); __ membar(Assembler::Membar_mask_bits(Assembler::StoreLoad)); __ ldub(addr, cardtable, tmp); // tmp := [addr + cardtable] assert(CardTableModRefBS::dirty_card_val() == 0, "otherwise check this code"); __ cmp_and_br_short(tmp, G0, Assembler::notEqual, Assembler::pt, not_already_dirty); __ bind(young_card); // We didn't take the branch, so we're already dirty: return. // Use return-from-leaf __ retl(); __ delayed()->nop(); // Not dirty. __ bind(not_already_dirty); // Get cardtable + tmp into a reg by itself __ add(addr, cardtable, tmp2); // First, dirty it. __ stb(G0, tmp2, 0); // [cardPtr] := 0 (i.e., dirty). Register tmp3 = cardtable; Register tmp4 = tmp; // these registers are now dead addr = cardtable = tmp = noreg; int dirty_card_q_index_byte_offset = in_bytes(JavaThread::dirty_card_queue_offset() + PtrQueue::byte_offset_of_index()); int dirty_card_q_buf_byte_offset = in_bytes(JavaThread::dirty_card_queue_offset() + PtrQueue::byte_offset_of_buf()); __ bind(restart); // Get the index into the update buffer. PtrQueue::_index is // a size_t so ld_ptr is appropriate here. __ ld_ptr(G2_thread, dirty_card_q_index_byte_offset, tmp3); // index == 0? __ cmp_and_brx_short(tmp3, G0, Assembler::equal, Assembler::pn, refill); __ ld_ptr(G2_thread, dirty_card_q_buf_byte_offset, tmp4); __ sub(tmp3, oopSize, tmp3); __ st_ptr(tmp2, tmp4, tmp3); // [_buf + index] := <address_of_card> // Use return-from-leaf __ retl(); __ delayed()->st_ptr(tmp3, G2_thread, dirty_card_q_index_byte_offset); __ bind(refill); __ save_frame(0); __ mov(tmp2, L0); __ mov(tmp3, L1); __ mov(tmp4, L2); __ call_VM_leaf(L7_thread_cache, CAST_FROM_FN_PTR(address, DirtyCardQueueSet::handle_zero_index_for_thread), G2_thread); __ mov(L0, tmp2); __ mov(L1, tmp3); __ mov(L2, tmp4); __ br(Assembler::always, /*annul*/false, Assembler::pt, restart); __ delayed()->restore(); } break; #endif // INCLUDE_ALL_GCS case predicate_failed_trap_id: { __ set_info("predicate_failed_trap", dont_gc_arguments); OopMap* oop_map = save_live_registers(sasm); int call_offset = __ call_RT(noreg, noreg, CAST_FROM_FN_PTR(address, predicate_failed_trap)); oop_maps = new OopMapSet(); oop_maps->add_gc_map(call_offset, oop_map); DeoptimizationBlob* deopt_blob = SharedRuntime::deopt_blob(); assert(deopt_blob != NULL, "deoptimization blob must have been created"); restore_live_registers(sasm); AddressLiteral dest(deopt_blob->unpack_with_reexecution()); __ jump_to(dest, O0); __ delayed()->restore(); } break; default: { __ set_info("unimplemented entry", dont_gc_arguments); __ save_frame(0); __ set((int)id, O1); __ call_RT(noreg, noreg, CAST_FROM_FN_PTR(address, unimplemented_entry), O1); __ should_not_reach_here(); } break; } return oop_maps; }
void CTMTreatmentActivitybyDept::PrintHoatdongdieutri(CString szFromDate, CString szToDate, CString szDoctor, bool bPreview){ CHMSMainFrame *pMF = (CHMSMainFrame*) AfxGetMainWnd(); CRecord rs(&pMF->m_db); CString szSQL, tmpStr, tmpStr1, szFromDateLabel, szToDateLabel, szWhere,szAmount, szOutpatient, m_szStatus; CString szDate, szSysDate; szSysDate = pMF->GetSysDate(); CReport rpt; szSQL = GetQueryString(); BeginWaitCursor(); rs.ExecSQL(szSQL); if (rs.IsEOF()) { AfxMessageBox(_T("No Data")); return; } if(!rpt.Init(_T("Reports/HMS/RPT_HOATDONGDIEUTRI.RPT"))) return ; //Report Header tmpStr = rpt.GetReportHeader()->GetValue(_T("ReportDate")); szDate.Format(tmpStr, CDate::Convert(szFromDate, yyyymmdd, ddmmyyyy),CDate::Convert(szToDate, yyyymmdd, ddmmyyyy)); rpt.GetReportHeader()->SetValue(_T("ReportDate"), szDate); rpt.GetReportHeader()->SetValue(_T("HEALTHSERVICE"), pMF->m_CompanyInfo.sc_pname); rpt.GetReportHeader()->SetValue(_T("HOSPITALNAME"), pMF->m_CompanyInfo.sc_name); //Report Detail CReportSection* rptDetail = rpt.GetDetail(); int nIndex = 1, SongayDT=0; int i=0,nTotal[18]; for (i=0;i<18;i++) { nTotal[i]=0; } while(!rs.IsEOF()) { rptDetail = rpt.AddDetail(); tmpStr.Format(_T("%d"), nIndex++); rptDetail->SetValue(_T("1"), tmpStr); rs.GetValue(_T("Deptname"), tmpStr); rptDetail->SetValue(_T("2"), tmpStr); rs.GetValue(_T("Totalbed"), tmpStr); nTotal[3] += ToInt(tmpStr); rptDetail->SetValue(_T("3"), tmpStr); rs.GetValue(_T("oldpatient"), tmpStr); nTotal[4] += ToInt(tmpStr); rptDetail->SetValue(_T("4"), tmpStr); rs.GetValue(_T("Admission"), tmpStr); nTotal[5] += ToInt(tmpStr); rptDetail->SetValue(_T("5"), tmpStr); rs.GetValue(_T("Tre15"), tmpStr); nTotal[6] += ToInt(tmpStr); rptDetail->SetValue(_T("6"), tmpStr); rs.GetValue(_T("Tre24Day"), tmpStr); nTotal[7] += ToInt(tmpStr); rptDetail->SetValue(_T("7"), tmpStr); rs.GetValue(_T("emergency"), tmpStr); nTotal[8] += ToInt(tmpStr); rptDetail->SetValue(_T("8"), tmpStr); rs.GetValue(_T("SongayDT"), tmpStr); rs.GetValue(_T("SongayDTO"), tmpStr1); if (m_bCheckBed) SongayDT=(ToInt(tmpStr)); else SongayDT=(ToInt(tmpStr) + ToInt(tmpStr1)); nTotal[9] += SongayDT; tmpStr.Format(_T("%ld"), SongayDT); rptDetail->SetValue(_T("9"), tmpStr); rs.GetValue(_T("dead"), tmpStr); nTotal[10] += ToInt(tmpStr); rptDetail->SetValue(_T("10"), tmpStr); rs.GetValue(_T("dead15"), tmpStr); nTotal[11] += ToInt(tmpStr); rptDetail->SetValue(_T("11"), tmpStr); rs.GetValue(_T("dead24Day"), tmpStr); nTotal[12] += ToInt(tmpStr); rptDetail->SetValue(_T("12"), tmpStr); rs.GetValue(_T("dead24h"), tmpStr); nTotal[13] += ToInt(tmpStr); rptDetail->SetValue(_T("13"),tmpStr); rs.GetValue(_T("dead24hf"), tmpStr); nTotal[14] += ToInt(tmpStr); rptDetail->SetValue(_T("14"),tmpStr); rs.GetValue(_T("BHYT"), tmpStr); nTotal[15] += ToInt(tmpStr); rptDetail->SetValue(_T("15"), tmpStr); rs.GetValue(_T("Chuyenvien"), tmpStr); nTotal[16] += ToInt(tmpStr); rptDetail->SetValue(_T("16"), tmpStr); rs.GetValue(_T("remain"), tmpStr); nTotal[17] += ToInt(tmpStr); rptDetail->SetValue(_T("17"), tmpStr); rs.MoveNext(); } rptDetail = rpt.AddDetail(); TranslateString(_T("Total"),tmpStr); rptDetail->GetItem(_T("2"))->SetBold(true); rptDetail->SetValue(_T("2"),tmpStr); for (int i =3; i < 18; i++){ tmpStr.Format(_T("%d"), i); szAmount.Format(_T("%ld"),nTotal[i] ); //rptDetail->GetItem(tmpStr)->SetBold(true); rptDetail->SetValue(tmpStr, szAmount); } //Page Footer //Report Footer szDate.Format(rpt.GetReportFooter()->GetValue(_T("PrintDate")),szSysDate.Right(2),szSysDate.Mid(5,2),szSysDate.Left(4)); rpt.GetReportFooter()->SetValue(_T("PrintDate"), szDate); EndWaitCursor(); if(bPreview) rpt.PrintPreview(); else rpt.Print(); }
void CEMGeneralSoldierExamination::OnExportSelect() { CHMSMainFrame *pMF = (CHMSMainFrame*) AfxGetMainWnd(); CRecord rs(&pMF->m_db); CString szSQL; CString tmpStr, szTemp; UpdateData(TRUE); BeginWaitCursor(); szSQL = GetQueryString(); rs.ExecSQL(szSQL); if (rs.IsEOF()) { ShowMessageBox(_T("No Data"), MB_ICONERROR | MB_OK); return; } CExcel xls; xls.CreateSheet(1); xls.SetWorksheet(0); xls.SetColumnWidth(0, 4); xls.SetColumnWidth(1, 23); xls.SetColumnWidth(2, 7); xls.SetColumnWidth(3, 10); xls.SetColumnWidth(4, 7); xls.SetColumnWidth(5, 10); xls.SetColumnWidth(6, 7); xls.SetColumnWidth(7, 10); xls.SetColumnWidth(8, 7); xls.SetColumnWidth(9, 10); xls.SetColumnWidth(10, 7); xls.SetColumnWidth(11, 10); xls.SetColumnWidth(12, 7); xls.SetColumnWidth(13, 10); int nRow = 1; int nCol = 0; xls.SetRowHeight(6, 20); xls.SetRowHeight(7, 36); xls.SetRowHeight(8, 36); xls.SetCellMergedColumns(0, 1, 4); xls.SetCellMergedColumns(0, 2, 4); xls.SetCellText(0, 1, pMF->m_CompanyInfo.sc_pname, FMT_TEXT | FMT_CENTER, true); xls.SetCellText(0, 2, pMF->m_CompanyInfo.sc_name, FMT_TEXT | FMT_CENTER, true); xls.SetCellMergedColumns(nCol, nRow + 3, 16); xls.SetCellMergedColumns(nCol, nRow + 4, 16); xls.SetCellText(nCol, nRow + 3, _T("T\xECnh h\xECnh kh\xE1m, \x63h\x1EEF\x61 \x62\x1EC7nh \x63\x1EE7\x61 qu\xE2n nh\xE2n th\x61m gi\x61 \x110\x1EC1 \xE1n th\xED \x111i\x1EC3m \x62\x1EA3o hi\x1EC3m y t\x1EBF qu\xE2n nh\xE2n"), FMT_TEXT | FMT_CENTER, true, 16, 0); tmpStr.Format(_T("T\x1EEB ng\xE0y %s \x111\x1EBFn ng\xE0y %s"), CDateTime::Convert(m_szFromDate, yyyymmdd | hhmm, ddmmyyyy | hhmm), CDateTime::Convert(m_szToDate, yyyymmdd | hhmm, ddmmyyyy | hhmm)); xls.SetCellText(nCol, nRow + 4, tmpStr, FMT_TEXT | FMT_CENTER, true, 12, 0); xls.SetCellMergedRows(nCol, nRow + 5, 3); xls.SetCellText(nCol, nRow + 5, _T("TT"), FMT_TEXT | FMT_CENTER | FMT_VCENTER | FMT_WRAPING, true, 11); xls.SetCellMergedRows(nCol + 1, nRow + 5, 3); xls.SetCellText(nCol + 1, nRow + 5, _T("\x110\x1A1n v\x1ECB th\x61m gi\x61 \x110\x1EC1 \xE1n"), FMT_TEXT | FMT_CENTER | FMT_VCENTER | FMT_WRAPING, true, 11); xls.SetCellMergedColumns(nCol + 2, nRow + 5, 6); xls.SetCellText(nCol + 2, nRow + 5, _T("K\x43\x42 ngo\x1EA1i tr\xFA"), FMT_TEXT | FMT_CENTER | FMT_VCENTER | FMT_WRAPING, true, 11); xls.SetCellMergedColumns(nCol + 2, nRow + 6, 2); xls.SetCellText(nCol + 2, nRow + 6, _T("\x43hi ph\xED t\x1EEB NSQP"), FMT_TEXT | FMT_CENTER | FMT_VCENTER | FMT_WRAPING, false, 11); xls.SetCellText(nCol + 2, nRow + 7, _T("S\x1ED1 l\x1B0\x1EE3t"), FMT_TEXT | FMT_CENTER | FMT_VCENTER | FMT_WRAPING, false, 11); xls.SetCellText(nCol + 3, nRow + 7, _T("S\x1ED1 ti\x1EC1n (\x111\x1ED3ng)"), FMT_TEXT | FMT_CENTER | FMT_VCENTER | FMT_WRAPING, false, 11); xls.SetCellMergedColumns(nCol + 4, nRow + 6, 2); xls.SetCellText(nCol + 4, nRow + 6, _T("\x43hi ph\xED t\x1EEB qu\x1EF9 \x42HYT"), FMT_TEXT | FMT_CENTER | FMT_VCENTER | FMT_WRAPING, false, 11); xls.SetCellText(nCol + 4, nRow + 7, _T("S\x1ED1 l\x1B0\x1EE3t"), FMT_TEXT | FMT_CENTER | FMT_VCENTER | FMT_WRAPING, false, 11); xls.SetCellText(nCol + 5, nRow + 7, _T("S\x1ED1 ti\x1EC1n (\x111\x1ED3ng)"), FMT_TEXT | FMT_CENTER | FMT_VCENTER | FMT_WRAPING, false, 11); xls.SetCellMergedColumns(nCol + 6, nRow + 6, 2); xls.SetCellText(nCol + 6, nRow + 6, _T("\x43\x1ED9ng"), FMT_TEXT | FMT_CENTER | FMT_VCENTER | FMT_WRAPING, false, 11); xls.SetCellText(nCol + 6, nRow + 7, _T("S\x1ED1 l\x1B0\x1EE3t"), FMT_TEXT | FMT_CENTER | FMT_VCENTER | FMT_WRAPING, false, 11); xls.SetCellText(nCol + 7, nRow + 7, _T("S\x1ED1 ti\x1EC1n (\x111\x1ED3ng)"), FMT_TEXT | FMT_CENTER | FMT_VCENTER | FMT_WRAPING, false, 11); xls.SetCellMergedColumns(nCol + 8, nRow + 5, 6); xls.SetCellText(nCol + 8, nRow + 5, _T("K\x43\x42 n\x1ED9i tr\xFA"), FMT_TEXT | FMT_CENTER | FMT_VCENTER | FMT_WRAPING, true, 11); xls.SetCellMergedColumns(nCol + 8, nRow + 6, 2); xls.SetCellText(nCol + 8, nRow + 6, _T("\x43hi ph\xED t\x1EEB NSQP"), FMT_TEXT | FMT_CENTER | FMT_VCENTER | FMT_WRAPING, false, 11); xls.SetCellText(nCol + 8, nRow + 7, _T("S\x1ED1 l\x1B0\x1EE3t"), FMT_TEXT | FMT_CENTER | FMT_VCENTER | FMT_WRAPING, false, 11); xls.SetCellText(nCol + 9, nRow + 7, _T("S\x1ED1 ti\x1EC1n (\x111\x1ED3ng)"), FMT_TEXT | FMT_CENTER | FMT_VCENTER | FMT_WRAPING, false, 11); xls.SetCellMergedColumns(nCol + 10, nRow + 6, 2); xls.SetCellText(nCol + 10, nRow + 6, _T("\x43hi ph\xED t\x1EEB qu\x1EF9 \x42HYT"), FMT_TEXT | FMT_CENTER | FMT_VCENTER | FMT_WRAPING, false, 11); xls.SetCellText(nCol + 10, nRow + 7, _T("S\x1ED1 l\x1B0\x1EE3t"), FMT_TEXT | FMT_CENTER | FMT_VCENTER | FMT_WRAPING, false, 11); xls.SetCellText(nCol + 11, nRow + 7, _T("S\x1ED1 ti\x1EC1n (\x111\x1ED3ng)"), FMT_TEXT | FMT_CENTER | FMT_VCENTER | FMT_WRAPING, false, 11); xls.SetCellMergedColumns(nCol + 12, nRow + 6, 2); xls.SetCellText(nCol + 12, nRow + 6, _T("\x43\x1ED9ng"), FMT_TEXT | FMT_CENTER | FMT_VCENTER | FMT_WRAPING, false, 11); xls.SetCellText(nCol + 12, nRow + 7, _T("S\x1ED1 l\x1B0\x1EE3t"), FMT_TEXT | FMT_CENTER | FMT_VCENTER | FMT_WRAPING, false, 11); xls.SetCellText(nCol + 13, nRow + 7, _T("S\x1ED1 ti\x1EC1n (\x111\x1ED3ng)"), FMT_TEXT | FMT_CENTER | FMT_VCENTER | FMT_WRAPING, false, 11); xls.SetCellMergedColumns(nCol + 14, nRow + 5, 2); xls.SetCellMergedRows(nCol + 14, nRow + 5, 2); xls.SetCellText(nCol + 14, nRow + 5, _T("T\x1ED5ng \x63\x1ED9ng"), FMT_TEXT | FMT_CENTER | FMT_VCENTER | FMT_WRAPING, false, 11); xls.SetCellText(nCol + 14, nRow + 7, _T("S\x1ED1 l\x1B0\x1EE3t"), FMT_TEXT | FMT_CENTER | FMT_VCENTER | FMT_WRAPING, false, 11); xls.SetCellText(nCol + 15, nRow + 7, _T("S\x1ED1 ti\x1EC1n (\x111\x1ED3ng)"), FMT_TEXT | FMT_CENTER | FMT_VCENTER | FMT_WRAPING, false, 11); int nIndex = 1; nRow = 8; while (!rs.IsEOF()) { nRow++; tmpStr.Format(_T("%d"), nIndex++); xls.SetCellText(nCol, nRow, tmpStr, FMT_INTEGER | FMT_WRAPING); rs.GetValue(_T("workplace"), tmpStr); xls.SetCellText(nCol + 1, nRow, tmpStr, FMT_TEXT | FMT_WRAPING); rs.GetValue(_T("ngt"), tmpStr); xls.SetCellText(nCol + 6, nRow, tmpStr, FMT_INTEGER | FMT_WRAPING); rs.GetValue(_T("nt"), tmpStr); xls.SetCellText(nCol + 12, nRow, tmpStr, FMT_INTEGER | FMT_WRAPING); rs.GetValue(_T("tong"), tmpStr); xls.SetCellText(nCol + 14, nRow, tmpStr, FMT_INTEGER | FMT_WRAPING); rs.MoveNext(); } EndWaitCursor(); xls.Save(_T("Exports\\THKCBQuanNhan.xls")); }
void CEMStatisticsMajorDiseasesReport::OnExportSelect(){ _debug(_T("%s"), CString(typeid(this).name())); CHMSMainFrame *pMF = (CHMSMainFrame*) AfxGetMainWnd(); UpdateData(true); CRecord rs(&pMF->m_db); CString szSQL, szTemp, tmpStr; CExcel xls; szSQL = GetQueryString(); BeginWaitCursor(); rs.ExecSQL(szSQL); if (rs.IsEOF()) { ShowMessage(150, MB_ICONSTOP); return; } xls.CreateSheet(1); xls.SetWorksheet(0); xls.SetColumnWidth(0, 7); xls.SetColumnWidth(1, 10); xls.SetColumnWidth(2, 78); xls.SetColumnWidth(3, 12); int nRow = 0, nCol = 0; xls.SetCellMergedColumns(nCol, nRow + 2, 4); xls.SetCellText(nCol+2, nRow, pMF->m_CompanyInfo.sc_pname, FMT_TEXT | FMT_CENTER, true, 10); xls.SetCellText(nCol+2, nRow + 1, pMF->m_CompanyInfo.sc_name, FMT_TEXT | FMT_CENTER, true, 10); xls.SetCellMergedColumns(nCol, nRow + 2, 4); xls.SetCellMergedColumns(nCol, nRow + 3, 4); xls.SetCellText(nCol, nRow + 2, _T("TH\x1ED0NG K\xCA M\x1EB6T \x42\x1EC6NH \x43H\xCDNH"), FMT_TEXT | FMT_CENTER, true, 13); tmpStr.Format(_T("T\x1EEB ng\xE0y %s \x110\x1EBFn ng\xE0y %s"), CDateTime::Convert(m_szFromDate, yyyymmdd|hhmmss, ddmmyyyy|hhmmss), CDateTime::Convert(m_szToDate, yyyymmdd|hhmmss, ddmmyyyy|hhmmss)); xls.SetCellText(nCol, nRow + 3, tmpStr, FMT_TEXT | FMT_CENTER, true, 11); xls.SetCellText(nCol, nRow + 4, _T("STT"), FMT_TEXT | FMT_CENTER, true, 11); xls.SetCellText(nCol + 1, nRow + 4, _T("M\xE3 \x62\x1EC7nh"), FMT_TEXT | FMT_CENTER, true, 11); xls.SetCellText(nCol + 2, nRow + 4, _T("T\xEAn m\x1EB7t \x62\x1EC7nh"), FMT_TEXT | FMT_CENTER, true, 11); xls.SetCellText(nCol + 3, nRow + 4, _T("S\x1ED1 l\x1B0\x1EE3ng"), FMT_TEXT | FMT_CENTER, true, 11); nRow += 5; int nIndex = 1; long double nTotal = 0.0; while (!rs.IsEOF()) { szTemp.Format(_T("%d"), nIndex); xls.SetCellText(nCol, nRow, szTemp, FMT_INTEGER); szTemp = rs.GetValue(_T("hi_icd")); xls.SetCellText(nCol + 1, nRow, szTemp, FMT_TEXT); szTemp = rs.GetValue(_T("ICDName")); xls.SetCellText(nCol + 2, nRow, szTemp, FMT_TEXT); szTemp = rs.GetValue(_T("total")); nTotal += ToDouble(szTemp); xls.SetCellText(nCol + 3, nRow, szTemp, FMT_INTEGER); nIndex++; nRow++; rs.MoveNext(); } xls.SetCellMergedColumns(nCol, nRow, 3); xls.SetCellText(nCol, nRow, _T("T\x1ED5ng \x63\x1ED9ng"), FMT_TEXT | FMT_CENTER, true, 12); xls.SetCellText(nCol + 3, nRow, double2str(nTotal), FMT_NUMBER1, true, 12 ); EndWaitCursor(); xls.Save(_T("Exports\\THONG KE MAT BENH CHINH.XLS")); }
STDMETHODIMP CDocProvider::GetHelpContext(LONG lError, LONG *plErrorID) { COM_METHOD_TRY CResourceSwapper rs(_Module.m_hInstResource); HRESULT hRes = S_OK; if (HRESULT_FACILITY(lError) != WSDOC) hRes = E_NOTIMPL; else { switch (lError) { case E_INVALID_SERVICE_NAME: *plErrorID = HIDC_INVALID_SERVICE_NAME; break; case E_NO_PROVIDER_SELECTED: *plErrorID = HIDC_INVALID_PROVIDER_SELECTED; break; case E_NO_DOCUMENT_INFO: *plErrorID = HIDC_NO_DOCUMENT_INFO; break; case E_INVALID_PROVIDER_SELECTED: *plErrorID = HIDC_INVALID_PROVIDER_SELECTED; break; case E_LOCAL_FILE_NOT_FOUND: *plErrorID = HIDC_FILE_DOES_NOT_EXIST; break; default: hRes = E_FAIL; } } if (hRes == E_NOTIMPL) { if (hRes == E_NOTIMPL && m_pCurrentDocumentProvider) { try { IWSErrorInfo* pErrorInfo = NULL; m_pCurrentDocumentProvider->QueryInterface(IID_IWSErrorInfo, (void**)&pErrorInfo); if( pErrorInfo) { hRes = pErrorInfo->GetHelpContext(lError, plErrorID); pErrorInfo->Release(); } else { hRes = E_FAIL; } } catch (...) { hRes = E_FAIL; } } } if (hRes == E_NOTIMPL) hRes = CWSErrorInfo::GetHelpContext(lError, plErrorID); return hRes; COM_METHOD_CATCH }