tuongkha
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;
//_stockNames.Add(item.SecurityName);
_openprices= item.OpenPrice;
_stockSymbol= item.StockSymbol;
_stockNames = item.SecurityName;
_bid1= 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 = item.Best1Bid value in html. how to get (or what code I can modified) value _bid1[] to show on "default.html" file ?
tuongkha
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%20item5%20item6%20item7%20item8%2
0item9%20item10%20item11%20item12%20item13%20item14%20item15%20&LS_schema1=last_
price%20time%20pct_change%20bid_quantity%20bid%20ask%20ask_quantity%20min%20max%
20ref_price%20open_price%20stock_name%20item_status%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.DataProviderProtocol.readFailu
re(DataProviderProtocol.java:161)
at com.lightstreamer.adapters.remote.data.RemoteDataProvider.onNotifyRec
eived(RemoteDataProvider.java:159)
at com.lightstreamer.adapters.remote.request_reply.NotifyReceiver.onNoti
fyReceived(NotifyReceiver.java:165)
at com.lightstreamer.adapters.remote.request_reply.NotifyReceiver.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.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];
_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;
//_stockNames.Add(item.SecurityName);
_openprices= item.OpenPrice;
_stockSymbol= item.StockSymbol;
_stockNames = item.SecurityName;
_maxprices = item.Highest;
_minprices = item.Lowest;
_ceiling = item.Ceiling;
_floor= item.Floor;
//gia tham chieu
_refprices = item.PriorClosePrice; //_bid1= 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?