public override void Marshal(DataOutputStream dos)
        {
            base.Marshal(dos);
            if (dos != null)
            {
                try
                {
                    this._designatingEntityID.Marshal(dos);
                    dos.WriteUnsignedShort((ushort)this._codeName);
                    this._designatedEntityID.Marshal(dos);
                    dos.WriteUnsignedShort((ushort)this._designatorCode);
                    dos.WriteFloat((float)this._designatorPower);
                    dos.WriteFloat((float)this._designatorWavelength);
                    this._designatorSpotWrtDesignated.Marshal(dos);
                    this._designatorSpotLocation.Marshal(dos);
                    dos.WriteByte((byte)this._deadReckoningAlgorithm);
                    dos.WriteUnsignedShort((ushort)this._padding1);
                    dos.WriteByte((byte)this._padding2);
                    this._entityLinearAcceleration.Marshal(dos);
                }
                catch (Exception e)
                {
#if DEBUG
                    Trace.WriteLine(e);
                    Trace.Flush();
#endif
                    this.OnException(e);
                }
            }
        }
示例#2
0
        public byte[] ToByteArray()
        {
            MemoryStream     byteArrayOutputStream = new MemoryStream();
            DataOutputStream outputStream          = new DataOutputStream(byteArrayOutputStream);

            outputStream.Write(RtpHeader.ToByteArray());

            byte midiCommandHeader1 = 0;

            midiCommandHeader1 |= (byte)((B ? 1 : 0) << 7);
            midiCommandHeader1 |= (byte)((J ? 1 : 0) << 6);
            midiCommandHeader1 |= (byte)((Z ? 1 : 0) << 5);
            midiCommandHeader1 |= (byte)((P ? 1 : 0) << 4);

            if (B)
            {
                midiCommandHeader1 |= (byte)((Length & 0x0F00) >> 8);
                outputStream.WriteByte(midiCommandHeader1);
                outputStream.WriteByte(Length & 0x00FF);
            }
            else
            {
                midiCommandHeader1 |= (byte)Length;
                outputStream.WriteByte(midiCommandHeader1);
            }

            outputStream.Flush();
            return(byteArrayOutputStream.ToArray());
        }
示例#3
0
        public byte[] ToByteArray()
        {
            MemoryStream     byteArrayOutputStream = new MemoryStream(12);
            DataOutputStream outputStream          = new DataOutputStream(byteArrayOutputStream);

            byte header1 = 0;

            header1 |= (byte)(Version << 6);
            header1 |= (byte)((PaddingFlag ? 1 : 0) << 5);
            header1 |= (byte)((ExtensionFlag ? 1 : 0) << 4);
            header1 |= ContributingSourceIdentifiersCount;

            outputStream.WriteByte(header1);

            byte header2 = 0;

            header2 |= (byte)((MarkerFlag ? 1 : 0) << 7);
            header2 |= PayloadType;

            outputStream.WriteByte(header2);

            outputStream.WriteShort(SequenceNumber);
            outputStream.WriteInt(Timestamp);
            outputStream.WriteInt(Ssrc);
            outputStream.Flush();
            return(byteArrayOutputStream.ToArray());
        }
示例#4
0
        public override void Marshal(DataOutputStream dos)
        {
            base.Marshal(dos);
            if (dos != null)
            {
                try
                {
                    this._emittingEntityID.Marshal(dos);
                    this._eventID.Marshal(dos);
                    dos.WriteByte((byte)this._stateChangeIndicator);
                    dos.WriteByte((byte)this._pad);
                    dos.WriteUnsignedShort((ushort)this._passiveParameterIndex);
                    dos.WriteUnsignedByte((byte)this._propulsionPlantConfiguration);
                    dos.WriteUnsignedByte((byte)this._shaftRPMs.Count);
                    dos.WriteUnsignedByte((byte)this._apaData.Count);
                    dos.WriteUnsignedByte((byte)this._emitterSystems.Count);

                    for (int idx = 0; idx < this._shaftRPMs.Count; idx++)
                    {
                        ShaftRPMs aShaftRPMs = (ShaftRPMs)this._shaftRPMs[idx];
                        aShaftRPMs.Marshal(dos);
                    }

                    for (int idx = 0; idx < this._apaData.Count; idx++)
                    {
                        ApaData aApaData = (ApaData)this._apaData[idx];
                        aApaData.Marshal(dos);
                    }

                    for (int idx = 0; idx < this._emitterSystems.Count; idx++)
                    {
                        AcousticEmitterSystemData aAcousticEmitterSystemData = (AcousticEmitterSystemData)this._emitterSystems[idx];
                        aAcousticEmitterSystemData.Marshal(dos);
                    }
                }
                catch (Exception e)
                {
                    if (PduBase.TraceExceptions)
                    {
                        Trace.WriteLine(e);
                        Trace.Flush();
                    }

                    this.RaiseExceptionOccured(e);

                    if (PduBase.ThrowExceptions)
                    {
                        throw e;
                    }
                }
            }
        }
