GnString&
		operator=(gnsdk_cstr_t str)
		{
			set_(str);

			if (m_cstr_ref)
			{
				this->AcceptOwnership(GNSDK_NULL);
				m_cstr_ref = GNSDK_NULL;
			}
			return *this;
		}
		GnString&
		operator=(const GnString& str)
		{
			if (str.m_cstr_ref)
			{
				if (str.m_cstr_ref != m_cstr_ref)
				{
					GnObject::operator=(str);
					m_cstr_ref = str.m_cstr_ref;
					m_cstr = m_cstr_ref;

					delete[] m_str;
					m_str = GNSDK_NULL;
				}
			}
			else
			{
				set_(str.m_cstr);
			}
			return *this;
		}
Exemple #3
0
// Tokenizes the instruction part of the text command. If it corresponds to one of the supported
// instructions, like "add" or "remove", it searches for the next token (the sample name) in the
// list of samples and sends its buttonID to the relevant instruction function for further processing
void instructionControl(char *string_pointer) {
  char *buttonID = NULL;
  int instruction_to_execute;

  if (!string_pointer) {
    return;
  }

  instruction_to_execute = selectInstruction(string_pointer);

  string_pointer = strtok(NULL, " \n");

  if (string_pointer != NULL) {
    buttonID = findSampleInArray(string_pointer); //
  }

  switch(instruction_to_execute) {
    case ADD: add_(buttonID); break;
    case REMOVE: remove_(buttonID); break;
    case SET: set_(string_pointer); break;
    case STOP: stopAll_(); break;
  }
}
		/**
		 * Construct a GnString object from an existing GnString object
		 * @param str [in] GnString object
		 */
		GnString(const GnString& str) : GnObject(str), m_cstr_ref(str.m_cstr_ref), m_cstr(str.m_cstr_ref), m_str(GNSDK_NULL)
		{
			if (!str.m_cstr_ref)
				set_(str.m_str);
		}
