Пример #1
0
        public void OnItemUpdate(int phase, int itemPos, string itemName, IUpdateInfo update)
        {
            if (!App.checkPhase(phase))
            {
                return;
            }
            Dictionary <int, UpdateCell> TextMap;

            if (RowMap.TryGetValue(itemPos, out TextMap))
            {
                for (int i = 0; i < App.fields.Length; i++)
                {
                    string field = App.fields[i];
                    if (update.IsValueChanged(field) || update.Snapshot)
                    {
                        UpdateCell cell;
                        if (TextMap.TryGetValue(i, out cell))
                        {
                            cell.SetText(update.GetNewValue(field));
                            if (field.Equals("last_price"))
                            {
                                cell.Animate(update, field, TextMap);
                            }
                        }
                    }
                }
            }

            Debug.WriteLine("OnItemUpdate: " + itemName + ", " + update + ", pos: " + itemPos);
        }
 private string NotifyValue(IUpdateInfo update, string fldName)
 {
     string newValue = update.GetNewValue(fldName);
     string notify = " " + fldName + " = " + (newValue != null ? newValue : "null");
     if (update.IsValueChanged(fldName))
     {
         string oldValue = update.GetOldValue(fldName);
         notify += " (was " + (oldValue != null ? oldValue : "null") + ")";
     }
     return notify;
 }
