47 #ifndef _MIRA_CHANNELPROPERTY_H_ 48 #define _MIRA_CHANNELPROPERTY_H_ 78 const std::string&
getID()
const {
95 virtual bool isValid()
const = 0;
123 virtual void update() = 0;
163 template <
typename Reflector>
165 r.member(
"Channel",
channelID,
"The ID of the channel");
173 return property->isValid();
183 return property->getAvailableChannels();
211 template <
typename T>
218 mProcessedUpdates(0),
219 mDataChangedFn(NULL),
220 mDataIntervalChangedFn(NULL),
221 mChannelChangedFn(NULL)
227 return mChannel.isValid();
235 return MIRA_FW.getChannelManager().getChannelsOfType<T>();
248 if(mChannel.isValid()) {
255 if (mChannelChangedFn)
258 mProcessedUpdates = -1;
266 mDataChangedFn = dataChangedFn;
267 mDataIntervalChangedFn = NULL;
270 template<
typename Class>
273 mDataChangedFn = boost::bind(f, obj, _1);
274 mDataIntervalChangedFn = NULL;
279 mDataChangedFn = NULL;
280 mDataIntervalChangedFn = dataChangedFn;
283 template<
typename Class>
286 mDataChangedFn = NULL;
287 mDataIntervalChangedFn = boost::bind(f, obj, _1);
292 mChannelChangedFn = channelChangedFn;
295 template<
typename Class>
298 mChannelChangedFn = boost::bind(f, obj);
311 MIRA_THROW(XRuntime,
"No channel specified.");
326 mProcessedUpdates = -1;
334 int64 updates = mDataUpdates;
339 if ((updates != mProcessedUpdates) && (mDataChangedFn || mDataIntervalChangedFn) )
341 mProcessedUpdates = updates;
342 if ( mDataChangedFn )
344 mDataChangedFn(mChannel.read());
346 catch(XInvalidRead&) {}
349 if ( !mLastUpdate.
isValid() ) {
350 bool increase = mChannel.isAutoIncreasingStorageDuration();
357 catch(XInvalidRead&) {}
358 MIRA_FW.getChannelManager().setAutoIncreaseStorageDuration(
mChannelID, increase);
362 tInterval = mChannel.readInterval(mLastUpdate);
364 catch(XInvalidRead&) {}
370 if (tInterval.
empty())
373 mDataIntervalChangedFn( tInterval );
395 template<
typename Reflector>
400 r.property(name.c_str(),
401 getter<ChannelPropertyProxy>(
402 boost::bind(proxyGetter, &channel, authorityProvider)),
403 setter<ChannelPropertyProxy>(
404 boost::bind(proxySetter, &channel, _1, authorityProvider)),
418 IAuthorityProvider* authorityProvider) {
419 This->mAuthorityProvider = authorityProvider;
420 return ChannelPropertyProxy(This->mChannelID, This);
427 int64 mProcessedUpdates;
428 boost::function<void (ChannelRead<T>)> mDataChangedFn;
429 boost::function<void (ChannelReadInterval<T>)> mDataIntervalChangedFn;
430 boost::function<void ()> mChannelChangedFn;
An object that allows read access to a whole interval of channel data.
Definition: ChannelReadInterval.h:72
Type trait that indicates whether pointer tracking can be enabled for this type.
Definition: IsObjectTrackable.h:68
virtual ~ChannelPropertyBase()
Definition: ChannelProperty.h:73
bool empty() const
Definition: ChannelReadInterval.h:169
Abstract base class for all derived property node classes.
Definition: PropertyNode.h:202
TypedPropertyNode< ChannelPropertyProxy > * property
Definition: ChannelProperty.h:446
ChannelPropertyProxy(const std::string &id, ChannelPropertyBase *p)
Definition: ChannelProperty.h:158
static void channelProperty(Reflector &r, const std::string &name, ChannelProperty &channel, const std::string &comment, IAuthorityProvider *authorityProvider)
Special property-method that should be called within the reflect method to specify a ChannelProperty...
Definition: ChannelProperty.h:396
ChannelPropertyDelegateLineEdit(PropertyNode *p, QWidget *parent)
An exception that occurs whenever a channel has no data.
Definition: Channel.h:88
specialize cv::DataType for our ImgPixel and inherit from cv::DataType<Vec>
Definition: IOService.h:67
void setDataChangedCallback(boost::function< void(ChannelRead< T >)> dataChangedFn)
Definition: ChannelProperty.h:264
bool isValid() const
Returns true if this contains a valid time.
Definition: Time.h:575
std::string channelID
Definition: ChannelProperty.h:188
Class object which supports some kind of class reflection.
Definition: Class.h:97
IAuthorityProvider * mAuthorityProvider
Definition: ChannelProperty.h:138
std::string mName
Definition: ChannelProperty.h:136
#define MIRA_FW
Macro for accessing the framework instance.
Definition: Framework.h:74
bool isOptional() const
For internal use only.
Definition: ChannelProperty.h:114
Provides MIRA_SPLIT_REFLECT macros.
Provides type trait that indicates whether pointer/object tracking should be enabled for a certain ty...
Channel< T > getChannel()
Obtains the set or chosen channel.
Definition: ChannelProperty.h:308
static Time unixEpoch()
Returns the unix epoch 1.1.1970 0:0:0.000.
Definition: Time.h:506
An object that allows read access to data of a channel.
Definition: ChannelReadWrite.h:494
virtual std::list< std::pair< std::string, Typename > > getAvailableChannels()=0
Returns list of (channelID,typename) pairs containing the channels that match the desired type...
void unsubscribe(const std::string &channelID)
Unsubscribe from a given channel.
virtual void set(const std::string &id, IAuthorityProvider *authorityProvider)
Sets the channelID and a necessary authority provider that is used to obtain the authority for subscr...
Definition: ChannelProperty.h:242
#define MIRA_THROW(ex, msg)
Macro for throwing an exception.
Definition: Exception.h:78
ChannelPropertyProxy()
Definition: ChannelProperty.h:157
virtual void update()=0
Tell the property to update the assigned channel.
const_iterator end() const
Definition: ChannelReadInterval.h:164
Contains the base interface of all Reflectors, Serializers, etc.
void setDataIntervalChangedCallback(void(Class::*f)(ChannelReadInterval< T >), Class *obj)
Definition: ChannelProperty.h:284
ChannelProperty()
Definition: ChannelProperty.h:216
Serializer that handles properties and creates PropertyNodes.
virtual bool isValid() const
Returns true, if an existing channel is set. Must be implemented in derived class.
Definition: ChannelProperty.h:226
const std::string & getName() const
Returns the name of the property.
Definition: ChannelProperty.h:88
Abstract interface for classes that can provide an authority via the getAuthority() method...
Definition: AuthorityProvider.h:61
const std::string & getID() const
Returns the channelID that was set by the user.
Definition: ChannelProperty.h:78
void setName(const std::string &name)
Sets the name of the property.
Definition: ChannelProperty.h:83
Base class for ChannelProperty template class.
Definition: ChannelProperty.h:68
ChannelPropertyBase()
Definition: ChannelProperty.h:72
Authorities act as a facade to the framework.
Definition: Authority.h:94
virtual uint32 getDataUpdateCount() const
Returns the number of data updates the channel has received.
Definition: ChannelProperty.h:230
Const iterator for iterating over the interval.
Definition: ChannelReadInterval.h:85
void setDataIntervalChangedCallback(boost::function< void(ChannelReadInterval< T >)> dataChangedFn)
Definition: ChannelProperty.h:277
void reflect(Reflector &r)
Definition: ChannelProperty.h:164
ChannelPropertyBase * property
Definition: ChannelProperty.h:189
virtual std::list< std::pair< std::string, Typename > > getAvailableChannels()
Returns list of (channelID,typename) pairs containing the channels that match the desired type...
Definition: ChannelProperty.h:234
void setChannelChangedCallback(boost::function< void()> channelChangedFn)
Definition: ChannelProperty.h:290
virtual void update()
Tell the property to update the assigned channel.
Definition: ChannelProperty.h:331
std::string mChannelID
Definition: ChannelProperty.h:137
virtual bool isValid() const =0
Returns true, if an existing channel is set. Must be implemented in derived class.
bool mOptional
Definition: ChannelProperty.h:139
The concrete typed ChannelProperty template class.
Definition: ChannelProperty.h:212
virtual Authority & getAuthority()=0
Return the authority as reference.
void setChannelChangedCallback(void(Class::*f)(), Class *obj)
Definition: ChannelProperty.h:296
void setOptional()
For internal use only.
Definition: ChannelProperty.h:109
Abstract interface for classes that can provide an authority.
Special LineEdit for ChannelProperty delegate for Property Editor.
Definition: ChannelProperty.h:438
Proxy class that is returned/set by the getter and setter methods of ChannelProperty.
Definition: ChannelProperty.h:152
The framework that holds all manager classes and provides startup and shutdown of all framework relat...
virtual void set(const std::string &id, IAuthorityProvider *authorityProvider)
Sets the channelID and a necessary authority provider that is used to obtain the authority for subscr...
Definition: ChannelProperty.h:129
void setDataChangedCallback(void(Class::*f)(ChannelRead< T >), Class *obj)
Definition: ChannelProperty.h:271
Channel< T > subscribe(const std::string &channelID, const Duration &storageDuration=Duration::seconds(0))
Subscribes authority to a given channel.
Abstract base class for all typed property nodes.
Definition: PropertyNode.h:70
bool isValid() const
Returns true, if an existing channel is set.
Definition: ChannelProperty.h:171
Provides definition for getters and setters that are used with the serialization framework.
std::list< std::pair< std::string, Typename > > getAvailableChannels()
Returns list of (channelID,typename) pairs containing the channels that match the desired type...
Definition: ChannelProperty.h:180
virtual uint32 getDataUpdateCount() const =0
Returns the number of data updates the channel has received.
void callback(ChannelRead< T > channel)
Definition: ChannelProperty.h:382