예제 #1
0
        public uint ToBytes(WriteStream stream)
        {
            uint size = 5;
            var  span = stream.Advance(4);

            stream.WriteByte(4);
            size += stream.WriteHeader(EventPropertyType.L_Date, 1);
            size += stream.WriteHeader(EventPropertyType.L_32, 1);
            size += stream.WriteHeader(EventPropertyType.L_64, 3);
            size += stream.WriteHeader(EventPropertyType.L_Str, 5);
            size += stream.WriteIndex(7);
            size += stream.WriteDate(TradeTime);
            size += stream.WriteIndex(9);
            size += stream.WriteInt32(ZCVolume);
            size += stream.WriteIndex(3);
            size += stream.WriteDouble(LastPrice);
            size += stream.WriteIndex(6);
            size += stream.WriteUInt64(TotalVolume);
            size += stream.WriteIndex(8);
            size += stream.WriteUInt64(Volume);
            size += stream.WriteIndex(0);
            size += stream.WriteString(CommodityNo);
            size += stream.WriteIndex(1);
            size += stream.WriteString(ExchangeID);
            size += stream.WriteIndex(2);
            size += stream.WriteString(InstrumentID);
            size += stream.WriteIndex(4);
            size += stream.WriteString(Oper);
            size += stream.WriteIndex(5);
            size += stream.WriteString(InTime);
            BitConverter.TryWriteBytes(span, size);
            return(size);
        }
        public void Write(WriteStream stream, StreamContext context)
        {
            if (context.fullModel)
            {
                // Write all properties
                stream.WriteString((uint)PropertyID.Name, _name);
                stream.WriteVarint32((uint)PropertyID.Pointer, _pointer ? 1u : 0u);
            }
            else
            {
                // Reliable properties
                if (context.reliableChannel)
                {
                    LocalCacheEntry entry = _cache.localCache;
                    if (entry.nameSet || entry.pointerSet)
                    {
                        _cache.PushLocalCacheToInflight(context.updateID);
                    }

                    if (entry.nameSet)
                    {
                        stream.WriteString((uint)PropertyID.Name, entry.name);
                    }
                    if (entry.pointerSet)
                    {
                        stream.WriteVarint32((uint)PropertyID.Pointer, entry.pointer ? 1u : 0u);
                    }
                }
            }
        }
        protected override void Write(WriteStream stream, StreamContext context)
        {
            var didWriteProperties = false;

            if (context.fullModel)
            {
                stream.WriteVarint32((uint)PropertyID.DeviceType, (uint)_deviceType);
                stream.WriteString((uint)PropertyID.DeviceModel, _deviceModel);
                stream.WriteVarint32((uint)PropertyID.HeadActive, _headActive ? 1u : 0u);
                stream.WriteVarint32((uint)PropertyID.LeftHandActive, _leftHandActive ? 1u : 0u);
                stream.WriteVarint32((uint)PropertyID.RightHandActive, _rightHandActive ? 1u : 0u);
            }
            else if (context.reliableChannel)
            {
                LocalCacheEntry entry = _cache.localCache;
                if (entry.deviceTypeSet || entry.deviceModelSet || entry.headActiveSet || entry.leftHandActiveSet || entry.rightHandActiveSet)
                {
                    _cache.PushLocalCacheToInflight(context.updateID);
                    ClearCacheOnStreamCallback(context);
                }
                if (entry.deviceTypeSet)
                {
                    stream.WriteVarint32((uint)PropertyID.DeviceType, (uint)entry.deviceType);
                    didWriteProperties = true;
                }
                if (entry.deviceModelSet)
                {
                    stream.WriteString((uint)PropertyID.DeviceModel, entry.deviceModel);
                    didWriteProperties = true;
                }
                if (entry.headActiveSet)
                {
                    stream.WriteVarint32((uint)PropertyID.HeadActive, entry.headActive ? 1u : 0u);
                    didWriteProperties = true;
                }
                if (entry.leftHandActiveSet)
                {
                    stream.WriteVarint32((uint)PropertyID.LeftHandActive, entry.leftHandActive ? 1u : 0u);
                    didWriteProperties = true;
                }
                if (entry.rightHandActiveSet)
                {
                    stream.WriteVarint32((uint)PropertyID.RightHandActive, entry.rightHandActive ? 1u : 0u);
                    didWriteProperties = true;
                }

                if (didWriteProperties)
                {
                    InvalidateReliableLength();
                }
            }
        }