示例#5
0
        public override void Marshal(DataOutputStream dos)
        {
            base.Marshal(dos);
            if (dos != null)
            {
                try
                {
                    this._entityID.Marshal(dos);
                    dos.WriteUnsignedByte((byte)this._forceId);
                    dos.WriteByte((byte)this._articulationParameters.Count);
                    this._entityType.Marshal(dos);
                    this._alternativeEntityType.Marshal(dos);
                    this._entityLinearVelocity.Marshal(dos);
                    this._entityLocation.Marshal(dos);
                    this._entityOrientation.Marshal(dos);
                    dos.WriteInt((int)this._entityAppearance);
                    this._deadReckoningParameters.Marshal(dos);

                    for (int idx = 0; idx < this._marking.Length; idx++)
                    {
                        dos.WriteByte(this._marking[idx]);
                    }

                    dos.WriteInt((int)this._capabilities);

                    for (int idx = 0; idx < this._articulationParameters.Count; idx++)
                    {
                        ArticulationParameter aArticulationParameter = (ArticulationParameter)this._articulationParameters[idx];
                        aArticulationParameter.Marshal(dos);
                    }
                }
                catch (Exception e)
                {
                    if (PduBase.TraceExceptions)
                    {
                        Trace.WriteLine(e);
                        Trace.Flush();
                    }

                    this.RaiseExceptionOccured(e);

                    if (PduBase.ThrowExceptions)
                    {
                        throw e;
                    }
                }
            }
        }
示例#6
0
        public override void Marshal(DataOutputStream dos)
        {
            base.Marshal(dos);
            if (dos != null)
            {
                try
                {
                    dos.WriteUnsignedShort((ushort)this._dataValues.Length);

                    dos.WriteByte(this._dataValues);
                }
                catch (Exception e)
                {
                    if (PduBase.TraceExceptions)
                    {
                        Trace.WriteLine(e);
                        Trace.Flush();
                    }

                    this.RaiseExceptionOccured(e);

                    if (PduBase.ThrowExceptions)
                    {
                        throw e;
                    }
                }
            }
        }
示例#7
0
        public override void Marshal(DataOutputStream dos)
        {
            base.Marshal(dos);
            if (dos != null)
            {
                try
                {
                    this._issuingEntityID.Marshal(dos);
                    this._collidingEntityID.Marshal(dos);
                    this._eventID.Marshal(dos);
                    dos.WriteUnsignedByte((byte)this._collisionType);
                    dos.WriteByte((byte)this._pad);
                    this._velocity.Marshal(dos);
                    dos.WriteFloat((float)this._mass);
                    this._location.Marshal(dos);
                }
                catch (Exception e)
                {
#if DEBUG
                    Trace.WriteLine(e);
                    Trace.Flush();
#endif
                    this.OnException(e);
                }
            }
        }
        public virtual void Marshal(DataOutputStream dos)
        {
            if (dos != null)
            {
                try
                {
                    dos.WriteUnsignedByte((byte)this._deadReckoningAlgorithm);

                    for (int idx = 0; idx < this._otherParameters.Length; idx++)
                    {
                        dos.WriteByte(this._otherParameters[idx]);
                    }
                    this._entityLinearAcceleration.Marshal(dos);
                    this._entityAngularVelocity.Marshal(dos);
                }
                catch (Exception e)
                {
#if DEBUG
                    Trace.WriteLine(e);
                    Trace.Flush();
#endif
                    this.OnException(e);
                }
            }
        }
