-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathModbusAnalyzer.h
65 lines (50 loc) · 2.01 KB
/
ModbusAnalyzer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#ifndef MODBUS_ANALYZER_H
#define MODBUS_ANALYZER_H
#include <Analyzer.h>
#include "ModbusAnalyzerResults.h"
#include "ModbusSimulationDataGenerator.h"
#include "ModbusAnalyzerModbusExtension.h"
#include <stdio.h>
#include <string.h>
class ModbusAnalyzerSettings;
class ModbusAnalyzer : public Analyzer2
{
public:
ModbusAnalyzer();
virtual ~ModbusAnalyzer();
virtual void SetupResults();
virtual void WorkerThread();
virtual U32 GenerateSimulationData( U64 newest_sample_requested, U32 sample_rate, SimulationChannelDescriptor** simulation_channels );
virtual U32 GetMinimumSampleRateHz();
virtual const char* GetAnalyzerName() const;
virtual bool NeedsRerun();
#pragma warning( push )
#pragma warning( \
disable : 4251 ) // warning C4251: 'ModbusAnalyzer::<...>' : class <...> needs to have dll-interface to be used by clients of class
protected: // functions
void ComputeSampleOffsets();
U64 GetNextByteModbus( U32 num_bits, U64 bit_mask, U64& frame_starting_sample, U64& frame_ending_sample );
int ASCII2INT( char value );
protected: // vars
std::auto_ptr<ModbusAnalyzerSettings> mSettings;
std::auto_ptr<ModbusAnalyzerResults> mResults;
AnalyzerChannelData* mModbus;
ModbusSimulationDataGenerator mSimulationDataGenerator;
bool mSimulationInitilized;
// Modbus analysis vars:
U32 mSampleRateHz;
std::vector<U32> mSampleOffsets;
U32 mParityBitOffset;
U32 mStartOfStopBitOffset;
BitState mBitLow;
BitState mBitHigh;
// Checksum caluclations for Modbus
U16 crc_tab16[ 256 ];
void init_crc16_tab( void );
U16 update_CRC( U16 crc, U8 c );
#pragma warning( pop )
};
extern "C" ANALYZER_EXPORT const char* __cdecl GetAnalyzerName();
extern "C" ANALYZER_EXPORT Analyzer* __cdecl CreateAnalyzer();
extern "C" ANALYZER_EXPORT void __cdecl DestroyAnalyzer( Analyzer* analyzer );
#endif // MODBUS_ANALYZER_H