Ejemplo n.º 1
0
void LnkProperties::beamLnk()
{
    Ir ir;
    DocLnk doc( *((DocLnk *)lnk) );
    doc.setName(d->docname->text());
    reject();
    ir.send( doc, doc.comment() );
}
    virtual void constructMessageIr(Ir &ir)
    {
        Ir::TokenByteOrder byteOrder = Ir::SBE_LITTLE_ENDIAN;
        std::string messageStr = std::string("MessageWithUInt32Array");
        std::string charFieldStr = std::string("UInt32ArrayField");

        ir.addToken(0, UINT32_ARRAY_SIZE, Ir::BEGIN_MESSAGE, byteOrder, Ir::NONE, TEMPLATE_ID, messageStr);
        ir.addToken(0, 0, Ir::BEGIN_FIELD, byteOrder, Ir::NONE, FIELD_ID, charFieldStr);
        ir.addToken(0, UINT32_ARRAY_SIZE, Ir::ENCODING, byteOrder, Ir::UINT32, Ir::INVALID_ID, std::string("uint32"));
        ir.addToken(0, 0, Ir::END_FIELD, byteOrder, Ir::NONE, FIELD_ID, charFieldStr);
        ir.addToken(0, UINT32_ARRAY_SIZE, Ir::END_MESSAGE, byteOrder, Ir::NONE, TEMPLATE_ID, messageStr);
    };
    virtual void constructMessageIr(Ir &ir)
    {
        Ir::TokenByteOrder byteOrder = Ir::SBE_LITTLE_ENDIAN;
        std::string messageStr = std::string("MessageWithCharArray");
        std::string charFieldStr = std::string("CharArrayField");

        ir.addToken(0, STR_FIELD_VALUE_SIZE, Ir::BEGIN_MESSAGE, byteOrder, Ir::NONE, TEMPLATE_ID, messageStr);
        ir.addToken(0, 0, Ir::BEGIN_FIELD, byteOrder, Ir::NONE, FIELD_ID, charFieldStr);
        ir.addToken(0, STR_FIELD_VALUE_SIZE, Ir::ENCODING, byteOrder, Ir::CHAR, Ir::INVALID_ID, std::string("char"));
        ir.addToken(0, 0, Ir::END_FIELD, byteOrder, Ir::NONE, FIELD_ID, charFieldStr);
        ir.addToken(0, STR_FIELD_VALUE_SIZE, Ir::END_MESSAGE, byteOrder, Ir::NONE, TEMPLATE_ID, messageStr);
    };
