Exemplo n.º 1
0
char *DhcpOption123::toString() 
{
	size_t maxlen = 512;
	char *buffer = new char[maxlen];
	snprintf(buffer, maxlen, "Lat/long/alt: %f, %f, %f \nUncertainty: %d, %d, %d \nAltitudeType: %s\nDatum: %s", 
		latitude, longitude, altitude,
		latitudeUncertainty, longitudeUncertainty, altitudeUncertainty,
		getAltitudeType(),
		getDatum());
	return buffer;
}
Exemplo n.º 2
0
DWORD GIO_Read(DWORD hOpenContext, LPVOID pBuffer, DWORD Count)
{
	// depending on Single or Bulk mode, returns status of GPIO(s)[High/Low]
	DWORD value=~0;
	if(bulk_active)
	{
		for(int n=0;n<16;n++)
		{
			value |= ((getDatum(n)==1)?1:0)<<n;
		}
	}
	else
	{
		value=getDatum(active_port);
	}
	if(Count!=4)
	{
		DEBUGMSG(ZONE_ERROR, (TEXT("[GPIO] GPIO_Control: GPIO_Read needs four buffer bytes ( sizeof(DWORD) )\r\n")));
		return FALSE;
	}
	*(DWORD *)pBuffer =value;
	
	return TRUE;
}
Exemplo n.º 3
0
bool ScriptNode::makeDatum(std::string n, PyTypeObject* type,
                           std::string value, bool output)
{
    for (auto a : script.active)
        if (a->name == n)
            return false;

    // If there's an existing datum and it's of the wrong type, delete it.
    auto d = getDatum(n);
    if (d != NULL && (d->type != type))
    {
        datums.remove_if([&](const std::unique_ptr<Datum>& d_)
                         { return d_.get() == d; });
        d = NULL;
    }

    if (d == NULL)
    {
        d = new Datum(n, value, type, this);
        assert(d->isValid());
    }
    else
    {
        // Move the existing datum to the end of the list
        // (so that ordering matches ordering in the script)
        for (auto itr = datums.begin(); itr != datums.end(); ++itr)
            if (itr->get() == d)
            {
                datums.splice(datums.end(), datums, itr);
                break;
            }

        // If the datum is an output, update its expression
        if (output)
            d->setText(value);
        // Otherwise, erase the output sigil by setting the text
        else if (d->isOutput())
            d->setText(value);
    }

    script.active.insert(d);

    // Inject this variable into the script's namespace
    script.inject(n.c_str(), d->currentValue());
    saveLookup(n, &script);

    return true;
}
Exemplo n.º 4
0
void GuiGraphCtrl::onRender(Point2I offset, const RectI &updateRect)
{   
   if (mBlendSB.isNull())
   {
      GFXStateBlockDesc desc;

      desc.setBlend(true, GFXBlendSrcColor, GFXBlendInvSrcColor);
      mBlendSB = GFX->createStateBlock(desc);

      desc.setBlend(false, GFXBlendOne, GFXBlendZero);
      mSolidSB = GFX->createStateBlock(desc);

   }

   GFX->setStateBlock( mBlendSB );
   
	GFX->getDrawUtil()->drawRectFill( updateRect, mProfile->mFillColor );
   
   GFX->setStateBlock( mSolidSB );

   const Point2I globalPos = getGlobalBounds().point;
   const F32 midPointY = F32( globalPos.y ) + F32( getExtent().y ) * mCenterY;

	for( S32 k = 0; k < MaxPlots; ++ k )
	{
		// Check if there is an autoplot and the proper amount of time has passed, if so add datum.
		if( mAutoPlot[ k ] && mAutoPlotDelay[ k ] < (Sim::getCurrentTime() - mAutoPlotLastDisplay[ k ] ) )
		{
         mAutoPlotLastDisplay[ k ] = Sim::getCurrentTime();
         addDatum( k, Con::getFloatVariable( mAutoPlot[ k ] ) );
		}

		// Nothing to graph
		if( mGraphData[ k ].size() == 0 )
			continue;

		// Adjust scale to max value + 5% so we can see high values
		F32 Scale = F32( getExtent().y ) / F32( mGraphMax[ k ] * 1.05 );
      
      const S32 numSamples = mGraphData[ k ].size();

      switch( mGraphType[ k ] )
      {
         case Bar:
         {
            F32 prevOffset = 0;

            for( S32 sample = 0; sample < numSamples; ++ sample )
            {                  
               PrimBuild::begin( GFXTriangleFan, 4 );
               PrimBuild::color( mGraphColor[ k ] );

               F32 offset = F32( getExtent().x ) / F32( MaxDataPoints ) * F32( sample + 1 );

               PrimBuild::vertex2f( globalPos.x + prevOffset,
                  midPointY - ( getDatum( k, sample ) * Scale ) );

               PrimBuild::vertex2f( globalPos.x + offset,
                  midPointY - ( getDatum( k, sample ) * Scale ) );

               PrimBuild::vertex2f( globalPos.x + offset,
                  midPointY );

               PrimBuild::vertex2f( globalPos.x + prevOffset,
                  midPointY );

               prevOffset = offset;

               PrimBuild::end();
            }

            break;
         }
         
         case Filled:
         {
            PrimBuild::begin( GFXTriangleStrip, numSamples * 2 ); // Max size correct? -pw
            PrimBuild::color( mGraphColor[ k ] );

            for( S32 sample = 0; sample < numSamples; ++ sample )
            {
               F32 offset = F32( getExtent().x ) / F32( MaxDataPoints - 1 ) * F32( sample );

               PrimBuild::vertex2f( globalPos.x + offset,
                  midPointY );

               PrimBuild::vertex2f( globalPos.x + offset,
                  midPointY - ( getDatum( k, sample ) * Scale ) );
            }

            PrimBuild::end();
            break;
         }

         case Point:
         case Polyline:
         {
            if( mGraphType[ k ] == Point )
               PrimBuild::begin( GFXPointList, numSamples ); // Max size correct? -pw
            else
               PrimBuild::begin( GFXLineStrip, numSamples );

            PrimBuild::color( mGraphColor[ k ] );

            for( S32 sample = 0; sample < numSamples; ++ sample )
            {
               F32 offset = F32( getExtent().x ) / F32( MaxDataPoints - 1 ) * F32( sample );

               PrimBuild::vertex2f( globalPos.x + offset,
                  midPointY - ( getDatum( k, sample ) * Scale ) );
            }

            PrimBuild::end();
            break;
         }
      }
	}

	if( mProfile->mBorder )
	{
		RectI rect( offset.x, offset.y, getWidth(), getHeight() );
		GFX->getDrawUtil()->drawRect( rect, mProfile->mBorderColor );
	}
   
   renderChildControls( offset, updateRect );
}