ngscopeclient 0.1-dev+51fbda87c
FunctionGeneratorState.h
Go to the documentation of this file.
1/***********************************************************************************************************************
2* *
3* ngscopeclient *
4* *
5* Copyright (c) 2012-2024 Andrew D. Zonenberg *
6* All rights reserved. *
7* *
8* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the *
9* following conditions are met: *
10* *
11* * Redistributions of source code must retain the above copyright notice, this list of conditions, and the *
12* following disclaimer. *
13* *
14* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the *
15* following disclaimer in the documentation and/or other materials provided with the distribution. *
16* *
17* * Neither the name of the author nor the names of any contributors may be used to endorse or promote products *
18* derived from this software without specific prior written permission. *
19* *
20* THIS SOFTWARE IS PROVIDED BY THE AUTHORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
21* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL *
22* THE AUTHORS BE HELD LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES *
23* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR *
24* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
25* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE *
26* POSSIBILITY OF SUCH DAMAGE. *
27* *
28***********************************************************************************************************************/
29
35#ifndef FunctionGeneratorState_h
36#define FunctionGeneratorState_h
37
42{
43public:
44
45 FunctionGeneratorState(std::shared_ptr<FunctionGenerator> generator)
46 {
47 size_t n = generator->GetChannelCount();
48 m_channelActive = std::make_unique<std::atomic<bool>[] >(n);
49 m_channelAmplitude = std::make_unique<std::atomic<float>[] >(n);
50 m_channelOffset= std::make_unique<std::atomic<float>[] >(n);
51 m_channelFrequency = std::make_unique<std::atomic<float>[] >(n);
52 m_channelShape = std::make_unique<std::atomic<FunctionGenerator::WaveShape>[] >(n);
53 m_channelOutputImpedance = std::make_unique<std::atomic<FunctionGenerator::OutputImpedance>[] >(n);
54 m_channelShapes = std::make_unique<std::vector<FunctionGenerator::WaveShape>[] >(n);
55 m_channelShapeIndexes = std::make_unique<std::map<FunctionGenerator::WaveShape,int>[] >(n);
56 m_channelShapeNames = std::make_unique<std::vector<std::string>[] >(n);
57
58 m_needsUpdate = std::make_unique<std::atomic<bool>[] >(n);
59
60 for(size_t i=0; i<n; i++)
61 {
62 m_channelActive[i] = false;
63 m_channelAmplitude[i] = 0;
64 m_channelOffset[i] = 0;
65 m_channelFrequency[i] = 0;
66 m_channelShape[i] = FunctionGenerator::WaveShape::SHAPE_SINE;
67 m_channelOutputImpedance[i] = FunctionGenerator::OutputImpedance::IMPEDANCE_HIGH_Z;
68 // Init shape list and names
69 m_channelShapes[i] = generator->GetAvailableWaveformShapes(i);
70 for(size_t j=0; j<m_channelShapes[i].size(); j++)
71 {
72 m_channelShapeNames[i].push_back(generator->GetNameOfShape(m_channelShapes[i][j]));
73 m_channelShapeIndexes[i][m_channelShapes[i][j]] = j;
74 }
75
76 m_needsUpdate[i] = true;
77 }
78 }
79
80 std::unique_ptr<std::atomic<bool>[]> m_channelActive;
81 std::unique_ptr<std::atomic<float>[]> m_channelAmplitude;
82 std::unique_ptr<std::atomic<float>[]> m_channelOffset;
83 std::unique_ptr<std::atomic<float>[]> m_channelFrequency;
84 std::unique_ptr<std::atomic<FunctionGenerator::WaveShape>[]> m_channelShape;
85 std::unique_ptr<std::atomic<FunctionGenerator::OutputImpedance>[]> m_channelOutputImpedance;
86 std::unique_ptr<std::vector<FunctionGenerator::WaveShape>[]> m_channelShapes;
87 std::unique_ptr<std::map<FunctionGenerator::WaveShape,int>[]> m_channelShapeIndexes;
88 std::unique_ptr<std::vector<std::string>[]> m_channelShapeNames;
89
90 std::unique_ptr<std::atomic<bool>[]> m_needsUpdate;
91
92};
93
94#endif
Current status of a Function Generator.
Definition: FunctionGeneratorState.h:42