| Line |
Branch |
Exec |
Source |
| 1 |
|
|
/***************************************************************************** |
| 2 |
|
|
* |
| 3 |
|
|
* Copyright 2010 Richard Hacker (lerichi at gmx dot net) |
| 4 |
|
|
* |
| 5 |
|
|
* This file is part of the pdserv library. |
| 6 |
|
|
* |
| 7 |
|
|
* The pdserv library is free software: you can redistribute it and/or modify |
| 8 |
|
|
* it under the terms of the GNU Lesser General Public License as published |
| 9 |
|
|
* by the Free Software Foundation, either version 3 of the License, or (at |
| 10 |
|
|
* your option) any later version. |
| 11 |
|
|
* |
| 12 |
|
|
* The pdserv library is distributed in the hope that it will be useful, but |
| 13 |
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
| 14 |
|
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public |
| 15 |
|
|
* License for more details. |
| 16 |
|
|
* |
| 17 |
|
|
* You should have received a copy of the GNU Lesser General Public License |
| 18 |
|
|
* along with the pdserv library. If not, see <http://www.gnu.org/licenses/>. |
| 19 |
|
|
* |
| 20 |
|
|
****************************************************************************/ |
| 21 |
|
|
|
| 22 |
|
|
#ifndef LIB_SIGNAL |
| 23 |
|
|
#define LIB_SIGNAL |
| 24 |
|
|
|
| 25 |
|
|
#include <set> |
| 26 |
|
|
|
| 27 |
|
|
#include "../PThread.h" |
| 28 |
|
|
#include "../Signal.h" |
| 29 |
|
|
#include "pdserv.h" |
| 30 |
|
|
|
| 31 |
|
|
namespace PdServ { |
| 32 |
|
|
class Session; |
| 33 |
|
|
class SessionTask; |
| 34 |
|
|
} |
| 35 |
|
|
|
| 36 |
|
|
class Task; |
| 37 |
|
|
class SessionTaskData; |
| 38 |
|
|
|
| 39 |
|
1884 |
class Signal: public PdServ::Signal { |
| 40 |
|
|
public: |
| 41 |
|
|
Signal( Task *task, |
| 42 |
|
|
size_t index, |
| 43 |
|
|
unsigned int decimation, |
| 44 |
|
|
const char *path, |
| 45 |
|
|
const PdServ::DataType& dtype, |
| 46 |
|
|
const void *addr, |
| 47 |
|
|
size_t ndims = 1, |
| 48 |
|
|
const size_t *dim = 0); |
| 49 |
|
|
|
| 50 |
|
|
Task* const task; |
| 51 |
|
|
|
| 52 |
|
|
const char * const addr; |
| 53 |
|
|
|
| 54 |
|
|
static const size_t dataTypeIndex[PdServ::DataType::maxWidth+1]; |
| 55 |
|
|
const size_t index; |
| 56 |
|
|
|
| 57 |
|
|
read_signal_t read_cb; |
| 58 |
|
|
void* priv_data; |
| 59 |
|
|
|
| 60 |
|
|
void pollValue(void* dst, struct timespec* mtime) const; |
| 61 |
|
|
|
| 62 |
|
|
// Required by Task in nrt to manage subscriptions |
| 63 |
|
|
typedef std::set<SessionTaskData*> SessionSet; |
| 64 |
|
|
SessionSet sessions; |
| 65 |
|
|
unsigned int subscriptionId; |
| 66 |
|
|
size_t copyListPos; |
| 67 |
|
|
|
| 68 |
|
|
private: |
| 69 |
|
|
// Reimplemented from PdServ::Signal |
| 70 |
|
|
void subscribe(PdServ::SessionTask *) const; |
| 71 |
|
|
void unsubscribe(PdServ::SessionTask *) const; |
| 72 |
|
|
double sampleTime() const; |
| 73 |
|
|
const char *getValue(const PdServ::SessionTask*) const; |
| 74 |
|
|
|
| 75 |
|
|
// Reimplemented from PdServ::Variable |
| 76 |
|
|
int getValue(const PdServ::Session*, |
| 77 |
|
|
void *, struct timespec * = 0) const; |
| 78 |
|
|
|
| 79 |
|
|
// A default function used when read_cb is not specified by the user |
| 80 |
|
|
static int copy(const struct pdvariable *signal, |
| 81 |
|
|
void *dst, const void *src, size_t len, |
| 82 |
|
|
struct timespec* time, void *priv_data); |
| 83 |
|
|
}; |
| 84 |
|
|
|
| 85 |
|
|
#endif //LIB_SIGNAL |
| 86 |
|
|
|