示例#9
0
            /// <summary>Write an integer of this type to the given output stream</summary>
            /// <exception cref="System.IO.IOException"/>
            public void Write(DataOutputStream @out, int value)
            {
                switch (this)
                {
                case VectorMap.Itype.Int8:
                {
                    @out.WriteByte(value);
                    break;
                }

                case VectorMap.Itype.Int16:
                {
                    @out.WriteShort(value);
                    break;
                }

                case VectorMap.Itype.Int32:
                {
                    @out.WriteInt(value);
                    break;
                }

                default:
                {
                    throw new Exception("Unknown itype: " + this);
                }
                }
            }
        public override void Marshal(DataOutputStream dos)
        {
            base.Marshal(dos);
            if (dos != null)
            {
                try
                {
                    this._entityID.Marshal(dos);
                    dos.WriteUnsignedShort((ushort)this._communicationsDeviceID);
                    dos.WriteUnsignedShort((ushort)this._encodingScheme);
                    dos.WriteUnsignedShort((ushort)this._tdlType);
                    dos.WriteUnsignedInt((uint)this._sampleRate);
                    dos.WriteUnsignedShort((ushort)this._data.Length);
                    dos.WriteUnsignedShort((ushort)this._samples);

                    dos.WriteByte(this._data);
                }
                catch (Exception e)
                {
                    if (PduBase.TraceExceptions)
                    {
                        Trace.WriteLine(e);
                        Trace.Flush();
                    }

                    this.RaiseExceptionOccured(e);

                    if (PduBase.ThrowExceptions)
                    {
                        throw e;
                    }
                }
            }
        }
        public virtual void Marshal(DataOutputStream dos)
        {
            if (dos != null)
            {
                try
                {
                    this._beamDirection.Marshal(dos);
                    dos.WriteFloat((float)this._azimuthBeamwidth);
                    dos.WriteFloat((float)this._referenceSystem);
                    dos.WriteShort((short)this._padding1);
                    dos.WriteByte((byte)this._padding2);
                    dos.WriteFloat((float)this._ez);
                    dos.WriteFloat((float)this._ex);
                    dos.WriteFloat((float)this._phase);
                }
                catch (Exception e)
                {
                    if (PduBase.TraceExceptions)
                    {
                        Trace.WriteLine(e);
                        Trace.Flush();
                    }

                    this.RaiseExceptionOccured(e);

                    if (PduBase.ThrowExceptions)
                    {
                        throw e;
                    }
                }
            }
        }
示例#12
0
        public override void Marshal(DataOutputStream dos)
        {
            base.Marshal(dos);
            if (dos != null)
            {
                try
                {
                    this._receivingEntityID.Marshal(dos);
                    this._repairingEntityID.Marshal(dos);
                    dos.WriteUnsignedByte((byte)this._repairResult);
                    dos.WriteShort((short)this._padding1);
                    dos.WriteByte((byte)this._padding2);
                }
                catch (Exception e)
                {
                    if (PduBase.TraceExceptions)
                    {
                        Trace.WriteLine(e);
                        Trace.Flush();
                    }

                    this.RaiseExceptionOccured(e);

                    if (PduBase.ThrowExceptions)
                    {
                        throw e;
                    }
                }
            }
        }