예제 #4
0
        public uint ToBytes(ref WriteStream stream)
        {
            uint size = 5;
            var  span = stream.Advance(4);

            stream.WriteByte(1);
            size += stream.WriteHeader(EventPropertyType.L_Str, 2);
            size += stream.WriteIndex(0);
            size += stream.WriteString(ExchangeNo);
            size += stream.WriteIndex(1);
            size += stream.WriteString(ExchangeName);
            BitConverter.TryWriteBytes(span, size);
            return(size);
        }
        public void Write(WriteStream stream, StreamContext context)
        {
            // Meta model
            stream.WriteModel(0, _metaModel, context);

            if (context.fullModel)
            {
                // Write all properties
                if (_sceneViewUUID != null && _sceneViewUUID.Length > 0)
                {
                    stream.WriteBytes((uint)PropertyID.SceneViewUUID, _sceneViewUUID);
                }
                if (_prefabName != null && _prefabName.Length > 0)
                {
                    stream.WriteString((uint)PropertyID.PrefabName, _prefabName);
                }
            }

            // Components
            if (_componentsModel != null)
            {
                stream.WriteModel((uint)PropertyID.Components, _componentsModel, context);
            }

            // Child Views
            if (_childViewsModel != null)
            {
                stream.WriteModel((uint)PropertyID.ChildViews, _childViewsModel, context);
            }
        }
예제 #6
0
        public uint ToBytes(WriteStream stream)
        {
            uint size = 5;
            var  span = stream.Advance(4);

            stream.WriteByte(3);
            size += stream.WriteHeader(EventPropertyType.L_32, 1);
            size += stream.WriteHeader(EventPropertyType.L_64, 2);
            size += stream.WriteHeader(EventPropertyType.L_Str, 7);
            size += stream.WriteIndex(1);
            size += stream.WriteInt32((int)CommodityType);
            size += stream.WriteIndex(4);
            size += stream.WriteDouble(MarginValue);
            size += stream.WriteIndex(5);
            size += stream.WriteDouble(FreeValue);
            size += stream.WriteIndex(0);
            size += stream.WriteString(ExchangeNo);
            size += stream.WriteIndex(2);
            size += stream.WriteString(CommodityNo);
            size += stream.WriteIndex(3);
            size += stream.WriteString(InstrumentID);
            size += stream.WriteIndex(6);
            size += stream.WriteString(ContractExpDate);
            size += stream.WriteIndex(7);
            size += stream.WriteString(LastTradeDate);
            size += stream.WriteIndex(8);
            size += stream.WriteString(FirstNoticeDate);
            size += stream.WriteIndex(9);
            size += stream.WriteString(ContractName);
            BitConverter.TryWriteBytes(span, size);
            return(size);
        }
예제 #7
0
        public uint ToBytes(WriteStream stream)
        {
            uint size = 5;
            var  span = stream.Advance(4);

            stream.WriteByte(1);
            size += stream.WriteHeader(EventPropertyType.L_Str, 4);
            size += stream.WriteIndex(0);
            size += stream.WriteString(AccountNo);
            size += stream.WriteIndex(1);
            size += stream.WriteString(Password);
            size += stream.WriteIndex(2);
            size += stream.WriteString(Address);
            size += stream.WriteIndex(3);
            size += stream.WriteString(CoreName);
            BitConverter.TryWriteBytes(span, size);
            return(size);
        }
