Hey Guys,
we are going to get a new machine with a robot. The robots software has a toolmanagementsystem. To use this i have to post the cuttingtime of every tool to the Nc-prgram header like this:
With the DeferredVariables Propery/Function from the postprocessor training guide i was able to add the time in seconds to the post. But now i'm struggeling to change it to the right format. I wanted to use this function to change the cutting times format:
function convertToTimeFormat(totaltoolTime){
var format = "HH:MM:SS".split(":")[0];
var hours, minutes, result, seconds;
if (format == "HH" || format == "MM") {
hours = Math.floor(totaltoolTime / 3600);
totaltoolTime -= (format == "HH") ? hours * 3600 : 0;
minutes = Math.floor(totaltoolTime / 60);
totaltoolTime -= minutes * 60;
}
seconds = totaltoolTime.toFixed(1);
if (format == "HH") {
result = hours + "Hrs " + minutes + "Min " + seconds + "Sec";
} else if (format == "MM") {
result = minutes + "Min " + seconds + "Sec";
} else {
result = seconds + "Sec";
}
return result;
}
It seems like the DeferredVariable is not a number.
Intstead of the new values i only get NaN.
I hope somebody can help.
Attached you can find my post I am playing with.
Solved! Go to Solution.
Solved by serge.quiblier. Go to Solution.
Hi @j_zander
In the dditive posts, we are using something like :
function formatCycleTime(cycleTime) {
var seconds = cycleTime % 60 | 0;
var minutes = ((cycleTime - seconds) / 60 | 0) % 60;
var hours = (cycleTime - minutes * 60 - seconds) / (60 * 60) | 0;
if (hours > 0) {
return subst(localize("%1h:%2m:%3s"), hours, minutes, seconds);
} else if (minutes > 0) {
return subst(localize("%1m:%2s"), minutes, seconds);
} else {
return subst(localize("%1s"), seconds);
}
}
You can build your own code from this sample. If you don't have to translate H, M S just remove the localize function call, and just keep the string.
Regards
______________________________________________________________
If my post answers your question, please click the "Accept Solution" button. This helps everyone find answers more quickly!
Can't find what you're looking for? Ask the community or share your knowledge.