-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathStructs.cs
More file actions
149 lines (131 loc) · 3.54 KB
/
Structs.cs
File metadata and controls
149 lines (131 loc) · 3.54 KB
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
//
// Structs.cs
//
// Author:
// Jae Stutzman <jaebird@gmail.com>
//
// Copyright (c) 2016 Jae Stutzman
//
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation; either version 2.1 of the
// License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
using System;
using System.Runtime.InteropServices;
namespace HamLibSharp
{
[StructLayout (LayoutKind.Explicit)]
public struct Value
{
// Signed integer
[FieldOffset (0)]
int i;
// Single precision float
[FieldOffset (0)]
float f;
// Pointer to char string
[MarshalAs (UnmanagedType.LPStr)]
[FieldOffset (0)]
string s;
// Pointer to constant char string
[MarshalAs (UnmanagedType.LPStr)]
[FieldOffset (0)]
string cs;
}
/// Numeric type
[StructLayout (LayoutKind.Sequential)]
struct paramN
{
/// Minimum value
float min;
/// Maximum value
float max;
/// Step
float step;
}
/// Combo type
[StructLayout (LayoutKind.Sequential)]
struct paramC
{
/// Combo list
[MarshalAs (UnmanagedType.LPStr)]
string combostr;
}
[StructLayout (LayoutKind.Explicit)]
struct paramU
{
[FieldOffset (0)]
[MarshalAs (UnmanagedType.Struct)]
paramN n;
[FieldOffset (0)]
[MarshalAs (UnmanagedType.Struct)]
paramC c;
}
// TODO: ConfigurationParameter still needs to attention due to C unions ///
// TODO: the value_t union makes this difficult
[StructLayout (LayoutKind.Sequential)]
public struct Granularity
{
// Minimum value
IntPtr min;
// Maximum value
IntPtr max;
// Step
IntPtr step;
}
// Frequency range
// Put together a group of this struct in an array to define
// what frequencies your rig has access to.
[StructLayout (LayoutKind.Sequential)]
public struct FrequencyRange
{
public double Start { get { return start; } }
public double End { get { return end; } }
public RigMode Modes { get { return modes; } }
public int LowPower { get { return low_power; } }
public int HighPower { get { return high_power; } }
public int Vfo { get { return vfo; } }
public int Antenna { get { return ant; } }
// Start frequency
double start;
// End frequency
double end;
// Bit field of RIG_MODE's
RigMode modes;
// Lower RF power in mW, -1 for no power (ie. rx list)
int low_power;
// Higher RF power in mW, -1 for no power (ie. rx list)
int high_power;
// VFO list equipped with this range
int vfo;
// Antenna list equipped with this range, 0 means all
int ant;
}
// Calibration table struct
[StructLayout (LayoutKind.Sequential)]
public class CalibrationTable
{
[StructLayout (LayoutKind.Sequential)]
public struct TableDef
{
// raw (A/D) value, as returned by \a RIG_LEVEL_RAWSTR
int raw;
// associated value, basically the measured dB value
int val;
}
// number of plots in the table
int size;
// table of plots
[MarshalAs (UnmanagedType.ByValArray, ArraySubType = UnmanagedType.Struct, SizeConst = Rig.MAX_CAL_LENGTH)]
TableDef[] table = new CalibrationTable.TableDef[Rig.MAX_CAL_LENGTH];
};
}