示例#13
0
        public override void Marshal(DataOutputStream dos)
        {
            base.Marshal(dos);
            if (dos != null)
            {
                try
                {
                    this._entityID.Marshal(dos);
                    dos.WriteByte((byte)this._padding1);
                    dos.WriteUnsignedByte((byte)this._variableParameters.Count);
                    this._entityLinearVelocity.Marshal(dos);
                    this._entityLocation.Marshal(dos);
                    this._entityOrientation.Marshal(dos);
                    dos.WriteUnsignedInt((uint)this._entityAppearance);

                    for (int idx = 0; idx < this._variableParameters.Count; idx++)
                    {
                        VariableParameter aVariableParameter = (VariableParameter)this._variableParameters[idx];
                        aVariableParameter.Marshal(dos);
                    }
                }
                catch (Exception e)
                {
#if DEBUG
                    Trace.WriteLine(e);
                    Trace.Flush();
#endif
                    this.OnException(e);
                }
            }
        }
        public virtual void Marshal(DataOutputStream dos)
        {
            if (dos != null)
            {
                try
                {
                    this._beamDirection.Marshal(dos);
                    dos.WriteFloat((float)this._azimuthBeamwidth);
                    dos.WriteFloat((float)this._referenceSystem);
                    dos.WriteShort((short)this._padding1);
                    dos.WriteByte((byte)this._padding2);
                    dos.WriteFloat((float)this._ez);
                    dos.WriteFloat((float)this._ex);
                    dos.WriteFloat((float)this._phase);
                }
                catch (Exception e)
                {
#if DEBUG
                    Trace.WriteLine(e);
                    Trace.Flush();
#endif
                    this.OnException(e);
                }
            }
        }
        public virtual void Marshal(DataOutputStream dos)
        {
            if (dos != null)
            {
                try
                {
                    dos.WriteByte((byte)this._order);
                }
                catch (Exception e)
                {
                    if (PduBase.TraceExceptions)
                    {
                        Trace.WriteLine(e);
                        Trace.Flush();
                    }

                    this.RaiseExceptionOccured(e);

                    if (PduBase.ThrowExceptions)
                    {
                        throw e;
                    }
                }
            }
        }
        public virtual void Marshal(DataOutputStream dos)
        {
            if (dos != null)
            {
                try
                {
                    dos.WriteUnsignedByte((byte)this._deadReckoningAlgorithm);

                    for (int idx = 0; idx < this._otherParameters.Length; idx++)
                    {
                        dos.WriteByte(this._otherParameters[idx]);
                    }

                    this._entityLinearAcceleration.Marshal(dos);
                    this._entityAngularVelocity.Marshal(dos);
                }
                catch (Exception e)
                {
                    if (PduBase.TraceExceptions)
                    {
                        Trace.WriteLine(e);
                        Trace.Flush();
                    }

                    this.RaiseExceptionOccured(e);

                    if (PduBase.ThrowExceptions)
                    {
                        throw e;
                    }
                }
            }
        }
        public override void Marshal(DataOutputStream dos)
        {
            base.Marshal(dos);
            if (dos != null)
            {
                try
                {
                    this._receivingEntityID.Marshal(dos);
                    this._supplyingEntityID.Marshal(dos);
                    dos.WriteUnsignedByte((byte)this._supplies.Count);
                    dos.WriteShort((short)this._padding1);
                    dos.WriteByte((byte)this._padding2);

                    for (int idx = 0; idx < this._supplies.Count; idx++)
                    {
                        SupplyQuantity aSupplyQuantity = (SupplyQuantity)this._supplies[idx];
                        aSupplyQuantity.Marshal(dos);
                    }
                }
                catch (Exception e)
                {
#if DEBUG
                    Trace.WriteLine(e);
                    Trace.Flush();
#endif
                    this.OnException(e);
                }
            }
        }
示例#18
0
        public virtual void Marshal(DataOutputStream dos)
        {
            if (dos != null)
            {
                try
                {
                    for (int idx = 0; idx < this._otherParameters.Length; idx++)
                    {
                        dos.WriteByte(this._otherParameters[idx]);
                    }
                }
                catch (Exception e)
                {
                    if (PduBase.TraceExceptions)
                    {
                        Trace.WriteLine(e);
                        Trace.Flush();
                    }

                    this.RaiseExceptionOccured(e);

                    if (PduBase.ThrowExceptions)
                    {
                        throw e;
                    }
                }
            }
        }
示例#19
0
        public override void Marshal(DataOutputStream dos)
        {
            base.Marshal(dos);
            if (dos != null)
            {
                try
                {
                    this._issuingEntityID.Marshal(dos);
                    this._collidingEntityID.Marshal(dos);
                    this._eventID.Marshal(dos);
                    dos.WriteUnsignedByte((byte)this._collisionType);
                    dos.WriteByte((byte)this._pad);
                    this._velocity.Marshal(dos);
                    dos.WriteFloat((float)this._mass);
                    this._location.Marshal(dos);
                }
                catch (Exception e)
                {
                    if (PduBase.TraceExceptions)
                    {
                        Trace.WriteLine(e);
                        Trace.Flush();
                    }

                    this.RaiseExceptionOccured(e);

                    if (PduBase.ThrowExceptions)
                    {
                        throw e;
                    }
                }
            }
        }
