Results 1 to 10 of 10

Hybrid View

  1. #1
    Senior Member
    Join Date
    Oct 2007
    Location
    HoChiMinh
    Posts
    69
    Hi darioCrivelli,
    I mean in your sample code (StockList demo), in "ExternalFeed.cs", you have :

    public ExternalFeedSimulator() {
    _stockGenerators= new Hashtable();
    _snapshotQueue= new ArrayList();
    ...

    _refprices = new double [] {3.04, 16.09, 7.19, 3.63, 7.61,
    2.30, 15.39, 5.31, 4.86, 7.61,
    10.41, 3.94, 6.79, 26.87, 2.27,
    13.04, 6.09, 17.19, 13.63, 17.61,
    11.30, 5.39, 15.31, 14.86, 17.61,
    5.41, 13.94, 16.79, 6.87,
    11.27 };
    }

    Now, I replace your code by read data from file. I want to add more varialbe, something like that (mark by red color) :

    {
    ISecurityStructReader reader;
    reader = new ReadSecurityStruct("C:\\TEMP\\SECURITY.DAT");


    if (reader.Open())
    {
    arr = reader.Read();
    _stockSymbol = new string[arr.Count];
    _openprices = new double[arr.Count];
    _stockNames = new string[arr.Count];
    _bid1 = new double[arr.Count];
    for (int i=0; i< arr.Count ;i++)
    {
    Struct_Security item = (Struct_Security)arr[i];
    //_stockNames.Add(item.SecurityName);
    _openprices[i]= item.OpenPrice;
    _stockSymbol[i]= item.StockSymbol;
    _stockNames[i] = item.SecurityName;
    _bid1[i] = item.Best1Bid ;
    }
    }
    reader.Close();
    }

    and in "default.html", i have :

    ////////////////Global var declaration
    var schema = "last_price time pct_change bid_quantity bid1 ask ask_quantity min max ref_price open_price stock_name item_status";

    My question: I want to show the _bid1[i] = item.Best1Bid value in html. how to get (or what code I can modified) value _bid1[] to show on "default.html" file ?

  2. #2
    Administrator
    Join Date
    Jul 2006
    Location
    Milan
    Posts
    1,091
    Hi,

    The extension seems correct. Therefore, just ensure that suitable cells are also added to "default.html" to display the new field data. The cells can be defined in several ways; the best way depends on the current code in "default.html".
    You can easily check if your new field is sent to the client through the Server log, by setting the priority for the "LightstreamerLogger.pump" category as "DEBUG".

  3. #3
    Senior Member
    Join Date
    Oct 2007
    Location
    HoChiMinh
    Posts
    69
    Hi DarioCrivelli,
    You said "You can easily check if your new field is sent to the client through the Server log, by setting the priority for the "LightstreamerLogger.pump" category as "DEBUG". and How i can setting the priority for the the "LightstreamerLogger.pump" category as "DEBUG" to check new field when it sent to client through the Server?

  4. #4
    Administrator
    Join Date
    Jul 2006
    Location
    Milan
    Posts
    1,091
    The Server log configuration settings are in the "lightstreamer_log_conf.xml" file, under the "conf" directory. The configuration is in "log4j" format.
    Just find an existing element for the "LightstreamerLogger.pump" category and change the priority value. The change is affective after a few seconds.

    Dario

  5. #5
    Senior Member
    Join Date
    Oct 2007
    Location
    HoChiMinh
    Posts
    69
    Hi Dario,
    First, thanks for your help. I followed by your instruction, and it has error :
    07.Jan.08 09:02:51,656 < INFO> Reused HTTP connection on Lightstreamer HTTP Serv
    er from 127.0.0.1:1206
    07.Jan.08 09:02:51,765 < INFO> Serving request: /lightstreamer/control.html?LS_s
    ession=S-1255625151N1&LS_window=0&LS_win_phase=5&LS_op=add& LS_req_phase=57&LS_mo
    de1=MERGE&LS_id1=item1%20item2%20item3%20item4%20i tem5%20item6%20item7%20item8%2
    0item9%20item10%20item11%20item12%20item13%20item1 4%20item15%20&LS_schema1=last_
    price%20time%20pct_change%20bid_quantity%20bid%20a sk%20ask_quantity%20min%20max%
    20ref_price%20open_price%20stock_name%20item_statu s%20ceiling%20floor&LS_snapsho
    t1=true&LS_requested_max_frequency1=0.5&LS_unique= 1 from 127.0.0.1:1206
    07.Jan.08 09:02:51,765 < INFO> Controlling session: S-1255625151N1 from 127.0.0.
    1:1206
    07.Jan.08 09:02:51,843 < INFO> Reused HTTP connection on Lightstreamer HTTP Serv
    er from 127.0.0.1:1206
    07.Jan.08 09:02:51,859 <TRACE> Pumping event in session S-1255625151N1: c(6,5,0)
    ;setWin(0,5);
    07.Jan.08 09:02:52,078 <ERROR> Failure invoked by Data Adapter
    com.lightstreamer.interfaces.data.FailureException : Unknown value '9450' found w
    hile building a UD3 request
    at com.lightstreamer.adapters.remote.data.DataProvide rProtocol.readFailu
    re(DataProviderProtocol.java:161)
    at com.lightstreamer.adapters.remote.data.RemoteDataP rovider.onNotifyRec
    eived(RemoteDataProvider.java:159)
    at com.lightstreamer.adapters.remote.request_reply.No tifyReceiver.onNoti
    fyReceived(NotifyReceiver.java:165)
    at com.lightstreamer.adapters.remote.request_reply.No tifyReceiver.run(No
    tifyReceiver.java:89)
    07.Jan.08 09:02:52,078 <FATAL> Failure in a Data Adapter
    07.Jan.08 09:02:52,078 < INFO> Exiting.....
    07.Jan.08 09:02:52,546 < INFO> Serving request: /tutorial_demo/ls/lsblank.html f
    rom 127.0.0.1:1206
    07.Jan.08 09:02:52,546 < INFO> Reused HTTP connection on Lightstreamer HTTP Serv
    er from 127.0.0.1:1206
    07.Jan.08 09:02:53,890 <TRACE> Sending probe in session S-1255625151N1
    Press any key to continue . . .

    -------
    In your code (StockList Demo) :

    public ExternalFeedSimulator() {
    _stockGenerators= new Hashtable();
    _snapshotQueue= new ArrayList();
    ...

    _refprices = new double [] {3.04, 16.09, 7.19, 3.63, 7.61,
    2.30, 15.39, 5.31, 4.86, 7.61,
    10.41, 3.94, 6.79, 26.87, 2.27,
    13.04, 6.09, 17.19, 13.63, 17.61,
    11.30, 5.39, 15.31, 14.86, 17.61,
    5.41, 13.94, 16.79, 6.87,
    11.27 };
    }

    and i changed something by add more variable :

    ISecurityStructReader reader;
    reader = new ReadSecurityStruct("C:\\TEMP\\BACKUP03\\SECURITY.D AT");


    if (reader.Open())
    {
    arr = reader.Read();
    _stockSymbol = new string[arr.Count];
    _openprices = new double[arr.Count];
    _stockNames = new string[arr.Count];
    _bid1 = new double[arr.Count];
    _maxprices = new double[arr.Count];
    _minprices = new double[arr.Count];
    _ceiling = new int [arr.Count];
    _floor = new double[arr.Count];
    _refprices = new double[arr.Count];

    for (int i=0; i< arr.Count ;i++)
    {
    Struct_Security item = (Struct_Security)arr[i];
    //_stockNames.Add(item.SecurityName);
    _openprices[i]= item.OpenPrice;
    _stockSymbol[i]= item.StockSymbol;
    _stockNames[i] = item.SecurityName;
    _maxprices[i] = item.Highest;
    _minprices[i] = item.Lowest;
    _ceiling[i] = item.Ceiling;
    _floor[i]= item.Floor;

    //gia tham chieu
    _refprices[i] = item.PriorClosePrice;
    //_bid1[i]= item.Best1Bid;

    }
    }

    reader.Close();

    in your code :
    ---------------------
    public void Start() {
    if (_snapshotSender != null) return;

    for (int i = 0; i < 30; i++) {
    string itemName= "item" + (i + 1);
    ExternalFeedProducer myProducer = new ExternalFeedProducer(itemName,
    _openprices[i], _refprices[i], _minprices[i], _maxprices[i],
    _updateTimeMeans[i], _updateTimeStdDevs[i], _stockNames[i]);

    _stockGenerators[itemName]= myProducer;
    myProducer.SetFeedListener(_listener);
    myProducer.Start();
    }

    _snapshotSender= new Thread(new ThreadStart(Run));
    _snapshotSender.Start();
    }

    my changed :
    ---------------
    ExternalFeedProducer myProducer = new ExternalFeedProducer(itemName,
    _openprices[i], _refprices[i], _minprices[i], _maxprices[i],
    _updateTimeMeans[i], _updateTimeStdDevs[i], _stockSymbol[i], _ceiling[i], _floor[i]);

    -------
    your code :
    -------
    public ExternalFeedProducer(string name,
    double openPrice, double referPrice, double minPrice, double maxPrice,
    double updateTimeMean, double updateTimeStdDev, string stockSymbol, int ceiling, double floor) {
    _itemName = name;
    _open = (int) Math.Round(openPrice / 1000);
    _refer = (int) Math.Round(referPrice / 100);
    ...
    }

    ---
    my changed :
    ---
    public ExternalFeedProducer(string name,
    double openPrice, double referPrice, double minPrice, double maxPrice,
    double updateTimeMean, double updateTimeStdDev, string stockSymbol, int ceiling, double floor) {
    _itemName = name;
    _open = (int) Math.Round(openPrice / 1000);
    _refer = (int) Math.Round(referPrice / 100);
    ...
    _min = minPrice;
    _max = maxPrice;
    _last = _open;
    _mean = updateTimeMean;
    _stddev = updateTimeStdDev;
    _stockSymbol = stockSymbol;
    _stockName = stockSymbol;
    _ceiling = ceiling;
    _floor = floor;

    }
    ------
    in your code :
    ------
    public IDictionary GetCurrentValues(bool fullData) {
    lock (this) {
    IDictionary eventData = new Hashtable();
    string time = DateTime.Now.ToString("s");
    eventData["time"] = time.Substring(time.Length - 8);
    ...
    }
    }

    ---
    my changed
    ----
    public IDictionary GetCurrentValues(bool fullData) {
    lock (this) {
    IDictionary eventData = new Hashtable();
    string time = DateTime.Now.ToString("s");
    eventData["time"] = time.Substring(time.Length - 8);

    eventData["ceiling"] = _ceiling;
    eventData["floor"] = _floor;

    ...
    }
    }

    and in default.html, i changed (mark by red color):

    <script>
    for (var i = 1; i <= 15; i++) {
    var suff = (i % 2 == 1) ? "A" : "B";
    document.write('<tr class="lscold'+suff+'">');
    document.write('<td nowrap style="text-align: left"><a href="#" onClick="return openPopup('+i+')"><img src="images/popup.gif" width="16" height="16" border="0" align="left" hspace="1" alt="Graphic Chart"><div class="stockname'+suff+'" source="lightstreamer" table="1" item="'+i+'" field="12">Loading...</div></a></td>');
    document.write('<td><div source="lightstreamer" table="1" item="'+i+'" field="1">-</div></td>');
    document.write('<td><div source="lightstreamer" table="1" item="'+i+'" field="2">-</div></td>');
    document.write('<td><span source="lightstreamer" table="1" item="'+i+'" field="16"><img src="images/spacer_4px.gif" width="20" height="8" border="0"></span></td>');
    document.write('<td nowrap><div source="lightstreamer" table="1" item="'+i+'" field="3">-</div></td>');
    document.write('<td><div source="lightstreamer" table="1" item="'+i+'" field="4">-</div></td>');
    document.write('<td><div source="lightstreamer" table="1" item="'+i+'" field="5">-</div></td>');
    document.write('<td><div source="lightstreamer" table="1" item="'+i+'" field="6">-</div></td>');
    document.write('<td><div source="lightstreamer" table="1" item="'+i+'" field="7">-</div></td>');
    document.write('<td><div source="lightstreamer" table="1" item="'+i+'" field="8">-</div></td>');
    document.write('<td><div source="lightstreamer" table="1" item="'+i+'" field="9">-</div></td>');
    document.write('<td><div source="lightstreamer" table="1" item="'+i+'" field="10">-</div></td>');
    document.write('<td><div source="lightstreamer" table="1" item="'+i+'" field="11">-</div></td>');
    document.write('<td><div source="lightstreamer" table="1" item="'+i+'" field="14">-</div></td>');
    document.write('<td><div source="lightstreamer" table="1" item="'+i+'" field="15">-</div></td>');

    document.write('</tr>');
    }
    </script>
    ////////////////Global var declaration
    var schema = "last_price time pct_change bid_quantity bid ask ask_quantity min max ref_price open_price stock_name item_status ceiling floor";
    var page1 = new Array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
    var page2 = new Array(16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30);

    What my fault? Can u help me?

  6. #6
    Administrator
    Join Date
    Jul 2006
    Location
    Milan
    Posts
    1,091
    The IItemEventListener.Update method specifications require that only String objects or byte arrays can be used as field values. You have to perform the conversions from numbers to strings in Data Adapter code, before populating the IDictionary object.
    (We might think about improving the error message.)
    Dario

  7. #7
    Senior Member
    Join Date
    Oct 2007
    Location
    HoChiMinh
    Posts
    69
    Thanks Dario. I convert from numbers to strings, it's ok.

    public IDictionary GetCurrentValues(bool fullData) {
    lock (this) {
    IDictionary eventData = new Hashtable();
    ...
    eventData["ceiling"] = _ceiling.ToString();
    eventData["floor"] = _floor.ToString();

    }
    }

 

 

Similar Threads

  1. Replies: 2
    Last Post: December 24th, 2010, 07:51 AM
  2. how to add the item into eventData
    By tuongkha in forum Client SDKs
    Replies: 6
    Last Post: January 10th, 2008, 09:26 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT +1. The time now is 04:14 AM.