Exemple #5
0
static P capture_( Pylon::CBaslerGigECamera& camera, Pylon::CBaslerGigECamera::StreamGrabber_t& grabber ) //static Pair capture( Ark::Robotics::Camera::Gige& camera )
{
    /// @todo if color spatial correction implemented, mind the following:
    ///
    /// Runner_Users_manual.pdf, 8.2.2.3:
    ///
    /// If you are using a color camera, you have spatial correction enabled
    /// and you have the frame start trigger mode set to off, you must discard
    /// the first n x 2 lines from the first frame transmitted by the camera
    /// after an acquisition start command is issued (where n is the absolute
    /// value of the current spatial correction parameter setting).
    ///
    /// If you have spatial correction enabled and you have the frame start
    /// trigger mode set to on, you must discard the first n x 2 lines from
    /// each frame transmitted by the camera.
    
    static const unsigned int retries = 10; // quick and dirty: arbitrary
    for( unsigned int i = 0; !done && i < retries; ++i )
    {
        Pylon::GrabResult result;
        //camera.AcquisitionStart.Execute(); // acquire single image (since acquisition mode set so)
        if( !grabber.GetWaitObject().Wait( timeout ) ) // quick and dirty: arbitrary timeout
        {
            std::cerr << "basler-cat: timeout" << std::endl;
            grabber.CancelGrab();
            while( grabber.RetrieveResult( result ) ); // get all buffers back
            if( is_shutdown ) { done = true; }
            return P();
        }
        boost::posix_time::ptime t = boost::get_system_time();
        grabber.RetrieveResult( result );
        if( !result.Succeeded() )
        { 
            std::cerr << "basler-cat: acquisition failed: " << result.GetErrorDescription() << " (" << result.GetErrorCode() << ")" << std::endl;
            std::cerr << "            status: " << ( result.Status() == Pylon::Idle ? "idle" :
                                                     result.Status() == Pylon::Queued ? "queued" :
                                                     result.Status() == Pylon::Grabbed ? "grabbed" :
                                                     result.Status() == Pylon::Canceled ? "canceled" :
                                                     result.Status() == Pylon::Failed ? "failed" : "unknown" ) << std::endl;
            std::cerr << "            run basler-cat --verbose and check your --packet-size settings" << std::endl;
            continue;
        }
        P pair;
        static const snark::cv_mat::serialization::header header = options.get_header();
        switch( header.type )
        {
            case CV_8UC1:
                pair.second = cv::Mat( result.GetSizeY(), result.GetSizeX(), header.type );
                ::memcpy( pair.second.data, reinterpret_cast< const char* >( result.Buffer() ), pair.second.dataend - pair.second.datastart );
                break;
            case CV_8UC3: // quick and dirty for now: rgb are not contiguous in basler camera frame
                pair.second = cv::Mat( result.GetSizeY(), result.GetSizeX(), header.type );
                ::memcpy( pair.second.data, reinterpret_cast< const char* >( result.Buffer() ), pair.second.dataend - pair.second.datastart );
                cv::cvtColor( pair.second, pair.second, CV_RGB2BGR );
                break;
            default: // quick and dirty for now
                std::cerr << "basler-cat: cv::mat type " << options.type << " not supported" << std::endl;
        }            
        set_( pair.first, t, result, camera );
        grabber.QueueBuffer( result.Handle(), NULL ); // requeue buffer
        if( is_shutdown ) { done = true; }
        return pair;
    }
    if( is_shutdown ) { done = true; }
    return P();
}
		/**
		 * Construct a GnString object from a native constant string
		 * @param str [in] Native string
		 */
		GnString(gnsdk_cstr_t str) : m_cstr_ref(GNSDK_NULL), m_cstr(GNSDK_NULL), m_str(GNSDK_NULL) { set_(str); }
 .def("__lshift__",
     static_cast<boost::dynamic_bitset<> (boost::dynamic_bitset<>::*)(
         const boost::dynamic_bitset<>::size_type
     ) const>(&boost::dynamic_bitset<>::operator<<)
 )
 .def("__rshift__",
     static_cast<boost::dynamic_bitset<> (boost::dynamic_bitset<>::*)(
         const boost::dynamic_bitset<>::size_type
     ) const>(&boost::dynamic_bitset<>::operator>>)
 )
 .def("set",
     static_cast<boost::dynamic_bitset<> &(boost::dynamic_bitset<>::*)(
         boost::dynamic_bitset<>::size_type, bool
     )>(&boost::dynamic_bitset<>::set),
     py::return_internal_reference<>(),
     set_()
 )
 .def("reset",
     static_cast<boost::dynamic_bitset<> &(boost::dynamic_bitset<>::*)(
         boost::dynamic_bitset<>::size_type
     )>(&boost::dynamic_bitset<>::reset),
     py::return_internal_reference<>(),
     reset_()
 )
 .def("flip",
     static_cast<boost::dynamic_bitset<> &(boost::dynamic_bitset<>::*)(
         boost::dynamic_bitset<>::size_type
     )>(&boost::dynamic_bitset<>::flip),
     py::return_internal_reference<>(),
     flip_()
 )
