Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
231 lines (181 loc) · 5.49 KB

File metadata and controls

231 lines (181 loc) · 5.49 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
package depthReadout;
import java.awt.Frame;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.Serializable;
import javax.swing.JMenuItem;
import javax.swing.Timer;
import Array.ArrayManager;
import PamController.PamControlledUnit;
import PamController.PamControlledUnitSettings;
import PamController.PamController;
import PamController.PamControllerInterface;
import PamController.PamSettingManager;
import PamController.PamSettings;
import PamView.PamSidePanel;
import PamView.dialog.warn.WarnOnce;
public class DepthControl extends PamControlledUnit implements PamSettings {
private DepthSystem depthSystem;
private Timer timer;
private DepthProcess depthProcess;
protected DepthParameters depthParameters = new DepthParameters();
private DepthSidePanel depthSidePanel;
int[] sensorMap;
public DepthControl(String unitName) {
super("Hydrophone Depth Readout", unitName);
PamSettingManager.getInstance().registerSettings(this);
warnObsolete();
createDepthSystem(depthParameters.systemNumber);
addPamProcess(depthProcess = new DepthProcess(this));
// ArrayManager.getArrayManager().setDepthControl(this);
timer = new Timer((int) (depthParameters.pollTime * 1000), new TimerListener());
newSettings();
depthSidePanel = new DepthSidePanel(this);
startTimer();
}
private void warnObsolete() {
String msg = "The depth measurement module has changed and you should now use the analog array sensors module." +
"<p>If you continue to use this module, you should change the sensor readout settings for each array streamer to use data from this module";
WarnOnce.showWarning(getUnitName(), msg, WarnOnce.WARNING_MESSAGE);
}
@Override
public boolean removeUnit() {
super.removeUnit();
// ArrayManager.getArrayManager().setDepthControl(null);
return true;
}
class TimerListener implements ActionListener {
@Override
public void actionPerformed(ActionEvent e) {
depthProcess.readDepthData();
}
}
private void newSettings() {
makeSensorMap();
startTimer();
}
private void startTimer() {
if (PamController.getInstance().getRunMode() == PamController.RUN_NORMAL) {
timer.setDelay((int)(depthParameters.pollTime * 1000));
timer.stop();
timer.setInitialDelay(0);
timer.start();
}
}
private boolean makeSensorMap() {
/*
* Make a map of shich sensor is connected with which hydrophone.
* basically reversing the hydrophone lookup tables in DepthParameters.
*
*/
ArrayManager arrayManager = ArrayManager.getArrayManager();
int nPhones = arrayManager.getCurrentArray().getHydrophoneCount();
sensorMap = new int[nPhones];
for (int iSensor = 0; iSensor < depthParameters.nSensors; iSensor++) {
sensorMap[iSensor] = -1;
}
int hMap;
if (depthParameters.hydrophoneMaps == null) {
return false;
}
for (int iSensor = 0; iSensor < depthParameters.nSensors; iSensor++) {
if (iSensor >= depthParameters.hydrophoneMaps.length ) {
return false;
}
hMap = depthParameters.hydrophoneMaps[iSensor];
for (int iP = 0; iP < nPhones; iP++) {
if ((hMap & 1<< iP) != 0) {
sensorMap[iP] = iSensor;
}
}
}
return true;
}
/**
* Return the sensor number for a particular hydrophone or -1 if this
* hydrophone is not associated with a sensor.
* @param iPhone
* @return sensor number for a given hydrophone
*/
public int getSensorForHydrophone(int iPhone) {
if (iPhone >= sensorMap.length) {
return -1;
}
return sensorMap[iPhone];
}
public DepthDataBlock getDepthDataBlock() {
return depthProcess.getDepthDataBlock();
}
public int getNumDepthSystems() {
return 1;
}
public String getDepthSystemName(int iSystem) {
return "Measurement Computing analog readout";
}
private boolean createDepthSystem(int iSystem) {
switch(iSystem) {
case 0:
setDepthSystem(new MccDepthSystem(this));
return true;
default:
setDepthSystem(null);
return false;
}
}
private void setDepthSystem(DepthSystem depthSystem) {
this.depthSystem = depthSystem;
}
public DepthSystem getDepthSystem() {
return depthSystem;
}
@Override
public PamSidePanel getSidePanel() {
if (depthSidePanel == null) {
depthSidePanel = new DepthSidePanel(this);
}
return depthSidePanel;
}
@Override
public JMenuItem createDetectionMenu(Frame parentFrame) {
// JMenu menu = new JMenu(getUnitName());
JMenuItem menuItem = new JMenuItem(getUnitName() + " settings ...");
menuItem.addActionListener(new DetectionMenuAction(parentFrame));
return menuItem;
}
@Override
public void notifyModelChanged(int changeType) {
if (changeType == PamControllerInterface.NEW_SCROLL_TIME) {
newViewTimes();
}
}
private void newViewTimes() {
depthSidePanel.newViewTimes();
}
class DetectionMenuAction implements ActionListener {
private Frame parentFrame;
public DetectionMenuAction(Frame parentFrame) {
super();
this.parentFrame = parentFrame;
}
@Override
public void actionPerformed(ActionEvent e) {
if (depthSystem != null && depthSystem.canConfigure()) {
depthSystem.configureSensor(parentFrame);
}
newSettings();
}
}
@Override
public Serializable getSettingsReference() {
return depthParameters;
}
@Override
public long getSettingsVersion() {
return DepthParameters.serialVersionUID;
}
@Override
public boolean restoreSettings(PamControlledUnitSettings pamControlledUnitSettings) {
depthParameters = ((DepthParameters) pamControlledUnitSettings.getSettings()).clone();
return true;
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.