I am trying to use the getTimerValues function but I have not got my syntax correct. I have tried for hours to manipulate it with some of the () in the function() filled in with various things and the syntax of var timer_val = process[1]/[2];
I am simply trying to retrieve the Timer Value Of Process 1 Timer 2. the variable $('#timer_val').html(timer_val); is on the html page and works when I plug a fixed value into var timer_val ="00:29:00", so I know that html syntax is not in error.
Any help or example
bcs.helpers.getTimerValues().then(function () {
var timer_val = process[1]/[2];
$('#timer_val').html(timer_val);
b
});
I eventually want to get the Timer String and Process State Name as well but not sure of the syntax for those functions either.
bcs.helpers.getTimerValues
Re: bcs.helpers.getTimerValues
First, getTimerValues requires you to supply a process number. Second, the function provided to then() needs to have a parameter that will hold the values returned from the BCS when it is called. So your example would look something like:
I can't actually try running that right now, but I'm pretty sure that's correct based on the docs.
http://embeddedcc.github.io/bcs-promise ... imerValues
Edit: I updated the code sample here so it should actually work in case anyone finds this thread later and is looking for a code sample.
Code: Select all
bcs.helpers.getTimerValues(1).then(function (timer_vals) {
$('#timer_val').html(timer_vals[2].toString());
});
http://embeddedcc.github.io/bcs-promise ... imerValues
Edit: I updated the code sample here so it should actually work in case anyone finds this thread later and is looking for a code sample.
Re: bcs.helpers.getTimerValues
Try this
Code: Select all
var process = 1;
bcs.helpers.getTimerValues(process).then(function (timeobject) {
var timer_val = new BCS.Time(timeobject[2].value).toString()
$('#timer_val').html(timer_val);
});
Move, copy, clear proc/states: http://manipulator.from-ca.com/
Perform coeff. mods: http://calculator.from-ca.com/
HMI latest ver: http://bbrally.altervista.org/guibeta/i ... r=01042020
Perform coeff. mods: http://calculator.from-ca.com/
HMI latest ver: http://bbrally.altervista.org/guibeta/i ... r=01042020
Re: bcs.helpers.getTimerValues
Tried your code directly and played around with mine and it runs but returns a Null I think as there is just white space in the timer_val div
It is reading the BCS because the other two divs work (from my large temp display)
</label>
<div id="probeSetPoint" class="textStyleSetpoint">Setpoint</div>
<div id="probeName" class="textStyleTitle">Probe</div>
<div id="timer_val" class="timerstyle">0.0</div>
If I hard code a value in the .js file it appears as it should (black text with green background{class="timerstyle})
bcs.helpers.getTimerValues(1).then(function (timer_vals) {
$('#timer_val').html("01:00:12");
b
});
I also tried this code as I like the style better as I am not a wiz at Javascript with same null result. I would think that is equivalent to yours but not as concise. I have used languages that you must declare so it makes better sense to me if I do.
bcs.helpers.getTimerValues(1).then(function (ftv) {
var timer_val = ftv[2];
$('#timer_val').html(timer_val);
b
});
It is reading the BCS because the other two divs work (from my large temp display)
</label>
<div id="probeSetPoint" class="textStyleSetpoint">Setpoint</div>
<div id="probeName" class="textStyleTitle">Probe</div>
<div id="timer_val" class="timerstyle">0.0</div>
If I hard code a value in the .js file it appears as it should (black text with green background{class="timerstyle})
bcs.helpers.getTimerValues(1).then(function (timer_vals) {
$('#timer_val').html("01:00:12");
b
});
I also tried this code as I like the style better as I am not a wiz at Javascript with same null result. I would think that is equivalent to yours but not as concise. I have used languages that you must declare so it makes better sense to me if I do.
bcs.helpers.getTimerValues(1).then(function (ftv) {
var timer_val = ftv[2];
$('#timer_val').html(timer_val);
b
});
Re: bcs.helpers.getTimerValues
bbrally wrote:Try this
Code: Select all
var process = 1; bcs.helpers.getTimerValues(process).then(function (timeobject) { var timer_val = new BCS.Time(timeobject[2].value).toString() $('#timer_val').html(timer_val); });
That sort of works. I am getting a number that is counting down but the number does not seem related to any value in the BCS. It is also taking about 9 seconds for the last digit to change
The 0.0 at the top is the SetPoint and not the Probe. The Timer 2 should be the Mash but it does not correspond to any of the running times. It took me about 15 seconds to do the screen shoots but the seconds were not close beween the code and the BCS regardless. I ran all the timers in the State for testing.
Here is a pix
Re: bcs.helpers.getTimerValues
getTimerValues returns an object. The value you are looking for will be contained in the .value property
Try this
This will only return the number of seconds in the timer. If you want to convert the seonds to Hours:Minutes:Seconds try this
Try this
Code: Select all
bcs.helpers.getTimerValues(1).then(function (ftv) {
var timer_val = ftv[2].value;
$('#timer_val').html(timer_val);
});
Code: Select all
var timer_val = ftv[2].value;
var time_string = new BCS.Time(timer_val).toString();
$('#timer_val').html(time_string);
Move, copy, clear proc/states: http://manipulator.from-ca.com/
Perform coeff. mods: http://calculator.from-ca.com/
HMI latest ver: http://bbrally.altervista.org/guibeta/i ... r=01042020
Perform coeff. mods: http://calculator.from-ca.com/
HMI latest ver: http://bbrally.altervista.org/guibeta/i ... r=01042020
Re: bcs.helpers.getTimerValues
If all you're trying to do is display the time and you don't need to manipulate it at all, I'd suggest using getTimerStrings instead of getTimerValues.
I just looked at the code and it looks like getTimerValues is already converting the time to a BCS.Time object. That is not at all clear from the documentation. So you should just be able to do timeobject[2].toString() to get the string representation. Again, I would suggest just using getTimerStrings since it does that for you already.
I just looked at the code and it looks like getTimerValues is already converting the time to a BCS.Time object. That is not at all clear from the documentation. So you should just be able to do timeobject[2].toString() to get the string representation. Again, I would suggest just using getTimerStrings since it does that for you already.
Re: bcs.helpers.getTimerValues
Not sure about why it takes 9 seconds to display, it's near instant for me.That sort of works. I am getting a number that is counting down but the number does not seem related to any value in the BCS. It is also taking about 9 seconds for the last digit to change
The 0.0 at the top is the SetPoint and not the Probe. The Timer 2 should be the Mash but it does not correspond to any of the running times. It took me about 15 seconds to do the screen shoots but the seconds were not close beween the code and the BCS regardless. I ran all the timers in the State for testing.
As for numbers that make no sense, I may not be using the toString() function properly. I ran into this a while ago and ended up writing my own function.
Code: Select all
function toTimeString(time) {
function formatNumber(n) {
return n < 10 ? '0' + n : '' + n;
}
var hours = Math.floor(Math.abs(time / 3600));
var minutes = Math.floor(Math.abs((time % 3600) / 60));
var seconds = Math.floor(Math.abs(time % 60));
return (time < 0 ? '-' : '') + hours + ":" + formatNumber(minutes) + ":" + formatNumber(seconds);
}
var timer_val = toTimeString(timeobject[2].value);
Move, copy, clear proc/states: http://manipulator.from-ca.com/
Perform coeff. mods: http://calculator.from-ca.com/
HMI latest ver: http://bbrally.altervista.org/guibeta/i ... r=01042020
Perform coeff. mods: http://calculator.from-ca.com/
HMI latest ver: http://bbrally.altervista.org/guibeta/i ... r=01042020
Re: bcs.helpers.getTimerValues
Is is my Timer 2 Mash as I restarted it. When my BCS Read 1:30:00 the code read 0:09:00 so it was off by 1 digit. It reads 9 minutes instead of 90. So it is reading the timer, just not parsing correctly. I think the getTempValues returns a Time String. More Play.
Re: bcs.helpers.getTimerValues
brahn wrote:If all you're trying to do is display the time and you don't need to manipulate it at all, I'd suggest using getTimerStrings instead of getTimerValues.
I just looked at the code and it looks like getTimerValues is already converting the time to a BCS.Time object. That is not at all clear from the documentation. So you should just be able to do timeobject[2].toString() to get the string representation. Again, I would suggest just using getTimerStrings since it does that for you already.
I am hoping to use the value as well as the String. I want to display the String but change the color via the Value using a stylesheet. I do that with the Temps and am hoping to create a html that flips between Temp and Time and then goes to time only with less than 5:00 minutes. (raw=300).
bbralley code does give me the raw value so I will try the getTimerValues for the display.