Пример #1
0
void Converter::populateStates()
{
    static std::bitset<32> accessor = 1;
    static std::bitset<32> accepting = 0;
    
    for (auto s : this->original.getStates())
    {
        this->originalStates[s.first] = std::pair<State*, std::bitset<32> >(s.second, accessor);
        
        // if it is an accepting state, add the accessor position
        // to the accepting bitset and set its state to accepting
        if (s.second->isAccepting() == true)
        {
            accepting |= accessor;
        }
        
        accessor <<= 1; //bit shift by 1
    }
    
    this->totalStates = accessor.to_ulong();
    //total number of elements of the powerset is final offset - 1
    for (int i = 0; i < this->totalStates; i++)
    {        
        this->newStates[i] = new State(std::bitset<32>(i).to_string());
    
        //compare if any of the accepting bits is set
        std::bitset<32> check = accepting & std::bitset<32>(i);
        if (check.any())
        {
            this->newStates[i]->setAccepting(true);
        }
    }
}
Пример #2
0
//set operation mode of adc
	void Vflyspi_adc::configure( std::bitset<3> test_pattern ) {
	    // Testpatterns are:
	    // 000 Normal operation - <D13:D0> = ADC output
	    // 001 All zeros - <D13:D0> = 0x0000
	    // 010 All ones - <D13:D0> = 0x3FFF
	    // 011 Toggle pattern - <D13:D0> toggles between 0x2AAA and 0x1555
	    // 100 Digital ramp - <D13:D0> increments from 0x0000 to 0x3FFF by one code every cycle
	    // 101 Custom pattern - <D13:D0> = contents of CUSTOM PATTERN registers
	    // 110 Unused
	    // 111 Unused

	    Logger& log = Logger::instance();
	    log(Logger::DEBUG0) << "Setting ADC input to: " << test_pattern.to_string();

	    sp6data* buf = writeBlock(0,18);//just a large one
	    *(buf++) = ocpwrite | 0x3008; *(buf++) = 0x08; //start clock
	    *(buf++) = ocpwrite | 0x3008; *(buf++) = 0xe8; //release pdn and reset for adc, no start signal yet
	    *(buf++) = ocpwrite | 0x1c00; *(buf++) = 0x10; //software reset
	    *(buf++) = ocpwrite | 0x1c01; *(buf++) = 0x4; //enable lvds interface, disable clock
	//  ocp.write(0x1c00|(0xe<<3)|2,0x81); //7mA, 100Ohm
	    *(buf++) = ocpwrite | 0x1c00|(0xe<<3); *(buf++) = 0xc; //lowest power lvds is 0xc
	    *(buf++) = ocpwrite | 0x1c00|(0x4<<3)|0; *(buf++) = 0x0; //clock edge
	    *(buf++) = ocpwrite | 0x1c00|(0xb<<3)|1; *(buf++) = 0x54; //custom pattern 0x555 ->datablatt wrong!!!
	    *(buf++) = ocpwrite | 0x1c00|(0xc<<3)|0; *(buf++) = 0x05; //custom pattern 0x555 ->datablatt wrong!!!
	    *(buf++) = ocpwrite | 0x1c00|(0xa<<3)|4; *buf =test_pattern.to_ulong()<<5; //enable ramp test pattern with 0x80, custom with 0xa0
	    doWB();
	}
Пример #3
0
 void blendChannels(
   Texture* dest,
   std::bitset<4> mask,
   Texture* src,
   int ch, float blend)
 {
   _launchThreadsCh2Masked<_blendChannels>(ch, mask.to_ulong(), dest, src, blend);
 }
Пример #4
0
long bitset_to_long(const std::bitset<B>& b)
{
    struct
    {
long x:
        B;
    } s;
    return s.x = b.to_ulong();
}
Пример #5
0
 void _grayCode(std::vector<int> &ret, std::bitset<32> &bits, int pos) {
     if (pos == 0) {
         ret.push_back(static_cast<int>(bits.to_ulong()));
         return ;
     }
     _grayCode(ret, bits, n, pos - 1);
     bits.flip(pos - 1);
     _grayCode(ret, bits, n, pos - 1);
 }
Пример #6
0
 void fillWithRevBlendChannel(
   Texture* dest,
   std::bitset<4> mask,
   const Eigen::Array4f& color,
   Texture* blend_tex,
   int blend_ch)
 {
   _launchThreadsCh2Masked<_blendCwrA>
     (blend_ch, mask.to_ulong(), dest, blend_tex, std::ref(color));
 }
