當前位置: 首頁>>代碼示例>>Java>>正文


Java IoBuffer.putFloat方法代碼示例

本文整理匯總了Java中org.apache.mina.core.buffer.IoBuffer.putFloat方法的典型用法代碼示例。如果您正苦於以下問題:Java IoBuffer.putFloat方法的具體用法?Java IoBuffer.putFloat怎麽用?Java IoBuffer.putFloat使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.mina.core.buffer.IoBuffer的用法示例。


在下文中一共展示了IoBuffer.putFloat方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: encodeWriteRequest

import org.apache.mina.core.buffer.IoBuffer; //導入方法依賴的package包/類
private void encodeWriteRequest ( final IoBuffer data, final WriteRequestMessage message )
{
    data.putShort ( message.getIndex () );
    final Object value = message.getData ();
    if ( value == null )
    {
        data.put ( (byte)0x00 );
    }
    else if ( value instanceof Boolean )
    {
        data.put ( (byte)0x01 );
        data.put ( (byte) ( (Boolean)value ? 0xFF : 0x00 ) );
    }
    else if ( value instanceof Float || value instanceof Double )
    {
        data.put ( (byte)0x04 );
        data.putFloat ( ( (Number)value ).floatValue () );
    }
    else if ( value instanceof Long )
    {
        data.put ( (byte)0x03 );
        data.putLong ( ( (Number)value ).longValue () );
    }
    else if ( value instanceof Number )
    {
        data.put ( (byte)0x02 );
        data.putInt ( ( (Number)value ).intValue () );
    }
    else if ( value instanceof String )
    {
        data.put ( (byte)0x02 );
        data.putInt ( Integer.parseInt ( (String)value ) );
    }
    else
    {
        throw new RuntimeException ( String.format ( "Unable to write request of type %s", value.getClass () ) );
    }
}
 
開發者ID:eclipse,項目名稱:neoscada,代碼行數:39,代碼來源:ArduinoCodec.java

示例2: sendWriteFloatData

import org.apache.mina.core.buffer.IoBuffer; //導入方法依賴的package包/類
@SuppressWarnings ( "unused" )
private void sendWriteFloatData ()
{

    final float f = this.r.nextFloat ();

    logger.info ( "Sending float: {}", f );

    final DaveWriteRequest request = new DaveWriteRequest ();

    this.tix++;

    final IoBuffer data = IoBuffer.allocate ( 4 );
    data.putFloat ( f );
    data.flip ();
    request.addRequest ( new DaveWriteRequest.ByteRequest ( (byte)0x84, (short)1, (short)214, data ) );

    this.session.write ( request );
}
 
開發者ID:eclipse,項目名稱:neoscada,代碼行數:20,代碼來源:DaveHandler.java


注:本文中的org.apache.mina.core.buffer.IoBuffer.putFloat方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。