void OrganizedSurfaceNormalNode::_display() const
  {
    const KinectCloud& pcd = *pcd_otl_->pull();
    cv::Mat3b vis(cv::Size(pcd.width, pcd.height), cv::Vec3b(0, 0, 0));

    for(int y = 0; y < vis.rows; ++y) {
      for(int x = 0; x < vis.cols; ++x) {
        int idx = y * pcd.width + x;
        if(isnan(pcd[idx].x))
          continue;

        normalToColor(normals_->at(idx), &vis(y, x));
      }
    }

    cv::imwrite("debug/" + getRunName() + ".png", vis);

    pcl::PointCloud<pcl::PointXYZRGBNormal> cn;
    pcl::concatenateFields(pcd, *normals_, cn);
    if(!cn.empty())
      pcl::io::savePCDFileBinary("debug/" + getRunName() + ".pcd", cn);
    else { 
      int retval = system(("touch debug/" + getRunName() + ".pcd").c_str());
      --retval;
    }
  }
  void ForegroundKdTreeNode::_display() const
  {
    if(seg_otl_->pull().rows == 0)
      return;

    cout << "Previous foreground PCD has " << fg_pcd_->size() << " points." << endl;
    if(!fg_pcd_->empty())
      pcl::io::savePCDFileBinary("debug/" + getRunName() + ".pcd", *fg_pcd_);
    else { 
      int retval = system(("touch debug/" + getRunName() + ".pcd").c_str());
      --retval;
    }

  }
