I'm trying to learn by programming for a Bosch/Rexroth MLC. I wrote this sequence, but I'm not sure if there's a better way to do things.
Pseudo-code would look something like this:
wRunningCount=300
wStandstillCount=150
wCount
zeroSpeed
IF zeroSpeed THEN
wCount=wStandstillCount
ELSE
wCount=wRunningCount
FI
But I want to move this functionality into function blocks. (Already have a TON that will receive the wCount)
Right now I have:
__MOVE____
zeroSpeed-|EN ENO|-
wStandStillCount-|_________|-wCount
__MOVE___
zeroSpeed-o|EN ENO|-
wRunningCount-|_________|-wCount
Is there some better way to do this?
depending on how you want to initialize your variables you can do this
Otherwise there is not better way to do it then you are right now.
Why can't you use the ton block in ST? The rest of your code looks pretty good.
TON_0(enable:=TRUE, PT:=T#1s);
IF TON_0.Q THEN //if timer done
//do stuff
TON_0(enable:=FALSE); //reset timer
END_IF
Most 61131 implementations will have a "SEL" block that should do this fairly nicely...
__SEL__
zerospeed |G Q|wCount
| |
wrunning |IN0 |
| |
wstandstill|IN1 |
|_______|
Related
Using WAA (Web Audio Api) I am using exponentialRampToValueAtTime to create a fade in and out that can be cancelled for the user pressing the "stop" button.
The stops function looks something like this:
this._gainNode.gain.cancelAndHoldAtTime(this._AudioContext.currentTime);
this._gainNode.gain.exponentialRampToValueAtTime(0.000001, this._AudioContext.currentTime + fadeDuration);
The complete function is wrapped in a Promise because I need to do something else after the stop (fadeDuration);
The problem is that in some browsers cancelAndHoldAtTime does not exit and I get some nasty clips that I do not know how to prevent. The same happens with cancelValuesAndHoldAtTime that is even less supported.
I tried with cancelScheduledValues but it does not help.
Is there a workaround or correct alternative to cancelAndHoldAtTime
You can do an approximation by calling setValueAtTime(v, t) where t is the context time at which the user pressed the stop button and v is the estimated value of the exponential at time t.
You'll probably still get a glitch, but it will probably be much better than using just cancelScheduledValues.
This is the reason why cancelAndHoldAtTime was added to the API.
Although maybe the best alternative for cancelAndHoldAtTime is the one recommended for Raymond Toy, to completely remove the clip and any glitches what I ended up doing was making a "Main Gain" between the oscillator Gain and the destination
OSC -> oscGain -> mainGain -> speakers.
Before I do anything I close the mainGain and then cancelScheduledValues and all the other stuff to the oscGain
I did some research into this and couldn't really find anything, so if this is a repetitive question I apologize. but anyway I have made a CCB file in CocosBuilder and I would like to start the timeline, for example, at one second instead of playing from the beginning. Is there a way to do this? Thanks for the help guys.
Edit: i would like this to be done in the code.
I am using 2.2.1 Cocos2DX version. I think there is no option to play it from given interval. But you can tweak yourself to get it done. (Not simple one)
You have to go to CCBAnimationManager and there you get "mNodeSequences".
It is dictionary and you get difference properties there like "rotation position etc..."
values there.
Internally AnimationManager reads this value (These values are specified in your CCB)
and puts in runAction queue.
So you have to break it as you want.(Ex. 5 min timeline you have. But you want to start
from 1 min then you have run first 1 min Actions without delay and for remaining you
have properly calculate tween intervals.
It's long procedure and needs calculation. If you don't know any other simpler way try this. If you know pls let us know (Post it).
In my application I'm building, I'd like for the first screen to be an UPDATE to an integer, but I'd like to have an option to press F2 to access a different kind of functionality in the program.
When I try it the logical way, I get buzzed at since the UPDATE is expecting INTEGER only input, and I'm pressing F2.
Can you UPDATE and READKEY successfully at the same time?
You're trying to do it the old way with editing blocks - try reading up on event-driven programming, where the code describes events and what gets run when a certain event happens. The code would look something like this:
ON F2 of update-field
DO: /* something */
END.
UPDATE update-field.
Better yet, don't use "UPDATE", do a "WAIT-FOR" instead.
I have been googling from last couple of hours for finding that is there any way to clear NSLog output using code or not?
Like we have clrscr() in c. So if we are trying to print something which we want to focus most and there is lots of log printin there we can put that code there and get keep our desire log on top for easy searching. This can be done by putting breakpoint on my NSLog line and than click on clear console. but question is is there a way to achive this programatically?
I found few question on stack overflow but I din't satisfied with answer like this is saying that I can disable log for release mode etc.
Or I can use DLog, ALog or ULog as requirement but my question is different..
Any one can help me in this?
Thanks in advance :)
You can use a conditional breakpoint to simulate it. Define a function like this in your code:
int clear_console()
{
NSLog(#"\n\n\n\n\n\n\n\n");
}
Then, when you want to clear the console just add a breakpoint before the NSLog with this condition:
Condition: 1 > 0
Action: Debugger Command expr (int) clear_console()
Options: Automatically continue after evaluating Check it to skip the pause.
Tested with Xcode 4.3.2 and lldb.
Previous answer:
AFAIK, no, there isn't.
Just in case you're not doing it yet, you can create custom macros to format the output to highlight what you want.
Define macros like this:
#define CLEAR(...) NSLog(#"\n\n\n\n\n\n") /* enough \n to "clear" the console */
#define WTF(...) CLEAR();NSLog(#"!!!!!!!!!!!!!!");NSLog(__VA_ARGS__)
#define TRACE(__message__) NSLog(#">>>>>>>>>>>>>>> %# <<<<<<<<<<<<<<<<<<<", __message__)
Then:
WTF(#"This should't be here object: %#", theObject);
...
TRACE(#"Start Encoding");
...
It's not what you want but it pretty much solves the problem. You'll end up with your own set of macros with custom prefixes easily scannable in the console output.
I'm trying to profile a Perl script, but CORE::sleep gobble all the space (and time) of my report.
How can i tell NYTProf to ignore sleep calls ?
Assuming we have the following script :
sub BrandNewSubroutine {
sleep 10;
print "Odelay\n";
}
BrandNewSubroutine();
I want to get rid of the following line of the report :
Exclusive Time;Inclusive Time;Subroutine
10.0s;10.0s;main::::CORE:sleepmain::CORE:sleep
(opcode)
Edit: Using DB::disable_profile() and DB::enable_profile() won't do the trick, as it add sleep time to BrandNewSubroutine Inclusive time.
Thanks in advance.
I'd suggest either wrapping the calls to sleep (possibly by use of method mentioned in perlsub) with DB::disable_profile() and DB::enable_profile() calls (RUN-TIME CONTROL OF PROFILING in NYTProf documentation), or post processing the report to remove the offending calls.
CORE::accept is already ignored in the way you'd like CORE::sleep to be, so the mechanism is already in place. See this code in NYTProf.xs:
/* XXX make configurable eg for wait(), and maybe even subs like FCGI::Accept
* so perhaps use $hide_sub_calls->{$package}{$subname} to make it general.
* Then the logic would have to move out of this block.
*/
if (OP_ACCEPT == op_type)
subr_entry->hide_subr_call_time = 1;
So with a little hacking (OP_SLEEP==op_type || OP_ACCEPT == op_type) you'd be able to ignore CORE::sleep in the same way.
I'd accept a patch to enable that as an option.