@Override protected boolean onResume(long time) { for(ServiceAddOn<Playable> addon : myAnimation.getAddOns()){ Playable p = addon.getAddOn(); p.resume(time); } if(mySource != null && mySource instanceof DefaultAnimationPlayer) { List<String> props = new ArrayList<String>(); if(myLoopFlag) { props.add(AnimationSignal.PROP_LOOP); } AnimationSignal signal = mySignalFactory.createAnimationSignal( mySource.getAnimationPlayerId(), AnimationSignal.EVENT_RESUME, myAnimation.getVersion().getName(), myAnimation.getVersion().getNumber(), myAnimation.hashCode(), myAnimation.getLength(), props); ((DefaultAnimationPlayer)mySource).notifyListeners(signal); } return true; } @Override
RampedAnimationJob( BundleContext context, AnimationPlayer source, Robot.Id robotId, Animation anim, long stepLength, Long start, Long stop, int maxRampMillisec){ if(context == null || robotId == null || anim == null){ throw new NullPointerException(); }if(stepLength <= 0){ throw new IllegalArgumentException( "stepLength must be greater than zero"); } myContext = context; myLoopFlag = false; myRobotId = robotId; myAnimationListeners = new ArrayList(); mySource = source; myAnimation = anim; myStepLengthMillisec = stepLength; myMaxRampTimeMillisec = maxRampMillisec; long s = start == null ? -1 : start; long e = stop == null ? -1 : stop; myAnimationMap = anim.compileMap(s, e, myStepLengthMillisec); }
public static XMLConfiguration writeAnimation( Animation anim, String path, ChannelsParameterSource source, Set<SynchronizedPointGroup> syncPointGroups){ XMLConfiguration config = new XMLConfiguration(); config.setRootElementName(ANIMATION); ConfigurationNode node = config.getRootNode(); node.addChild(XMLConfigUtils.writeVersion(anim.getVersion(), ANIMATION_VERSION_TYPE)); node.addChild(writeChannels(anim.getChannels())); node.addChild(writeAddOnList(anim.getAddOns(), path)); node.addChild(writeChannelsParameters(source)); node.addChild(SyncPointGroupXML.ApacheWriter.writeSyncGroups(syncPointGroups)); return config; }
public static Animation unpackAnimation(AnimationRecord animRec){ String name = animRec.getName(); String number = animRec.getVersionNumber(); VersionProperty animVersion = new VersionProperty(name, number); Animation anim = new Animation(animVersion); for(ChannelRecord chanRec : animRec.getChannels()){ anim.addChannel(unpackChannel(chanRec)); } if(animRec.getStartTime() != null){ anim.setStartTime(animRec.getStartTime()); } if(animRec.getStopTime() != null){ anim.setStopTime(animRec.getStopTime()); } return anim; }
public static AnimationRecord packAnimation(Animation animation){ if(animation == null){ throw new NullPointerException(); } AnimationRecord animRec = new AnimationRecord(); animRec.setName(animation.getVersion().getName()); animRec.setVersionNumber(animation.getVersion().getNumber()); animRec.setStartTime(animation.getStartTime()); animRec.setStopTime(animation.getStopTime()); Schema arraySchema = Schema.createArray(ChannelRecord.SCHEMA$); List<Channel> chanList = animation.getChannels(); GenericArray<ChannelRecord> channels = new Array<ChannelRecord>(chanList.size(), arraySchema); for(Channel chan : chanList){ channels.add(packChannel(chan)); } animRec.setChannels(channels); return animRec; }
public static Animation readAnimation(HierarchicalConfiguration config){ VersionProperty version = XMLConfigUtils.readVersion(config, ANIMATION_VERSION_TYPE); Animation anim = new Animation(version); HierarchicalConfiguration channelsConfig = config.configurationAt(CHANNELS); if(channelsConfig != null && !channelsConfig.isEmpty()){ anim.addChannels(readChannels(channelsConfig)); SyncPointGroupXML.ApacheReader.readSyncPointGroupConfigs( groupsConfig); anim.setSyncGroupConfigs(groups); List<ServiceAddOn<Playable>> addons = readAddOns(addonsConfig); for(ServiceAddOn<Playable> addon : addons){ anim.addAddOn(addon);
List<ChannelsParameter> chanParams = cpSource.getChannelParameters(); getLogger().debug("Test animation channels={}", chanParams); Animation anim = new Animation(); anim.addChannel(chan);
long s = start == null ? -1 : start; long e = stop == null ? -1 : stop; myAnimationMap = anim.compileMap(s, e, stepLength); List<Channel> channels = myAnimation.getChannels(); myPreviousPositions = new Robot.RobotPositionHashMap(channels.size()); for(Channel c : channels){
public AnimationJob playFullAnimationNow(Animation anim) { long lengthMsec = anim.getLength(); return playAnimationSegmentNow(anim, 0, lengthMsec); /*"The PlayState is not implemented for the RemoteAnimationJob." To get correct "remainingTime", when using a networked animation player. Before you play an animation set the start time and stop time on the animation, * or use the play animation with time args: anim.setStartTime(0); anim.setStopTime(anim.getLength()); or animPlayer.playAnimation(anim, 0, anim.getLength()); */ /* * if (myCachedAnimPlayer != null) { // return myCachedAnimPlayer.playAnimation(anim); } else { return AnimationUtils.playAnimation(myBundleCtx, myAnimPlayerOsgiFilterString, anim); } */ }
Set<SynchronizedPointGroup> syncPointGroups) throws IOException{ xs.startTag(NAMESPACE, ANIMATION); XMLUtils.writeVersionProperty(xs, a.getVersion(), ANIMATION_VERSION_TYPE); xs.startTag(NAMESPACE, CHANNELS); for(Channel channel : a.getChannels()){ writeChannel(xs, channel); writeAddOnList(xs, a.getAddOns(), file); xs.startTag(NAMESPACE, CHANNELS_PARAMETERS); if(source != null){
@Override protected boolean onComplete(long time) { for(ServiceAddOn<Playable> addon : myAnimation.getAddOns()){ Playable p = addon.getAddOn(); p.complete(time); } if(mySource != null && mySource instanceof DefaultAnimationPlayer && mySignalFactory != null) { List<String> props = new ArrayList<String>(); if(myLoopFlag) { props.add(AnimationSignal.PROP_LOOP); } AnimationSignal signal = mySignalFactory.createAnimationSignal( mySource.getAnimationPlayerId(), AnimationSignal.EVENT_COMPLETE, myAnimation.getVersion().getName(), myAnimation.getVersion().getNumber(), myAnimation.hashCode(), myAnimation.getLength(), props); ((DefaultAnimationPlayer)mySource).notifyListeners(signal); } return true; }
@Override protected boolean onComplete(long time) { for(ServiceAddOn<Playable> addon : myAnimation.getAddOns()){ Playable p = addon.getAddOn(); p.complete(time); } if(mySource != null && mySource instanceof RampedAnimationPlayer && mySignalFactory != null) { List<String> props = new ArrayList<String>(); props.add(AnimationSignal.PROP_RAMPING); if(myLoopFlag) { props.add(AnimationSignal.PROP_LOOP); } AnimationSignal signal = mySignalFactory.createAnimationSignal( mySource.getAnimationPlayerId(), AnimationSignal.EVENT_COMPLETE, myAnimation.getVersion().getName(), myAnimation.getVersion().getNumber(), myAnimation.hashCode(), myAnimation.getLength(), props); ((RampedAnimationPlayer)mySource).notifyListeners(signal); } return true; }
@Override protected boolean onResume(long time) { for(ServiceAddOn<Playable> addon : myAnimation.getAddOns()){ Playable p = addon.getAddOn(); p.resume(time); } if(mySource != null && mySource instanceof RampedAnimationPlayer && mySignalFactory != null) { List<String> props = new ArrayList<String>(); props.add(AnimationSignal.PROP_RAMPING); if(myLoopFlag) { props.add(AnimationSignal.PROP_LOOP); } AnimationSignal signal = mySignalFactory.createAnimationSignal( mySource.getAnimationPlayerId(), AnimationSignal.EVENT_RESUME, myAnimation.getVersion().getName(), myAnimation.getVersion().getNumber(), myAnimation.hashCode(), myAnimation.getLength(), props); ((RampedAnimationPlayer)mySource).notifyListeners(signal); } return true; } @Override
@Override protected boolean onStop(long time) { for(ServiceAddOn<Playable> addon : myAnimation.getAddOns()){ Playable p = addon.getAddOn(); p.stop(time); } if(mySource != null && mySource instanceof RampedAnimationPlayer && mySignalFactory != null) { List<String> props = new ArrayList<String>(); props.add(AnimationSignal.PROP_RAMPING); if(myLoopFlag) { props.add(AnimationSignal.PROP_LOOP); } AnimationSignal signal = mySignalFactory.createAnimationSignal( mySource.getAnimationPlayerId(), AnimationSignal.EVENT_CANCEL, myAnimation.getVersion().getName(), myAnimation.getVersion().getNumber(), myAnimation.hashCode(), myAnimation.getLength(), props); ((RampedAnimationPlayer)mySource).notifyListeners(signal); } return true; } @Override
@Override protected boolean onPause(long time) { for(ServiceAddOn<Playable> addon : myAnimation.getAddOns()){ Playable p = addon.getAddOn(); p.pause(time); } if(mySource != null && mySource instanceof DefaultAnimationPlayer && mySignalFactory != null) { List<String> props = new ArrayList<String>(); if(myLoopFlag) { props.add(AnimationSignal.PROP_LOOP); } AnimationSignal signal = mySignalFactory.createAnimationSignal( mySource.getAnimationPlayerId(), AnimationSignal.EVENT_PAUSE, myAnimation.getVersion().getName(), myAnimation.getVersion().getNumber(), myAnimation.hashCode(), myAnimation.getLength(), props); ((DefaultAnimationPlayer)mySource).notifyListeners(signal); } return true; } @Override
@Override protected boolean onStop(long time) { for(ServiceAddOn<Playable> addon : myAnimation.getAddOns()){ Playable p = addon.getAddOn(); p.stop(time); } if(mySource != null && mySource instanceof DefaultAnimationPlayer && mySignalFactory != null) { List<String> props = new ArrayList<String>(); if(myLoopFlag) { props.add(AnimationSignal.PROP_LOOP); } AnimationSignal signal = mySignalFactory.createAnimationSignal( mySource.getAnimationPlayerId(), AnimationSignal.EVENT_CANCEL, myAnimation.getVersion().getName(), myAnimation.getVersion().getNumber(), myAnimation.hashCode(), myAnimation.getLength(), props); ((DefaultAnimationPlayer)mySource).notifyListeners(signal); } return true; } @Override
@Override protected boolean onPause(long time) { for(ServiceAddOn<Playable> addon : myAnimation.getAddOns()){ Playable p = addon.getAddOn(); p.pause(time); } if(mySource != null && mySource instanceof RampedAnimationPlayer && mySignalFactory != null) { List<String> props = new ArrayList<String>(); props.add(AnimationSignal.PROP_RAMPING); if(myLoopFlag) { props.add(AnimationSignal.PROP_LOOP); } AnimationSignal signal = mySignalFactory.createAnimationSignal( mySource.getAnimationPlayerId(), AnimationSignal.EVENT_PAUSE, myAnimation.getVersion().getName(), myAnimation.getVersion().getNumber(), myAnimation.hashCode(), myAnimation.getLength(), props); ((RampedAnimationPlayer)mySource).notifyListeners(signal); } return true; } @Override
@Override public boolean onStart(long time) { for(ServiceAddOn<Playable> addon : myAnimation.getAddOns()){ Playable p = addon.getAddOn(); p.start(time); mySource.getAnimationPlayerId(), AnimationSignal.EVENT_START, myAnimation.getVersion().getName(), myAnimation.getVersion().getNumber(), myAnimation.hashCode(), myAnimation.getLength(), props);
@Override public boolean onStart(long time) { for(ServiceAddOn<Playable> addon : myAnimation.getAddOns()){ Playable p = addon.getAddOn(); p.start(time); mySource.getAnimationPlayerId(), AnimationSignal.EVENT_START, myAnimation.getVersion().getName(), myAnimation.getVersion().getNumber(), myAnimation.hashCode(), myAnimation.getLength(), props);