示例#3
0
void CPairTrade::onBrokerResponseArrived(
		BrkLib::BrokerConnect &brkConnect,
		BrkLib::BrokerResponseBase const& bresponse
)
{
	if (bresponse.type_m != BrkLib::RT_BrokerResponseOrder)
		return;

	MyBrokerContext const* myCtxPtr = (MyBrokerContext const*)bresponse.context_m.getContext();


	if (myCtxPtr != NULL) {
		// context is const but we want actually change this
		CppUtils::BaseAction<MachineContext>& action =  const_cast<CppUtils::BaseAction<MachineContext>&>(myCtxPtr->getAction());

		BrokerResponseRecipient* rp = dynamic_cast<BrokerResponseRecipient*>(&action);
		if (rp != NULL) {
			CppUtils::BaseAction<MachineContext>* action = dynamic_cast< CppUtils::BaseAction<MachineContext>* >(rp);

			LOG_COMMON( getRunName(), getRtdataProvider_Smartcom(), BrkLib::AP_MEDIUM, "Broker response delegated to: " << action->toString());
			rp->onCallbackReceived(brkConnect, bresponse);
		}
		else {																							 
			// unknown target
			LOG_COMMON( getRunName(), getRtdataProvider_Smartcom(), BrkLib::AP_MEDIUM, "Broker response delegated to default handler - unknown target");

			//LOG(MSG_INFO, "Check - Unknown target", "Check: \n" << bresponse.toString());

			BrokerResponseRecipient::onUnknownCallbackreceived(brkConnect, bresponse);
		}
		
	} else {
		// unknown target
		LOG_COMMON( getRunName(), getRtdataProvider_Smartcom(), BrkLib::AP_MEDIUM, "Broker response delegated to default handler - NULL context");

		//LOG(MSG_INFO, "Check - NULL context", "Check: \n" << bresponse.toString());

		BrokerResponseRecipient::onUnknownCallbackreceived(brkConnect, bresponse);
	}
}
示例#4
0
void CPairTrade::onEventArrived(
	Inqueue::ContextAccessor& contextaccessor, 
	HlpStruct::CallingContext& callContext,
	bool& result,
	CppUtils::String& customOutputData
)
{
		customOutputData = "FAILED";
		CppUtils::String const& command = callContext.getCallCustomName();

		CppUtils::String const& data = callContext.getParameter<BrkLib::String_Proxy>("custom_data").get();

		// parse as simple structure
		HlpStruct::XmlParameter xmlparam_data_v;
		HlpStruct::HumanSerializer::deserializeXmlParameter(data, xmlparam_data_v);


		HlpStruct::XmlParameter const& xmlparam_data = (HlpStruct::XmlParameter const&)xmlparam_data_v;
		if (command=="hallo") {
				
		}
		else if (command=="dump_symbol") {
			CppUtils::String const& symbol = xmlparam_data.getStringParameter("symbol");

			exportSymbol(contextaccessor, symbol);

			LOG_COMMON(connectRunName_m,getBarDataProvider_Smartcom(), BrkLib::AP_MEDIUM, "Symbol dumped");
		}  
		else if (command=="load_data") {
			bool loaded = contextaccessor.loadDataFromMaster(historyDataProfile_m, false);

			if (!loaded)
				THROW(CppUtils::OperationFailed, "exc_CannotLoadHistoryData", "ctx_onEventArrived", "");
			
		
			LOG_COMMON(connectRunName_m,getBarDataProvider_Smartcom(), BrkLib::AP_MEDIUM, "Loaded history OK ");
		}
		else if (command=="dump_cache") {
			// this command dump cache file to see what we have in memory
			CppUtils::String const& fileTmp = CppUtils::getTempPath() + "\\dump_" + CppUtils::createValidFileName(getRunName()) + "_" + CppUtils::long2String(CppUtils::getTime()) + ".txt";
			CppUtils::saveContentInFile2(fileTmp,  contextaccessor.makeDebugDump(true));
		}
		else if (command=="simulate_signal_up") {

		
			robot_m.simulateUp();
		}
		else if (command=="simulate_signal_down") {

		
			robot_m.simulateDown();
		}
		else if (command=="start_trade") {

			
			if ( xmlparam_data.isKeyExists("allowed_direction")) {
				CppUtils::String  direction = xmlparam_data.getParameter("allowed_direction").getAsString();
				CppUtils::toupper( direction );
				
				robot_m.getGlobalTradeContext().get().allowTrading_m = BrkLib::TD_NONE;

				if (direction == "SHORT") {
					robot_m.getGlobalTradeContext().get().allowTrading_m =  BrkLib::TD_SHORT;
				}
				else if (direction == "LONG") {
					robot_m.getGlobalTradeContext().get().allowTrading_m =  BrkLib::TD_LONG;
				}
				else if (direction == "BOTH") {
					robot_m.getGlobalTradeContext().get().allowTrading_m = BrkLib::TD_BOTH;
				}
				
			}

			if ( xmlparam_data.isKeyExists("current_position")) {
				CppUtils::String  direction = xmlparam_data.getParameter("current_position").getAsString();
				CppUtils::toupper( direction );
				
				if (direction == "SHORT") {
					robot_m.sendInitialEvent( BrkLib::TD_SHORT );
				}
				else if (direction == "LONG") {
					robot_m.sendInitialEvent( BrkLib::TD_LONG );
				}
				else if (direction == "NONE") {
					robot_m.sendInitialEvent( BrkLib::TD_NONE);
				}
				
			}

			
			
		}
		else if (command=="stop_trade") {
			robot_m.sendStopTradeEvent();
			LOG_COMMON(connectRunName_m,getBarDataProvider_Smartcom(), BrkLib::AP_MEDIUM, "Prohibited broker operations broker operations");

		}
		else
			THROW(CppUtils::OperationFailed, "exc_InvalidCommand", "ctx_onEventArrived", command);

		// no exceptions
		customOutputData ="Command: [" +command+ "] done OK";
}
示例#5
0
 void BoundaryMaskNode::_display() const
 {
   displayNodePotentials();
   cv::imwrite("debug/" + getRunName() + "-rough_mask.png", rough_mask_);
   cv::imwrite("debug/" + getRunName() + "-refined_mask.png", refined_mask_);
 }