Ejemplo n.º 4
0
void NotesControl::slotBeamButton()
{
    Ir ir;
    if(ir.supported()){
        this->hide();
        QString selectedText = m_notesList->currentText();
        if( !selectedText.isEmpty()) {
            QString file = QDir::homeDirPath() + "/" +selectedText;
            QFile f(file);
            Ir *irFile = new Ir(this, "IR");
            connect( irFile, SIGNAL(done(Ir*)), this, SLOT( slotBeamFinished(Ir*) ) );
            irFile->send( file, "Note", "text/plain" );
        }
    virtual void constructMessageIr(Ir &ir)
    {
        Ir::TokenByteOrder byteOrder = Ir::SBE_LITTLE_ENDIAN;
        std::string messageStr = std::string("MessageWithRepeatingGroup");
        std::string groupDimensionStr = std::string("groupSizeEncoding");
        std::string groupStr = std::string("GroupName");
        std::string fieldStr = std::string("FieldName");

        ir.addToken(0, 0xFFFFFFFF, Ir::BEGIN_MESSAGE, byteOrder, Ir::NONE, TEMPLATE_ID, messageStr);
        ir.addToken(0, 0, Ir::BEGIN_GROUP, byteOrder, Ir::NONE, GROUP_ID, groupStr);
        ir.addToken(0, 3, Ir::BEGIN_COMPOSITE, byteOrder, Ir::NONE, Ir::INVALID_ID, groupDimensionStr);
        ir.addToken(0, 2, Ir::ENCODING, byteOrder, Ir::UINT16, Ir::INVALID_ID, std::string("blockLength"));
        ir.addToken(2, 1, Ir::ENCODING, byteOrder, Ir::UINT8, Ir::INVALID_ID, std::string("numInGroup"));
        ir.addToken(0, 3, Ir::END_COMPOSITE, byteOrder, Ir::NONE, Ir::INVALID_ID, groupDimensionStr);
        ir.addToken(0, 0, Ir::BEGIN_FIELD, byteOrder, Ir::NONE, FIELD_ID, fieldStr);
        ir.addToken(0, 4, Ir::ENCODING, byteOrder, Ir::UINT32, Ir::INVALID_ID, std::string("uint32"));
        ir.addToken(0, 0, Ir::END_FIELD, byteOrder, Ir::NONE, FIELD_ID, fieldStr);
        ir.addToken(0, 0, Ir::END_GROUP, byteOrder, Ir::NONE, GROUP_ID, groupStr);
        ir.addToken(0, 0xFFFFFFFF, Ir::END_MESSAGE, byteOrder, Ir::NONE, TEMPLATE_ID, messageStr);
    };
Ejemplo n.º 6
0
// protected
int Listener::process(void)
{
    Ir *ir = ir_;

    stack_.push(messageFrame_);

    // consolidate the IR and the data buffer and invoke methods that represent events for a semantic
    // layer to coalesce for higher up
    for (; !ir->end(); ir->next())
    {
        //cout << "IR @ " << ir->position() << " " << ir->signal() << endl;
        //cout << "offsets " << bufferOffset_ << "/" << bufferLen_ << endl;
        if (bufferOffset_ > bufferLen_)
        {
            if (onError_ != NULL)
            {
                onError_->onError(Error("buffer too short"));
            }
            return -1;
        }

        // if group is empty, then skip to END_GROUP
        if (stack_.top().state_ == Frame::SKIP_TO_END_GROUP && ir->signal() != Ir::END_GROUP)
        {
            continue;
        }

        // overloaded method for encoding callback. 1 per primitiveType. Don't need type passed as method has typed value
        switch (ir->signal())
        {
        case Ir::BEGIN_MESSAGE:
            processBeginMessage(ir);
            break;

        case Ir::END_MESSAGE:
            processEndMessage();
            break;

        case Ir::BEGIN_COMPOSITE:
            processBeginComposite(ir);
            break;

        case Ir::END_COMPOSITE:
            processEndComposite();
            break;

        case Ir::BEGIN_FIELD:
            processBeginField(ir);
            break;

        case Ir::END_FIELD:
            processEndField();
            break;

        case Ir::BEGIN_ENUM:
            {
                updateBufferOffsetFromIr(ir);
                const char *valuePosition = buffer_ + bufferOffset_;

                switch (ir->primitiveType())
                {
                case Ir::CHAR:
                    bufferOffset_ += processBeginEnum(ir, *((char *)valuePosition));
                    break;

                case Ir::UINT8:
                    bufferOffset_ += processBeginEnum(ir, *((uint8_t *)valuePosition));
                    break;

                default:
                    break;
                }
                break;

            }
        case Ir::VALID_VALUE:
            processEnumValidValue(ir);
            break;

        case Ir::END_ENUM:
            processEndEnum();
            break;

        case Ir::BEGIN_SET:
            {
                updateBufferOffsetFromIr(ir);
                const char *valuePosition = buffer_ + bufferOffset_;

                switch (ir->primitiveType())
                {
                case Ir::UINT8:
                    bufferOffset_ += processBeginSet(ir, *((uint8_t *)valuePosition));
                    break;

                case Ir::UINT16:
                    bufferOffset_ += processBeginSet(ir, (uint64_t)BSWAP16(ir->byteOrder(), *((uint16_t *)valuePosition)));
                    break;

                case Ir::UINT32:
                    bufferOffset_ += processBeginSet(ir, (uint64_t)BSWAP32(ir->byteOrder(), *((uint32_t *)valuePosition)));
                    break;

                case Ir::UINT64:
                    bufferOffset_ += processBeginSet(ir, (uint64_t)BSWAP64(ir->byteOrder(), *((uint64_t *)valuePosition)));
                    break;

                default:
                    break;
                }
                break;
            }
        case Ir::CHOICE:
            processSetChoice(ir);
            break;

        case Ir::END_SET:
            processEndSet();
            break;

        case Ir::BEGIN_VAR_DATA:
            processBeginVarData(ir);
            break;

        case Ir::END_VAR_DATA:
            processEndVarData();
            break;

        case Ir::BEGIN_GROUP:
            processBeginGroup(ir);
            break;

        case Ir::END_GROUP:
            processEndGroup();
            break;

        case Ir::ENCODING:
            {
                updateBufferOffsetFromIr(ir);
                const char *valuePosition = buffer_ + bufferOffset_;
                const char *constVal = ir->constVal();
                int *calculatedOffset = &bufferOffset_;
                int constOffset;

                // use ir->constVal() for value if this token is a constant
                if (constVal != NULL)
                {
                    valuePosition = constVal;
                    calculatedOffset = &constOffset;  // use a dummy variable for offset as constant comes from IR
                }

                // if this is an array or variable size field (-1 size), or constant array then handle it
                if (ir->size() == -1 || ir->size() > Ir::size(ir->primitiveType()) || ir->constLen() > Ir::size(ir->primitiveType()))
                {
                    *calculatedOffset += processEncoding(ir, valuePosition,
                                                         (ir->size() < ir->constLen()) ? ir->constLen() : ir->size());
                    break;
                }

                // fall through to single items
                switch (ir->primitiveType())
                {
                case Ir::CHAR:
                    *calculatedOffset += processEncoding(ir, (int64_t)*((char *)(valuePosition)));
                    break;

                case Ir::INT8:
                    *calculatedOffset += processEncoding(ir, (int64_t)*((int8_t *)(valuePosition)));
                    break;

                case Ir::INT16:
                    *calculatedOffset += processEncoding(ir, (int64_t)((int16_t)BSWAP16(ir->byteOrder(), *((int16_t *)(valuePosition)))));
                    break;

                case Ir::INT32:
                    *calculatedOffset += processEncoding(ir, (int64_t)((int32_t)BSWAP32(ir->byteOrder(), *((int32_t *)(valuePosition)))));
                    break;

                case Ir::INT64:
                    *calculatedOffset += processEncoding(ir, (int64_t)((int64_t)BSWAP64(ir->byteOrder(), *((int64_t *)(valuePosition)))));
                    break;

                case Ir::UINT8:
                    *calculatedOffset += processEncoding(ir, (uint64_t)*((uint8_t *)(valuePosition)));
                    break;

                case Ir::UINT16:
                    *calculatedOffset += processEncoding(ir, (uint64_t)BSWAP16(ir->byteOrder(), *((uint16_t *)(valuePosition))));
                    break;

                case Ir::UINT32:
                    *calculatedOffset += processEncoding(ir, (uint64_t)BSWAP32(ir->byteOrder(), *((uint32_t *)(valuePosition))));
                    break;

                case Ir::UINT64:
                    *calculatedOffset += processEncoding(ir, (uint64_t)BSWAP64(ir->byteOrder(), *((uint64_t *)(valuePosition))));
                    break;

                case Ir::FLOAT:
                    *calculatedOffset += processEncoding(ir, (double)BSWAP32(ir->byteOrder(), *((float *)(valuePosition))));
                    break;

                case Ir::DOUBLE:
                    *calculatedOffset += processEncoding(ir, (double)BSWAP64(ir->byteOrder(), *((double *)(valuePosition))));
                    break;

                default:
                    break;
                }
                break;
            }
        default:
            break;
        }
    }

    if (onCompleted_ != NULL && irCallback_ == NULL)
    {
        onCompleted_->onCompleted();
    }
    return 0;
}
    virtual void constructMessageIr(Ir &ir)
    {
        Ir::TokenByteOrder byteOrder = Ir::SBE_LITTLE_ENDIAN;
        std::string messageStr = std::string("MessageWithVarData");
        std::string varDataStr1 = std::string("VarDataField1");
        std::string varDataStr2 = std::string("VarDataField2");
        std::string compositeStr1 = std::string("varDataEncodingChar");
        std::string compositeStr2 = std::string("varDataEncodingUInt8");

        ir.addToken(0, 0xFFFFFFFF, Ir::BEGIN_MESSAGE, byteOrder, Ir::NONE, TEMPLATE_ID, messageStr);
        ir.addToken(0, 0, Ir::BEGIN_VAR_DATA, byteOrder, Ir::NONE, FIELD_ID, varDataStr1);
        ir.addToken(0, 0, Ir::BEGIN_COMPOSITE, byteOrder, Ir::NONE, Field::INVALID_ID, compositeStr1);
        ir.addToken(0, 1, Ir::ENCODING, byteOrder, Ir::UINT8, Field::INVALID_ID, std::string("length"));
        ir.addToken(1, 0xFFFFFFFF, Ir::ENCODING, byteOrder, Ir::CHAR, Field::INVALID_ID, std::string("varData"));
        ir.addToken(0, 0, Ir::END_COMPOSITE, byteOrder, Ir::NONE, Field::INVALID_ID, compositeStr1);
        ir.addToken(0, 0, Ir::END_VAR_DATA, byteOrder, Ir::NONE, FIELD_ID, varDataStr1);
        ir.addToken(0, 0, Ir::BEGIN_VAR_DATA, byteOrder, Ir::NONE, FIELD_ID + 1, varDataStr2);
        ir.addToken(0, 0, Ir::BEGIN_COMPOSITE, byteOrder, Ir::NONE, Field::INVALID_ID, compositeStr2);
        ir.addToken(0xFFFFFFFF, 1, Ir::ENCODING, byteOrder, Ir::UINT8, Field::INVALID_ID, std::string("length"));
        ir.addToken(0xFFFFFFFF, 0xFFFFFFFF, Ir::ENCODING, byteOrder, Ir::UINT8, Field::INVALID_ID, std::string("varData"));
        ir.addToken(0, 0, Ir::END_COMPOSITE, byteOrder, Ir::NONE, Field::INVALID_ID, compositeStr2);
        ir.addToken(0, 0, Ir::END_VAR_DATA, byteOrder, Ir::NONE, FIELD_ID + 1, varDataStr2);
        ir.addToken(0, 0xFFFFFFFF, Ir::END_MESSAGE, byteOrder, Ir::NONE, TEMPLATE_ID, messageStr);
    };