Пример #3
0
    new public void RTUpdates(IUpdateInfo update)
    {
        if (!update.ItemName.Equals(this.ItemName))
        {
            return;
        }

        if (update.ItemName.StartsWith("item"))
        {
            if (update.IsValueChanged(2))
            {
                float ftmp = 1;
                float.TryParse(update.GetNewValue(2), out ftmp);

                int iValue  = Mathf.FloorToInt(ftmp);
                int iValue2 = Mathf.FloorToInt(ftmp / 2.0F);

                if (this.cc == 0)
                {
                    this.redC  = (this.redC + iValue) % 255;
                    this.blueC = (this.blueC + iValue2) % 255;
                }
                else
                {
                    this.greenC = (this.greenC + iValue) % 255;
                    this.blueC  = (this.blueC + iValue2) % 255;
                }
            }
            if (update.IsValueChanged(4))
            {
                float ftmp = 1;
                float.TryParse(update.GetNewValue(4), out ftmp);

                Debug.Log(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>: " + ftmp);

                this.scale = 3.0F + (3.0F * ftmp / 5000.0F);

                Debug.Log("New scale: " + this.scale);
            }
        }
    }
Пример #4
0
        private string NotifyValue(IUpdateInfo update, string fldName)
        {
            string newValue = update.GetNewValue(fldName);
            string notify   = " " + fldName + " = " + (newValue != null ? newValue : "null");

            if (update.IsValueChanged(fldName))
            {
                string oldValue = update.GetOldValue(fldName);
                notify += " (was " + (oldValue != null ? oldValue : "null") + ")";
            }
            return(notify);
        }
Пример #5
0
 /// <summary>
 /// It seems some streams have a 'spin-up' process that can return an all null update
 /// until the data starts streaming. We were not catching this and null updates were
 /// sometimes throwing exceptions that were logged and then swallowed by LS. I think
 /// a better way is to determine if the update is emtpy (null) and simply not fire if so.
 ///
 /// Follows is a very simple check
 /// </summary>
 /// <param name="update"></param>
 /// <returns></returns>
 private static bool IsUpdateNull(IUpdateInfo update)
 {
     for (int i = 1; i < update.NumFields + 1; i++)
     {
         object value = update.IsValueChanged(i) ? update.GetNewValue(i) : update.GetOldValue(i);
         if (value != null)
         {
             return(false);
         }
     }
     return(true);
 }
    new public void RTUpdates(IUpdateInfo update)
    {
        if (!update.ItemName.Equals(this.ItemName))
        {
            return;
        }

        if (update.IsValueChanged("message"))
        {
            Debug.Log("Message:" + update.GetNewValue("message"));

            GetComponent <TextMesh>().text = update.GetNewValue("message");
        }
    }
        private static string GetCurrentValue(IUpdateInfo updateInfo, int pos)
        {
            string value;

            if (updateInfo.IsValueChanged(pos))
            {
                value = updateInfo.GetNewValue(pos);
            }
            else
            {
                value = updateInfo.GetOldValue(pos);
            }
            return(value);
        }
Пример #8
0
        private static string GetCurrentValue(IUpdateInfo updateInfo, int pos)
        {
            string result;

            if (updateInfo.IsValueChanged(pos))
            {
                result = updateInfo.GetNewValue(pos);
            }
            else
            {
                result = updateInfo.GetOldValue(pos);
            }

            return(result);
        }
Пример #9
0
        public void OnItemUpdate(int phase, int itemPos, string itemName, IUpdateInfo update)
        {
            if (!App.checkPhase(phase))
            {
                return;
            }
            Dictionary<int, UpdateCell> TextMap;
            if (RowMap.TryGetValue(itemPos, out TextMap))
            {

                for (int i = 0; i < App.fields.Length; i++)
                {
                    string field = App.fields[i];
                    if (update.IsValueChanged(field) || update.Snapshot)
                    {
                        UpdateCell cell;
                        if (TextMap.TryGetValue(i, out cell))
                        {
                            cell.SetText(update.GetNewValue(field));
                            if (field.Equals("last_price"))
                                cell.Animate(update, field, TextMap);
                        }
                    }
                }

            }

            Debug.WriteLine("OnItemUpdate: " + itemName + ", " + update + ", pos: " + itemPos);
        }
Пример #10
0
        private void OnLightstreamerUpdate(int item, IUpdateInfo values)
        {
            dataGridview.SuspendLayout();

            if (this.isDirty)
            {
                this.isDirty = false;
                CleanGrid();
            }

            DataGridViewRow row = dataGridview.Rows[item - 1];

            ArrayList cells = new ArrayList();
            int len = values.NumFields;
            for (int i = 0; i < len; i++) {
                if (values.IsValueChanged(i + 1)) {
                    string val = values.GetNewValue(i + 1);
                    DataGridViewCell cell = row.Cells[i];

                    switch (i) {
                        case 1: // last_price          
                        case 5: // bid
                        case 6: // ask
                        case 8: // min
                        case 9: // max
                        case 10: // ref_price
                        case 11: // open_price
                            double dVal = Double.Parse(val, CultureInfo.GetCultureInfo("en-US").NumberFormat);
                            cell.Value = dVal;
                            break;

                        case 3: // pct_change
                            double dVal2 = Double.Parse(val, CultureInfo.GetCultureInfo("en-US").NumberFormat);
                            cell.Value = dVal2;
                            cell.Style.ForeColor = ((dVal2 < 0.0) ? Color.Red : Color.Green);
                            break;

                        case 4: // bid_quantity
                        case 7: // ask_quantity
                            int lVal = Int32.Parse(val);
                            cell.Value = lVal;
                            break;

                        case 2: // time
                            DateTime dtVal = DateTime.Parse(val);
                            cell.Value = dtVal;
                            break;

                        default: // stock_name, ...
                            cell.Value = val;
                            break;
                    }

                    if (blinkEnabled) {
                        cell.Style.BackColor = blinkOnColor;
                        cells.Add(cell);
                    }
                }
            }

            dataGridview.ResumeLayout();

            if (blinkEnabled) {
                long now = DateTime.Now.Ticks;
                ScheduleBlinkOff(cells, now);
            }
        }
        public void OnItemUpdate(int itemPos, string itemName, IUpdateInfo update)
        {
            List <string> item_fields = null;

            flowForm.AppendLightstreamerLog("OnItemUpdate, pos: " + itemPos + ", name: " +
                                            itemName + ", update:" + update);
            flowForm.TickItemsCountLabel();

            if (!feedingToggle)
            {
                flowForm.AppendLightstreamerLog("OnItemUpdate, not feeding Excel.");
                return;
            }

            itemCache[itemName] = update;


            if (subsDone.TryGetValue(itemName, out item_fields))
            {
                bool updatesExist = false;
                foreach (string field in item_fields)
                {
                    try
                    {
                        if (update.IsValueChanged(field))
                        {
                            if (update.GetNewValue(field) != null)
                            {
                                // push to update queue
                                if (updateQueue.Count() < updateQueueMaxLength)
                                {
                                    int topicId;
                                    if (reverseTopicIdMap.TryGetValue(itemName + "@" + field, out topicId))
                                    {
                                        updatesExist = true;
                                        updateQueue.Enqueue(new RtdUpdateQueueItem(topicId, field, update));
                                        if (field.Equals("time"))
                                        {
                                            int topicId_Last;
                                            if (reverseTopicIdMap.TryGetValue("LAST", out topicId_Last))
                                            {
                                                updateQueue.Enqueue(new RtdUpdateQueueItem(topicId_Last, "", update.GetNewValue(field)));
                                            }
                                        }
                                        if (field.Equals("last_price"))
                                        {
                                            int topicId_Last_px;
                                            if (reverseTopicIdMap.TryGetValue("PX", out topicId_Last_px))
                                            {
                                                updateQueue.Enqueue(new RtdUpdateQueueItem(topicId_Last_px, "", update.GetNewValue(field)));
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    } catch (ArgumentException)
                    {
                        // Skip ...
                    }
                }
                if (updatesExist && (rtdUpdateEvent != null))
                {
                    // notify Excel that updates exist
                    // if this fails, it means that Excel is not ready
                    rtdUpdateEvent.UpdateNotify();
                    flowForm.AppendExcelLog("OnItemUpdate, Excel notified. HB interval: " + rtdUpdateEvent.HeartbeatInterval);
                }
            }
        }
Пример #12
0
        private void OnLightstreamerUpdate(int item, IUpdateInfo values)
        {
            dataGridview.SuspendLayout();

            if (this.isDirty)
            {
                this.isDirty = false;
                CleanGrid();
            }

            DataGridViewRow row = dataGridview.Rows[item - 1];

            ArrayList cells = new ArrayList();
            int       len   = values.NumFields;

            for (int i = 0; i < len; i++)
            {
                if (values.IsValueChanged(i + 1))
                {
                    string           val  = values.GetNewValue(i + 1);
                    DataGridViewCell cell = row.Cells[i];

                    switch (i)
                    {
                    case 1:     // last_price
                    case 5:     // bid
                    case 6:     // ask
                    case 8:     // min
                    case 9:     // max
                    case 10:    // ref_price
                    case 11:    // open_price
                        double dVal = Double.Parse(val, CultureInfo.GetCultureInfo("en-US").NumberFormat);
                        cell.Value = dVal;
                        break;

                    case 3:     // pct_change
                        double dVal2 = Double.Parse(val, CultureInfo.GetCultureInfo("en-US").NumberFormat);
                        cell.Value           = dVal2;
                        cell.Style.ForeColor = ((dVal2 < 0.0) ? Color.Red : Color.Green);
                        break;

                    case 4:     // bid_quantity
                    case 7:     // ask_quantity
                        int lVal = Int32.Parse(val);
                        cell.Value = lVal;
                        break;

                    case 2:     // time
                        DateTime dtVal = DateTime.Parse(val);
                        cell.Value = dtVal;
                        break;

                    default:     // stock_name, ...
                        cell.Value = val;
                        break;
                    }

                    if (blinkEnabled)
                    {
                        cell.Style.BackColor = blinkOnColor;
                        cells.Add(cell);
                    }
                }
            }

            dataGridview.ResumeLayout();

            if (blinkEnabled)
            {
                long now = DateTime.Now.Ticks;
                ScheduleBlinkOff(cells, now);
            }
        }