Пример #7
0
void makeDelaunay(Texture* tex,
                  std::vector<std::pair<double, double>>& point_set,
                  float range,
                  std::bitset<4> mask)
{
    //create the map
    Map map(tex->width * 2, tex->height * 2);
    std::vector<float> verts;
    verts.reserve(point_set.size() * 8);

    for(auto& point: point_set)
    {
        double x = point.first * tex->width;
        double y = point.second * tex->height;
        map.insertPoint(x, y);
        map.insertPoint(x + tex->width, y);
        map.insertPoint(x, y + tex->height);
        map.insertPoint(x + tex->width, y + tex->height);

        verts.push_back(x);
        verts.push_back(y);
        verts.push_back(x + tex->width);
        verts.push_back(y);
        verts.push_back(x);
        verts.push_back(y + tex->height);
        verts.push_back(x + tex->width);
        verts.push_back(y + tex->height);
    }

    Delaunay<float> del(verts);

    auto edges = del.triangulate().edges();

    for(unsigned i = 0; i < edges.size(); i += 2)
        _placeLine(&map,
                   verts[edges[i] * 2],
                   verts[edges[i] * 2 + 1],
                   verts[edges[i + 1] * 2],
                   verts[edges[i + 1] * 2 + 1]);

    map.generateDistances();

    if(range > 0)
        range *= tex->width < tex->height? tex->width : tex->height;
    else range = -range;

    _launchThreadsMasked<_writeSDFMap>(mask.to_ulong(), tex, std::move(map), range);
}
Пример #8
0
 //! Serializing (save) for std::bitset
 template <class Archive, size_t N> inline
 void save( Archive & ar, std::bitset<N> const & bits )
 {
   try
   {
     auto const b = bits.to_ulong();
     ar( _CEREAL_NVP("type", bitset_detail::type::ulong) );
     ar( _CEREAL_NVP("data", b) );
   }
   catch( std::overflow_error const & )
   {
     try
     {
       auto const b = bits.to_ullong();
       ar( _CEREAL_NVP("type", bitset_detail::type::ullong) );
       ar( _CEREAL_NVP("data", b) );
     }
     catch( std::overflow_error const & )
     {
       ar( _CEREAL_NVP("type", bitset_detail::type::string) );
       ar( _CEREAL_NVP("data", bits.to_string()) );
     }
   }
 }
//Sets address in the binary form
void IPAddress::setAddressAsBinary(std::bitset<32> ip_address)
{
	unsigned long int value = ip_address.to_ulong();
	setAddressAsUnsignedLongInt(value);
}
Пример #10
0
 void textureDiff(Texture* dest, Texture* src, std::bitset<4> mask)
 {
   _launchThreadsMasked<_diffTex>(mask.to_ulong(), dest, src);
 }
Пример #11
0
 void channelDiff(Texture* dest, Texture* src, int ch, std::bitset<4> mask)
 {
   _launchThreadsCh2Masked<_diffCh>(ch, mask.to_ulong(), dest, src);
 }
Пример #12
0
 void mergeTextures(Texture* dest, Texture* src, float blend, std::bitset<4> mask)
 {
   _launchThreadsMasked<_mergeTex>(mask.to_ulong(), dest, src, blend);
 }
Пример #13
0
 void blendTexturesWithAlpha(
   Texture* dest, Texture* src, std::bitset<4> mask, Texture* a_tex, int a_ch)
 {
   _launchThreadsCh2Masked<_blendTex>(a_ch, mask.to_ulong(), dest, src, a_tex);
 }
void N2MStandardPacket::set_mode(std::bitset<32> mode)
{
    std::lock_guard<std::mutex> packet_lock(packet_mtx);
    n2m_standard_packet.mode = mode.to_ulong();
}
Пример #15
0
void shrimp_gateway_impl::set_steer(short steer) {
    if (is_feasible_steer(steer)) {
        shrimp_command_t set_steer_command(STEER, write_t, static_cast <all::core::uint8_t> (steer));
        send_command(set_steer_command);
        //update_control_flags();
        //m_control_flags.set(0);
        //m_control_flags.set(1);
        shrimp_command_t update_steer_command(CONTROL_FLAGS, write_t, static_cast <all::core::uint8_t> (m_control_flags.to_ulong()));
        send_command(update_steer_command);
    }
    else
        printf("Steer out of range\n");
}
Пример #16
0
void shrimp_gateway_impl::enable_voltage_reading() {

    //update_control_flags();
    m_control_flags.set(6);

    shrimp_command_t enable_voltage(CONTROL_FLAGS, write_t, static_cast <all::core::uint8_t> (m_control_flags.to_ulong()));
    send_command(enable_voltage);
}