예제 #8
0
        public uint ToBytes(WriteStream stream)
        {
            uint size = 5;
            var  span = stream.Advance(4);

            stream.WriteByte(3);
            size += stream.WriteHeader(EventPropertyType.L_32, 6);
            size += stream.WriteHeader(EventPropertyType.L_64, 3);
            size += stream.WriteHeader(EventPropertyType.L_Str, 7);
            size += stream.WriteIndex(2);
            size += stream.WriteInt32((int)CommodityType);
            size += stream.WriteIndex(6);
            size += stream.WriteInt32((int)TradeCurrency);
            size += stream.WriteIndex(10);
            size += stream.WriteInt32(MarketDot);
            size += stream.WriteIndex(11);
            size += stream.WriteInt32(CommodityDenominator);
            size += stream.WriteIndex(12);
            size += stream.WriteInt32(DeliveryDays);
            size += stream.WriteIndex(14);
            size += stream.WriteInt32(CommodityTimeZone);
            size += stream.WriteIndex(7);
            size += stream.WriteDouble(ContractSize);
            size += stream.WriteIndex(8);
            size += stream.WriteDouble(StrikePriceTimes);
            size += stream.WriteIndex(9);
            size += stream.WriteDouble(CommodityTickSize);
            size += stream.WriteIndex(0);
            size += stream.WriteString(ExchangeNo);
            size += stream.WriteIndex(1);
            size += stream.WriteString(ExchangeName);
            size += stream.WriteIndex(3);
            size += stream.WriteString(CommodityNo);
            size += stream.WriteIndex(4);
            size += stream.WriteString(CommodityName);
            size += stream.WriteIndex(5);
            size += stream.WriteString(CommodityEngName);
            size += stream.WriteIndex(13);
            size += stream.WriteString(AddOneTime);
            size += stream.WriteIndex(15);
            size += stream.WriteString(AllowTradeTime);
            BitConverter.TryWriteBytes(span, size);
            return(size);
        }
