AnsweredAssumed Answered

JavaScript Calculator Questions

Question asked by MatthiasNovaTec on Sep 11, 2014
Latest reply on Jun 29, 2015 by Guenter_Grossberger
Branched to a new discussion

Hello guys,


I working for several hours now on JavaScript Calculators which ended in some questions I cannot answer myself. I hope you guys can help me.


Better description of 'metricData' available or general about JavaScript Calculators?

I basically learned how to work with the metricData parameter from other scripts located in the scripts folder. I also had a look at the short description for javascript calculators => JavaScript Calculators How TO.docx. Unfortunately, I cannot really find a description about all the possible methods/attributes offered by metricData. This is quite essential since I haven't received values for kStringIndividualEvents Metrics with the common used "metricData[i].timeslicedValue.value" until I changed it to "metricData[i].timeslicedValue.getString()" (I'm still not convinced that this is the correct usage even if i get the correct values.


If anyone knows a better desciption please let me know.


Does the EM offer an interface for retrieving data during script execution?

One of my requirements at the script I write is the need to look at the history of a metric. Let*s assume the script always works only on a single metric A which is either 0 or 1. Depending on this metric I write another metric X back to the EM. I write 10 if I get 3 times of the last 4 iterations the value 0 and 20 otherwise. Currently I keep track of the history inside the script. Unfortunately this has a really painful drawback because if the script is reloaded all the history is gone which is kind of ugly because in my case it can lead to side-effects. So is there a possibility to retrieve data from the EM via an interface which basically would allow me to receive the values of the latest 4 periods of the metric?


Do you know a metric which is written each period (use latest value) even if no new value is provided?

The question is hard to understand but I don't find a way to describe it easier ;-) So let's try it with some sentences: I currently write a metric (X from last question) to the EM with type kIntegerFluctuatingCounter (Definition: A 32 bit numeric value that fluctuates, but stays at the last known value until new data is available). I have chosen this type because I thought that even If I do not write a value each period the value will stay the same and will not turn into e.g. 0. This works all fine but the problem occurs when I try to read it each script iteration (Necessary because the script needs to do things different depending whether it is 10 or 20). The problem happens if no data has been written the period before (e.g. because the script was reloaded or it was not possible to write a value in the previous script iteration which can happen) because I only get the value of the last 15seconds which is undefined and not the one which I last wrote and assumed to be used each iteration in case I do not write a value.


Do you guys know how to deal with this situation? Any suggestion or similiar problems you already have found a solution for?


Thanks in advance,


Matthias Huber