示例#20
0
        public override void Marshal(DataOutputStream dos)
        {
            base.Marshal(dos);
            if (dos != null)
            {
                try
                {
                    this._originatingSimulationAddress.Marshal(dos);
                    dos.WriteInt((int)this._padding1);
                    dos.WriteShort((short)this._padding2);
                    dos.WriteUnsignedByte((byte)this._attributeRecordPduType);
                    dos.WriteUnsignedByte((byte)this._attributeRecordProtocolVersion);
                    dos.WriteUnsignedInt((uint)this._masterAttributeRecordType);
                    dos.WriteUnsignedByte((byte)this._actionCode);
                    dos.WriteByte((byte)this._padding3);
                    dos.WriteUnsignedShort((ushort)this._numberAttributeRecordSet);
                }
                catch (Exception e)
                {
#if DEBUG
                    Trace.WriteLine(e);
                    Trace.Flush();
#endif
                    this.OnException(e);
                }
            }
        }
示例#21
0
        public override void Marshal(DataOutputStream dos)
        {
            base.Marshal(dos);
            if (dos != null)
            {
                try
                {
                    this._entityID.Marshal(dos);
                    dos.WriteUnsignedShort((ushort)this._communicationsDeviceID);
                    dos.WriteUnsignedShort((ushort)this._encodingScheme);
                    dos.WriteUnsignedShort((ushort)this._tdlType);
                    dos.WriteUnsignedInt((uint)this._sampleRate);
                    dos.WriteUnsignedShort((ushort)this._data.Length);
                    dos.WriteUnsignedShort((ushort)this._samples);
                    dos.WriteByte(this._data);
                }
                catch (Exception e)
                {
#if DEBUG
                    Trace.WriteLine(e);
                    Trace.Flush();
#endif
                    this.OnException(e);
                }
            }
        }
示例#22
0
        public override void Marshal(DataOutputStream dos)
        {
            base.Marshal(dos);
            if (dos != null)
            {
                try
                {
                    dos.WriteUnsignedShort((ushort)this._encodingScheme);
                    dos.WriteUnsignedShort((ushort)this._tdlType);
                    dos.WriteUnsignedInt((uint)this._sampleRate);
                    dos.WriteShort((short)((this._dataLength == 0 && this._data.Length > 0) ? this._data.Length * 8 : this._dataLength)); //09062009 Post processed.  If value is zero then default to every byte will use all 8 bits
                    dos.WriteShort((short)this._samples);

                    dos.WriteByte(this._data);
                }
                catch (Exception e)
                {
                    if (PduBase.TraceExceptions)
                    {
                        Trace.WriteLine(e);
                        Trace.Flush();
                    }

                    this.RaiseExceptionOccured(e);

                    if (PduBase.ThrowExceptions)
                    {
                        throw e;
                    }
                }
            }
        }
示例#23
0
        public override void Marshal(DataOutputStream dos)
        {
            base.Marshal(dos);
            if (dos != null)
            {
                try
                {
                    this._emittingEntityID.Marshal(dos);
                    this._eventID.Marshal(dos);
                    dos.WriteByte((byte)this._stateChangeIndicator);
                    dos.WriteByte((byte)this._pad);
                    dos.WriteUnsignedShort((ushort)this._passiveParameterIndex);
                    dos.WriteUnsignedByte((byte)this._propulsionPlantConfiguration);
                    dos.WriteUnsignedByte((byte)this._shaftRPMs.Count);
                    dos.WriteUnsignedByte((byte)this._apaData.Count);
                    dos.WriteUnsignedByte((byte)this._emitterSystems.Count);

                    for (int idx = 0; idx < this._shaftRPMs.Count; idx++)
                    {
                        Vector3Float aVector3Float = (Vector3Float)this._shaftRPMs[idx];
                        aVector3Float.Marshal(dos);
                    }

                    for (int idx = 0; idx < this._apaData.Count; idx++)
                    {
                        Vector3Float aVector3Float = (Vector3Float)this._apaData[idx];
                        aVector3Float.Marshal(dos);
                    }

                    for (int idx = 0; idx < this._emitterSystems.Count; idx++)
                    {
                        Vector3Float aVector3Float = (Vector3Float)this._emitterSystems[idx];
                        aVector3Float.Marshal(dos);
                    }
                }
                catch (Exception e)
                {
#if DEBUG
                    Trace.WriteLine(e);
                    Trace.Flush();
#endif
                    this.OnException(e);
                }
            }
        }