예제 #9
0
        public uint ToBytes(ref WriteStream stream)
        {
            uint size = 5;
            var  span = stream.Advance(4);

            stream.WriteByte(4);
            size += stream.WriteHeader(EventPropertyType.L_Date, 3);
            size += stream.WriteHeader(EventPropertyType.L_32, 2);
            size += stream.WriteHeader(EventPropertyType.L_64, 53);
            size += stream.WriteHeader(EventPropertyType.L_Str, 6);
            size += stream.WriteIndex(44);
            size += stream.WriteDate(LocalTime);
            size += stream.WriteIndex(60);
            size += stream.WriteDate(InTime);
            size += stream.WriteIndex(62);
            size += stream.WriteDate(TradingDay);
            size += stream.WriteIndex(24);
            size += stream.WriteInt32((int)CommodityType);
            size += stream.WriteIndex(49);
            size += stream.WriteInt32((int)TradingState);
            size += stream.WriteIndex(1);
            size += stream.WriteDouble(AskPrice1);
            size += stream.WriteIndex(2);
            size += stream.WriteDouble(AskPrice2);
            size += stream.WriteIndex(3);
            size += stream.WriteDouble(AskPrice3);
            size += stream.WriteIndex(4);
            size += stream.WriteDouble(AskPrice4);
            size += stream.WriteIndex(5);
            size += stream.WriteDouble(AskPrice5);
            size += stream.WriteIndex(6);
            size += stream.WriteUInt64(AskVolume1);
            size += stream.WriteIndex(7);
            size += stream.WriteUInt64(AskVolume2);
            size += stream.WriteIndex(8);
            size += stream.WriteUInt64(AskVolume3);
            size += stream.WriteIndex(9);
            size += stream.WriteUInt64(AskVolume4);
            size += stream.WriteIndex(10);
            size += stream.WriteUInt64(AskVolume5);
            size += stream.WriteIndex(11);
            size += stream.WriteDouble(AveragePrice);
            size += stream.WriteIndex(12);
            size += stream.WriteDouble(BidPrice1);
            size += stream.WriteIndex(13);
            size += stream.WriteDouble(BidPrice2);
            size += stream.WriteIndex(14);
            size += stream.WriteDouble(BidPrice3);
            size += stream.WriteIndex(15);
            size += stream.WriteDouble(BidPrice4);
            size += stream.WriteIndex(16);
            size += stream.WriteDouble(BidPrice5);
            size += stream.WriteIndex(17);
            size += stream.WriteUInt64(BidVolume1);
            size += stream.WriteIndex(18);
            size += stream.WriteUInt64(BidVolume2);
            size += stream.WriteIndex(19);
            size += stream.WriteUInt64(BidVolume3);
            size += stream.WriteIndex(20);
            size += stream.WriteUInt64(BidVolume4);
            size += stream.WriteIndex(21);
            size += stream.WriteUInt64(BidVolume5);
            size += stream.WriteIndex(22);
            size += stream.WriteDouble(ClosePrice);
            size += stream.WriteIndex(26);
            size += stream.WriteDouble(HighestPrice);
            size += stream.WriteIndex(27);
            size += stream.WriteDouble(HisHighPrice);
            size += stream.WriteIndex(28);
            size += stream.WriteDouble(HisLowPrice);
            size += stream.WriteIndex(30);
            size += stream.WriteDouble(LastPrice);
            size += stream.WriteIndex(31);
            size += stream.WriteUInt64(ImpliedBidQty);
            size += stream.WriteIndex(32);
            size += stream.WriteDouble(LowestPrice);
            size += stream.WriteIndex(33);
            size += stream.WriteUInt64(OpenInterest);
            size += stream.WriteIndex(34);
            size += stream.WriteDouble(OpenPrice);
            size += stream.WriteIndex(35);
            size += stream.WriteDouble(PreClosePrice);
            size += stream.WriteIndex(36);
            size += stream.WriteDouble(PreDelta);
            size += stream.WriteIndex(37);
            size += stream.WriteDouble(CurrDelta);
            size += stream.WriteIndex(38);
            size += stream.WriteDouble(TurnoverRate);
            size += stream.WriteIndex(39);
            size += stream.WriteUInt64(PreOpenInterest);
            size += stream.WriteIndex(40);
            size += stream.WriteDouble(PreSettlementPrice);
            size += stream.WriteIndex(41);
            size += stream.WriteDouble(SettlementPrice);
            size += stream.WriteIndex(42);
            size += stream.WriteUInt64(TotalVolume);
            size += stream.WriteIndex(43);
            size += stream.WriteDouble(Turnover);
            size += stream.WriteIndex(45);
            size += stream.WriteUInt64(Volume);
            size += stream.WriteIndex(46);
            size += stream.WriteDouble(ImpliedAskPrice);
            size += stream.WriteIndex(47);
            size += stream.WriteUInt64(ImpliedAskQty);
            size += stream.WriteIndex(48);
            size += stream.WriteDouble(ImpliedBidPrice);
            size += stream.WriteIndex(50);
            size += stream.WriteUInt64(Q5DAvgQty);
            size += stream.WriteIndex(51);
            size += stream.WriteDouble(PERatio);
            size += stream.WriteIndex(52);
            size += stream.WriteUInt64(TotalValue);
            size += stream.WriteIndex(53);
            size += stream.WriteDouble(NegotiableValue);
            size += stream.WriteIndex(54);
            size += stream.WriteDouble(PositionTrend);
            size += stream.WriteIndex(55);
            size += stream.WriteDouble(ChangeSpeed);
            size += stream.WriteIndex(56);
            size += stream.WriteDouble(ChangeRate);
            size += stream.WriteIndex(57);
            size += stream.WriteDouble(Swing);
            size += stream.WriteIndex(58);
            size += stream.WriteUInt64(TotalBidQty);
            size += stream.WriteIndex(59);
            size += stream.WriteUInt64(TotalAskQty);
            size += stream.WriteIndex(0);
            size += stream.WriteString(CurrencyNo);
            size += stream.WriteIndex(23);
            size += stream.WriteString(CommodityNo);
            size += stream.WriteIndex(25);
            size += stream.WriteString(ExchangeID);
            size += stream.WriteIndex(29);
            size += stream.WriteString(InstrumentID);
            size += stream.WriteIndex(61);
            size += stream.WriteString(Source);
            size += stream.WriteIndex(63);
            size += stream.WriteString(TradingTime);
            BitConverter.TryWriteBytes(span, size);
            return(size);
        }