private static void AddPerson(IWritableReactiveTable people, int id, string name)
        {
            var rowIndex = people.AddRow();

            people.SetValue(PersonColumns.IdColumn, rowIndex, PersonIdOffset + id);
            people.SetValue(PersonColumns.NameColumn, rowIndex, name);
        }
        /// <summary>
        /// Called on the target table thread - copies adds/updates/deletes
        /// </summary>
        /// <param name="rowUpdatesAdd"></param>
        /// <param name="colUpdaters"></param>
        /// <param name="rowUpdatesDelete"></param>
        private void CopyChanges(List <TableUpdate> rowUpdatesAdd, List <ITableColumnUpdater> colUpdaters, List <TableUpdate> rowUpdatesDelete)
        {
            try
            {
                // Copy the adds
                if (rowUpdatesAdd != null)
                {
                    for (var i = 0; i < rowUpdatesAdd.Count; i++)
                    {
                        _targetTable.AddRow();
                    }
                }

                // Copy the updates
                foreach (var updater in colUpdaters)
                {
                    updater.SetValues(_targetTable);
                }

                // Copy the deletes
                if (rowUpdatesDelete != null)
                {
                    for (var i = 0; i < rowUpdatesDelete.Count; i++)
                    {
                        _targetTable.DeleteRow(rowUpdatesDelete[i].RowIndex);
                    }
                }
            }
            finally
            {
                StartTimer();
            }
        }
Exemplo n.º 3
0
        private void AddRow(string groupVal, int value, IWritableReactiveTable table1, string GroupColumnId, string ValueColumnId)
        {
            var row1 = table1.AddRow();

            table1.SetValue(GroupColumnId, row1, groupVal);
            table1.SetValue(ValueColumnId, row1, value);
        }
        private static void AddAccount(IWritableReactiveTable accountsWire, int accountId, int personId, decimal balance)
        {
            var rowId = accountsWire.AddRow();

            accountsWire.SetValue(AccountColumns.IdColumn, rowId, AccountIdOffset + accountId);
            accountsWire.SetValue(AccountColumns.PersonId, rowId, PersonIdOffset + personId);
            accountsWire.SetValue(AccountColumns.AccountBalance, rowId, balance);
        }
Exemplo n.º 5
0
        private void AddCurrencyPair(IWritableReactiveTable currencyPairsWire, string ccyPair)
        {
            var row = currencyPairsWire.AddRow();

            currencyPairsWire.SetValue(BrokerTableDefinition.BrokerClientColumns.ClientIpColumn, row, IPAddress.Loopback.ToString());
            currencyPairsWire.SetValue(BrokerTableDefinition.BrokerClientColumns.ClientCcyPairColumn, row, ccyPair);
            currencyPairsWire.SetValue(BrokerTableDefinition.BrokerClientColumns.ClientSide.Selected, row, false);
        }
Exemplo n.º 6
0
        private static int AddRow(IWritableReactiveTable table, int id, string stringVal, decimal decimalVal)
        {
            var row1 = table.AddRow();

            table.SetValue(TestTableColumns.IdColumn, row1, id);
            table.SetValue(TestTableColumns.StringColumn, row1, stringVal);
            table.SetValue(TestTableColumns.DecimalColumn, row1, decimalVal);
            return(row1);
        }
Exemplo n.º 7
0
        /// <summary>
        /// All Broker feeds must be started in same thread so that AddRow is called on same thread.
        /// </summary>
        public void Start()
        {
            _rowIndeces = new int[_ccyPairs.Length * _maturities.Length];
            var count = 0;

            foreach (var ccyPair in _ccyPairs)
            {
                for (var i = 0; i < _maturities.Length; i++)
                {
                    var rowIndex = _table.AddRow();
                    _rowIndeces[count++] = rowIndex;
                    _table.SetValue(BrokerTableDefinition.BrokerColumns.MaturityColumn, rowIndex, _maturities[i]);
                    _table.SetValue(BrokerTableDefinition.BrokerColumns.CcyPairColumn, rowIndex, ccyPair);
                    _table.SetValue(BrokerTableDefinition.BrokerColumns.BrokerNameColumn, rowIndex, Name);
                }
            }
            Task.Run(() => FeedBrokerData());
        }
Exemplo n.º 8
0
 public void OnNext(TableUpdate update)
 {
     _threadMarshaller.Dispatch(
         () =>
     {
         if (update.Action == TableUpdateAction.Add)
         {
             var newRowIndex = _targetTable.AddRow();
             Debug.Assert(update.RowIndex == newRowIndex);
         }
         else if (update.Action == TableUpdateAction.Delete)
         {
             _targetTable.DeleteRow(update.RowIndex);
         }
         else if (update.Action == TableUpdateAction.Update)
         {
             // BUG: When this line is called the original update.Column may not contain the same state as when the outside method is called.
             _targetTable.SetValue(update.Column.ColumnId, update.RowIndex, update.Column, update.RowIndex);
         }
     });
 }
Exemplo n.º 9
0
        private void SynchroniseChanges(object state)
        {
            // Make copies to control exactly when we lock
            List <TableUpdate> updates;

            lock (_shared)
            {
                if (_updates.Count == 0)
                {
                    return;
                }

                updates = _updates.DequeueAllToList();
            }

            _threadMarshaller.Dispatch(
                () =>
            {
                foreach (var update in updates.Where(TableUpdate.IsRowUpdate))
                {
                    if (update.Action == TableUpdateAction.Add)
                    {
                        _targetTable.AddRow();
                    }
                    else if (update.Action == TableUpdateAction.Delete)
                    {
                        _targetTable.DeleteRow(update.RowIndex);
                    }
                }

                // BUG: When this line is called the original update.Column may not contain the same state as when the outside method is called.
                foreach (var update in updates.Where(TableUpdate.IsColumnUpdate))
                {
                    _targetTable.SetValue(update.Column.ColumnId, update.RowIndex, update.Column, update.RowIndex);
                }
            });
        }