示例#24
0
        public byte[] ToByteArray()
        {
            MemoryStream     byteArrayOutputStream = new MemoryStream();
            DataOutputStream outputStream          = new DataOutputStream(byteArrayOutputStream);

            outputStream.Write(MidiCommandHeader.ToByteArray());

            bool first = true;

            foreach (MidiTimestampPair message in Messages)
            {
                if (first && !MidiCommandHeader.Z)
                {
                    first = false;
                }
                else
                {
                    int timestamp = message.Timestamp;
                    if (timestamp > 0x0FFFFFFF)
                    {
                        throw new IllegalArgumentException("Timestamp too big: " + timestamp);
                    }
                    if (timestamp > 0)
                    {
                        int numberOfSeptets =
                            (int)System.Math.Ceiling(Integer.BitCount(Integer.HighestOneBit(timestamp) * 2 - 1) / 7.0);
                        while (numberOfSeptets > 0)
                        {
                            outputStream.WriteByte(
                                (numberOfSeptets > 1 ? 0x80 : 0) | ((timestamp >> ((numberOfSeptets - 1) * 7)) & 0x7F));
                            numberOfSeptets--;
                        }
                    }
                    else
                    {
                        outputStream.WriteByte(0);
                    }
                }
                outputStream.Write(message.MidiMessage.Data);
            }

            outputStream.Flush();
            return(byteArrayOutputStream.ToArray());
        }
        /// <exception cref="System.IO.IOException"/>
        private void WriteFile(FileSystem fileSys, Path name, int nBytesToWrite)
        {
            DataOutputStream @out = fileSys.Create(name);

            for (int i = 0; i < nBytesToWrite; ++i)
            {
                @out.WriteByte(0);
            }
            @out.Close();
        }
示例#26
0
 private static void WriteJavaField(this DataOutputStream stream, MetadataJavaField field)
 {
     stream.WriteUTF(field.Name);
     stream.WriteUTF(field.Type);
     stream.WriteAccessFlagsParameter(field.AccessFlags);
     stream.WriteBoolean(field.ConstantValue != null);
     if (field.ConstantValue != null)
     {
         stream.WriteArray(field.ConstantValue, b => stream.WriteByte(b));
     }
 }
示例#27
0
 public static void WriteByteArray(this DataOutputStream output, Byte[] value)
 {
     if (value == null)
     {
         throw new ArgumentNullException("value");
     }
     output.WriteInt32(value.Length);
     _byte2SByteMap.ByteArray = value;
     foreach (var item in _byte2SByteMap.SByteArray)
     {
         output.WriteByte(item);
     }
 }
        public byte[] ToByteArray()
        {
            MemoryStream     outputStream     = new MemoryStream();
            DataOutputStream dataOutputStream = new DataOutputStream(outputStream);

            dataOutputStream.Write(MIDI_COMMAND_HEADER1);
            dataOutputStream.Write(MIDI_COMMAND_HEADER2);
            dataOutputStream.Write(System.Text.Encoding.UTF8.GetBytes(CommandWord.ToString()));
            dataOutputStream.WriteInt(Ssrc);
            dataOutputStream.WriteByte(Count);
            dataOutputStream.Write(new byte[3]);
            dataOutputStream.WriteLong(Timestamp1);
            dataOutputStream.WriteLong(Timestamp2);
            dataOutputStream.WriteLong(Timestamp3);
            dataOutputStream.Flush();
            return(outputStream.ToArray());
        }
示例#29
0
        public virtual void Marshal(DataOutputStream dos)
        {
            if (dos != null)
            {
                try
                {
                    dos.WriteByte((byte)this._order);
                }
                catch (Exception e)
                {
#if DEBUG
                    Trace.WriteLine(e);
                    Trace.Flush();
#endif
                    this.OnException(e);
                }
            }
        }
示例#30
0
        public override void Marshal(DataOutputStream dos)
        {
            base.Marshal(dos);
            if (dos != null)
            {
                try
                {
                    dos.WriteUnsignedShort((ushort)this._dataValues.Length);
                    dos.WriteByte(this._dataValues);
                }
                catch (Exception e)
                {
#if DEBUG
                    Trace.WriteLine(e);
                    Trace.Flush();
#endif
                    this.OnException(e);
                }
            }
        }