question

Upvotes
Accepted
9 5 4 5

Set up multiple time series request in Web SDK

Hi all,

I am working on a page which requires to send multiple time series requests at one time. However, as the requests are at promise (asynchronous) base. I cannot find a way to distinguish which result corresponds to its request when it is loaded and only result is returned (Without RIC). I wonder if there is a way to do that.

Thanks a lot for your help! I know it should have a trivial solution but i really have no idea how to fix this.

It would be helpful if you can build on the time series example.

//Create snapshot request via request() function.

function snapshot() {

var table = document.getElementById("myTable"); table.innerHTML='';

if (typeof sub !== 'undefined') {

sub.unsubscribe(); delete sub;

}

var intervalType = $("#select_intervalType").val();

var tsPromise = JET.Data.TimeSeries.request({"ric" : $("#RIC").val(),"view" : $("#VIEW").val(),"numberOfPoints": Number($("#numberOfPoints").val()),"timeZone" : "instrument","intervalType" : $("#select_intervalType").val(),"intervalLength" : 1}); tsPromise.then(resolve, reject);

}

function resolve(data){

var status = document.getElementById("status");

status.value = "Success";

data.....

}

//If request is rejected, then update status text area.

function reject(msg) {

var status = document.getElementById("status");

status.value = "Rejected: " + JSON.stringify(msg);

}

eikontime-serieseikon-app-studio
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

· Write an Answer
Upvotes
Accepted
78.8k 249 52 74

You can implement like this:

function snapshot() {
    
    var intervalType = $("#select_intervalType").val();
    var ricName = $("#RIC").val();
    var tsPromise = JET.Data.TimeSeries.request({ "ric": $("#RIC").val(), "view": $("#VIEW").val(), "numberOfPoints": Number($("#numberOfPoints").val()), "timeZone": "instrument", "intervalType": $("#select_intervalType").val(), "intervalLength": 1 });
    tsPromise.then(function (data) {
        resolve(data, ricName);
    }, function (msg) {
        reject(msg, ricName);
    });
}
function resolve(data, ricName){
    var status = document.getElementById("status");
    status.value = "Success";
    console.log("### " + ricName + " ###");
    if (data.length > 30000) {// too big data
        console.log("Total Points:" + args.Data.length);
    }
    else {
        if (data.length > 1) {
            console.log(JSON.stringify(data, null, 4));
        }
        else {
            console.log(JSON.stringify(data, null, 4));
        }
    }
}

//If request is rejected, then update status text area.
function reject(msg, ricName) {
    var status = document.getElementById("status");
    status.value = "Rejected: " + JSON.stringify(msg);
    console.log("Rejected: "+ ricName);
}
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Thx a lot! ;p

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.