static Tensor new_with_storage(const Type& type, Storage& storage) {
  auto tensor = type.tensor();
  tensor.set_(storage);
  return tensor;
}
Exemple #9
0
		//-----------------------------------------------------------------//
		static void turn(peripheral t, bool ena = true)
		{
			device::SYSTEM::PRCR = 0xA500 | device::SYSTEM::PRCR.PRC1.b();

			bool f = !ena;
			switch(t) {
			case peripheral::TMR6:
			case peripheral::TMR7:
				SYSTEM::MSTPCRA.MSTPA2 = f;
				break;
			case peripheral::TMR4:
			case peripheral::TMR5:
				SYSTEM::MSTPCRA.MSTPA3 = f;
				break;
			case peripheral::TMR3:
			case peripheral::TMR2:
				SYSTEM::MSTPCRA.MSTPA4 = f;
				break;
			case peripheral::TMR1:
			case peripheral::TMR0:
				SYSTEM::MSTPCRA.MSTPA5 = f;
				break;

			case peripheral::HRPWM:
				SYSTEM::MSTPCRA.MSTPA7 = f;
				break;

			case peripheral::MTU0:
			case peripheral::MTU1:
			case peripheral::MTU2:
			case peripheral::MTU3:
			case peripheral::MTU4:
			case peripheral::MTU5:
			case peripheral::MTU6:
			case peripheral::MTU7:
				SYSTEM::MSTPCRA.MSTPA9 = f;
				break;

			case peripheral::CMT0:
			case peripheral::CMT1:
				// CMT0, CMT1 のストップ状態設定
				set_(ena, STH::st.cmt_, peripheral::CMT0, t);
				SYSTEM::MSTPCRA.MSTPA15 = ((STH::st.cmt_ & 0b0011) == 0);
				break;
			case peripheral::CMT2:
			case peripheral::CMT3:
				// CMT2, CMT3 のストップ状態設定
				set_(ena, STH::st.cmt_, peripheral::CMT0, t);
				SYSTEM::MSTPCRA.MSTPA14 = ((STH::st.cmt_ & 0b1100) == 0);
				break;

			case peripheral::S12AD1:
				SYSTEM::MSTPCRA.MSTPA16 = f;	// S12AD1 のストップ状態解除
				break;
			case peripheral::S12AD:
				SYSTEM::MSTPCRA.MSTPA17 = f;	// S12AD のストップ状態解除
				break;

			case peripheral::R12DA:
				SYSTEM::MSTPCRA.MSTPA19 = f;	// R12DA のストップ状態解除
				break;
			case peripheral::S12AD2:
				SYSTEM::MSTPCRA.MSTPA23 = f;	// S12AD2 のストップ状態解除
				break;

			case peripheral::DMAC0:
			case peripheral::DMAC1:
			case peripheral::DMAC2:
			case peripheral::DMAC3:
			case peripheral::DMAC4:
			case peripheral::DMAC5:
			case peripheral::DMAC6:
			case peripheral::DMAC7:
			case peripheral::DTC:
				SYSTEM::MSTPCRA.MSTPA28 = f;	// DMAC/DTC のストップ状態解除
				break;

			case peripheral::CAN0:
				SYSTEM::MSTPCRB.MSTPB0 = f;		// CAN のストップ状態解除
				break;

			case peripheral::SCI12:
				SYSTEM::MSTPCRB.MSTPB4 = f;		// SCI12 のストップ状態解除
				break;

			case peripheral::DOC:
				SYSTEM::MSTPCRB.MSTPB6 = f;		// DOC のストップ状態解除
				break;

			case peripheral::ELC:
				SYSTEM::MSTPCRB.MSTPB9 = f;		// ELC のストップ状態解除
				break;

			case peripheral::CMPC0:
			case peripheral::CMPC1:
			case peripheral::CMPC2:
			case peripheral::CMPC3:
			case peripheral::CMPC4:
			case peripheral::CMPC5:
				SYSTEM::MSTPCRB.MSTPB10 = f;	// CMPCx のストップ状態解除
				break;

			case peripheral::RSPI0:
				SYSTEM::MSTPCRB.MSTPB17 = f;	// RSPI0 のストップ状態解除
				break;

			case peripheral::USB0:
				SYSTEM::MSTPCRB.MSTPB19 = f;	// USB0 のストップ状態解除
				break;

			case peripheral::RIIC0:
				SYSTEM::MSTPCRB.MSTPB21 = f;	// RIIC0 のストップ状態解除
				break;

			case peripheral::CRC:
				SYSTEM::MSTPCRB.MSTPB23 = f;	// CRC のストップ状態解除
				break;

			case peripheral::SCI6:
				SYSTEM::MSTPCRB.MSTPB25 = f;	// SCI6 のストップ状態解除
				break;
			case peripheral::SCI5:
				SYSTEM::MSTPCRB.MSTPB26 = f;	// SCI5 のストップ状態解除
				break;
			case peripheral::SCI1:
				SYSTEM::MSTPCRB.MSTPB30 = f;	// SCI1 のストップ状態解除
				break;

			case peripheral::SCI11:
				SYSTEM::MSTPCRC.MSTPC24 = f;	// SCI11 のストップ状態解除
				break;

			case peripheral::SCI9:
				SYSTEM::MSTPCRC.MSTPC26 = f;	// SCI9 のストップ状態解除
				break;
			case peripheral::SCI8:
				SYSTEM::MSTPCRC.MSTPC27 = f;	// SCI8 のストップ状態解除
				break;

			default:
				break;
			}
			device::SYSTEM::PRCR = 0xA500;
		}
Exemple #10
0
	void CsvSerializer::set(const double &data, const Field &field) { set_(data, field); }
Exemple #11
0
	void CsvSerializer::set(const float &data, const Field &field) { set_(data, field); }
Exemple #12
0
	void CsvSerializer::set(const boost::uint64_t &data, const Field &field) { set_(data, field); }
Exemple #13
0
	void CsvSerializer::set(const std::string &data, const Field &field) { set_(data, field); }