l@272: /***** Scope.h *****/ l@272: #ifndef __Scope_H_INCLUDED__ l@272: #define __Scope_H_INCLUDED__ l@272: l@272: #include l@272: #include l@272: #include l@272: giuliomoro@475: #define OSC_RECEIVE_PORT 8675 l@272: #define OSC_SEND_PORT 8676 l@272: #define SCOPE_UDP_PORT 8677 l@272: l@272: #define FRAMES_STORED 2 l@272: l@272: class Scope{ l@272: public: l@272: Scope(); l@272: giuliomoro@485: /** giuliomoro@485: * Setup the Scope. giuliomoro@485: * giuliomoro@485: * @param numChannels number of channels in the scope. giuliomoro@485: * @param sampleRate sampleRate of the data passed in. giuliomoro@485: */ l@272: void setup(unsigned int numChannels, float sampleRate); giuliomoro@485: giuliomoro@485: /** giuliomoro@485: * Logs a frame of data to the scope. giuliomoro@485: * giuliomoro@485: * Pass one argument per channel (starting from the first), up to the giuliomoro@485: * number of channels of the object. giuliomoro@485: * Omitted values will be set to 0. giuliomoro@485: */ l@272: void log(float chn1, ...); giuliomoro@485: giuliomoro@485: /** giuliomoro@485: * Logs a frame of data to the scope. giuliomoro@485: * giuliomoro@485: * @param values a pointer to an array containing numChannels values. giuliomoro@485: */ giuliomoro@485: void log(float* values); l@272: bool trigger(); l@272: l@272: private: l@272: OSCServer oscServer; l@272: OSCClient oscClient; l@272: UdpClient socket; l@272: l@272: void parseMessage(oscpkt::Message); l@272: void start(); l@272: void stop(); l@272: void doTrigger(); l@272: void triggerNormal(); l@272: void triggerAuto(); l@272: void scheduleSendBufferTask(); l@272: void sendBuffer(); l@272: void customTrigger(); l@272: bool triggered(); l@272: l@272: // settings l@272: int numChannels; l@272: float sampleRate; l@272: int connected; l@272: int frameWidth; l@272: int triggerMode; l@272: int triggerChannel; l@272: int triggerDir; l@272: float triggerLevel; l@272: int xOffset; l@272: int upSampling; l@272: int downSampling; l@272: float holdOff; l@272: l@272: int channelWidth; l@272: int downSampleCount; l@272: int holdOffSamples; l@272: l@272: // buffers l@272: std::vector buffer; l@272: std::vector outBuffer; l@272: l@272: // pointers l@272: int writePointer; l@272: int readPointer; l@272: int triggerPointer; l@272: int customTriggerPointer; l@272: l@272: // trigger status l@272: bool triggerPrimed; l@272: bool triggerCollecting; l@272: bool triggerWaiting; l@272: bool triggering; l@272: int triggerCount; l@272: int autoTriggerCount; l@272: bool started; l@272: bool customTriggered; l@272: l@272: // aux tasks l@272: AuxiliaryTask scopeTriggerTask; l@272: static void triggerTask(void*); l@272: l@272: AuxiliaryTask scopeSendBufferTask; l@272: static void sendBufferTask(void*); l@272: l@272: }; l@272: giuliomoro@485: #endif