-
Notifications
You must be signed in to change notification settings - Fork 0
/
UiController.m
233 lines (207 loc) · 8.83 KB
/
UiController.m
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
232
233
//
// UiController.m
// AudioRouter
//
// Created by Ward Witt on 11/9/07.
// Copyright 2009 The Filmworkers Club. All rights reserved.
//
#import "UiController.h"
#import "PrefController.h"
@implementation UiController
static NSDictionary * OIDStrings;
static NSString * slot;
- (BOOL)applicationShouldTerminateAfterLastWindowClosed:
(NSApplication *)AudioRouter {
return YES;
}
- (void)awakeFromNib{
defaults = [NSUserDefaults standardUserDefaults];
[[statusField window]setFrameAutosaveName:@"controllerWindow"]; // save and restore the location of the window
OIDStrings = [NSDictionary dictionaryWithContentsOfFile:[[[NSBundle mainBundle] bundlePath]
stringByAppendingString:@"/Contents/Resources/OIDStrings.plist"]];
if (OIDStrings == nil)
{
NSLog (@"Error unable to open OIDStrings.plist");
}
else
{
}
NSArray * inputs = ([NSArray arrayWithObjects:@"Ch 1", @"Ch 2", @"Ch 3", @"Ch 4",
@"Ch 5", @"Ch 6", @"Ch 7", @"Ch 8", NULL]);
[statusField setStringValue:@""];
[leftPopUp removeAllItems];
[leftPopUp addItemsWithTitles:inputs];
[centerPopUp removeAllItems];
[centerPopUp addItemsWithTitles:inputs];
[rightPopUp removeAllItems];
[rightPopUp addItemsWithTitles:inputs];
[leftSurroundPopUp removeAllItems];
[leftSurroundPopUp addItemsWithTitles:inputs];
[rightSurroundPopUp removeAllItems];
[rightSurroundPopUp addItemsWithTitles:inputs];
[subWooferPopUp removeAllItems];
[subWooferPopUp addItemsWithTitles:inputs];
[leftTotalPopUp removeAllItems];
[leftTotalPopUp addItemsWithTitles:inputs];
[rightTotalPopUp removeAllItems];
[rightTotalPopUp addItemsWithTitles:inputs];
NSString *host = [defaults objectForKey:@"ipAddress"];
NSString *slotPrefix = @".";
NSString *slotNumber = [defaults objectForKey:@"slot"];
if (slotNumber == nil || host == nil) {
if (!prefController) {
prefController = [[PrefController alloc] init];
}
[prefController showWindow:self];
return;
}
slot = [slotPrefix stringByAppendingString:slotNumber];
NSString *community = @"private";
session = [[SnmpSession alloc] initWithHost:host
community:community];
if (nil == session)
{
[statusField setStringValue:@"Not Connected"];
NSLog(@"Not connected");
}else{
[leftPopUp setEnabled:YES];
[rightPopUp setEnabled:YES];
[centerPopUp setEnabled:YES];
[subWooferPopUp setEnabled:YES];
[leftSurroundPopUp setEnabled:YES];
[rightSurroundPopUp setEnabled:YES];
[leftTotalPopUp setEnabled:YES];
[rightTotalPopUp setEnabled:YES];
[aDelayCheckBox setEnabled:YES];
[vDelayPopUp setEnabled:YES];
[self update];
}
}
- (void)update{
// make sure we have a connection
if (nil == session)
{
NSLog(@"NULL session in update");
return;
}
// test the first SNMP get to make sure we are talking to an evertz audio card
NSString * ch1ARoute = [session stringForOid:[[OIDStrings objectForKey:@"ch1ARouteOID"] stringByAppendingString:slot]];
if ([ch1ARoute isEqualToString:@"Error"]) {
if (!prefController) {
prefController = [[PrefController alloc] init];
}
[prefController showWindow:self];
[statusField setStringValue:@"Not Connected"];
return;
}
[leftPopUp selectItemAtIndex:[ch1ARoute intValue]-3];
[rightPopUp selectItemAtIndex:[[session stringForOid:[[OIDStrings objectForKey:@"ch1BRouteOID"] stringByAppendingString:slot]] intValue]-3];
[centerPopUp selectItemAtIndex:[[session stringForOid:[[OIDStrings objectForKey:@"ch2ARouteOID"] stringByAppendingString:slot]] intValue]-3];
[subWooferPopUp selectItemAtIndex:[[session stringForOid:[[OIDStrings objectForKey:@"ch2BRouteOID"] stringByAppendingString:slot]] intValue]-3];
[leftSurroundPopUp selectItemAtIndex:[[session stringForOid:[[OIDStrings objectForKey:@"ch3ARouteOID"] stringByAppendingString:slot]] intValue]-3];
[rightSurroundPopUp selectItemAtIndex:[[session stringForOid:[[OIDStrings objectForKey:@"ch3BRouteOID"] stringByAppendingString:slot]] intValue]-3];
[leftTotalPopUp selectItemAtIndex:[[session stringForOid:[[OIDStrings objectForKey:@"ch4ARouteOID"] stringByAppendingString:slot]] intValue]-3];
[rightTotalPopUp selectItemAtIndex:[[session stringForOid:[[OIDStrings objectForKey:@"ch4BRouteOID"] stringByAppendingString:slot]] intValue]-3];
[aDelayCheckBox setIntValue:[[session stringForOid:[[OIDStrings objectForKey:@"ch1ADelayOID"] stringByAppendingString:slot]] intValue]];
int vd = [[session stringForOid:[[OIDStrings objectForKey:@"videoDelayOID"] stringByAppendingString:slot]] intValue];
if (vd <= 0 || vd < 2)
[vDelayPopUp selectItemAtIndex:vd];
}
- (IBAction)left:(id)sender{
[session setOidIntValue:[[OIDStrings objectForKey:@"ch1ARouteOID"] stringByAppendingString:slot]
value:[sender indexOfSelectedItem] + 3];
}
- (IBAction)center:(id)sender{
[session setOidIntValue:[[OIDStrings objectForKey:@"ch2ARouteOID"] stringByAppendingString:slot]
value:[sender indexOfSelectedItem] + 3];
}
- (IBAction)right:(id)sender{
[session setOidIntValue:[[OIDStrings objectForKey:@"ch1BRouteOID"] stringByAppendingString:slot]
value:[sender indexOfSelectedItem] + 3];
}
- (IBAction)leftSurround:(id)sender{
[session setOidIntValue:[[OIDStrings objectForKey:@"ch3ARouteOID"] stringByAppendingString:slot]
value:[sender indexOfSelectedItem] + 3];
}
- (IBAction)rightSurround:(id)sender{
[session setOidIntValue:[[OIDStrings objectForKey:@"ch3BRouteOID"] stringByAppendingString:slot]
value:[sender indexOfSelectedItem] + 3];
}
- (IBAction)leftTotal:(id)sender{
[session setOidIntValue:[[OIDStrings objectForKey:@"ch4ARouteOID"] stringByAppendingString:slot]
value:[sender indexOfSelectedItem] + 3];
}
- (IBAction)rightTotal:(id)sender{
[session setOidIntValue:[[OIDStrings objectForKey:@"ch4BRouteOID"] stringByAppendingString:slot]
value:[sender indexOfSelectedItem] + 3];
}
- (IBAction)subWoofer:(id)sender{
[session setOidIntValue:[[OIDStrings objectForKey:@"ch2BRouteOID"] stringByAppendingString:slot]
value:[sender indexOfSelectedItem] + 3];
}
- (IBAction)aDelay:(id)sender{
NSString *aDelay = [defaults objectForKey:@"aDelay"];
if (nil == aDelay) {
aDelay = @"66";
}
if(1 == [sender intValue])
{
// Ch 1A delay in ms
[session setOidIntValue:[[OIDStrings objectForKey:@"ch1ADelayOID"] stringByAppendingString:slot]
value:[aDelay intValue]];
// Ch 1B delay in ms
[session setOidIntValue:[[OIDStrings objectForKey:@"ch1BDelayOID"] stringByAppendingString:slot]
value:[aDelay intValue]];
// Ch 2A delay in ms
[session setOidIntValue:[[OIDStrings objectForKey:@"ch2ADelayOID"] stringByAppendingString:slot]
value:[aDelay intValue]];
// Ch 2B delay in ms
[session setOidIntValue:[[OIDStrings objectForKey:@"ch2BDelayOID"] stringByAppendingString:slot]
value:[aDelay intValue]];
// Ch 3A delay in ms
[session setOidIntValue:[[OIDStrings objectForKey:@"ch3ADelayOID"] stringByAppendingString:slot]
value:[aDelay intValue]];
// Ch 3B delay in ms
[session setOidIntValue:[[OIDStrings objectForKey:@"ch3BDelayOID"] stringByAppendingString:slot]
value:[aDelay intValue]];
// Ch 4A delay in ms
[session setOidIntValue:[[OIDStrings objectForKey:@"ch4ADelayOID"] stringByAppendingString:slot]
value:[aDelay intValue]];
// Ch 4B delay in ms
[session setOidIntValue:[[OIDStrings objectForKey:@"ch4BDelayOID"] stringByAppendingString:slot]
value:[aDelay intValue]];
}
else
{
// Ch 1A delay in ms
[session setOidIntValue:[[OIDStrings objectForKey:@"ch1ADelayOID"] stringByAppendingString:slot] value:0];
// Ch 1B delay in ms
[session setOidIntValue:[[OIDStrings objectForKey:@"ch1BDelayOID"] stringByAppendingString:slot] value:0];
// Ch 2A delay in ms
[session setOidIntValue:[[OIDStrings objectForKey:@"ch2ADelayOID"] stringByAppendingString:slot] value:0];
// Ch 2B delay in ms
[session setOidIntValue:[[OIDStrings objectForKey:@"ch2BDelayOID"] stringByAppendingString:slot] value:0];
// Ch 3A delay in ms
[session setOidIntValue:[[OIDStrings objectForKey:@"ch3ADelayOID"] stringByAppendingString:slot] value:0];
// Ch 3B delay in ms
[session setOidIntValue:[[OIDStrings objectForKey:@"ch3BDelayOID"] stringByAppendingString:slot] value:0];
// Ch 4A delay in ms
[session setOidIntValue:[[OIDStrings objectForKey:@"ch4ADelayOID"] stringByAppendingString:slot] value:0];
// Ch 4B delay in ms
[session setOidIntValue:[[OIDStrings objectForKey:@"ch4BDelayOID"] stringByAppendingString:slot] value:0];
}
}
- (IBAction)vDelay:(id)sender{
[session setOidIntValue:[[OIDStrings objectForKey:@"videoDelayOID"] stringByAppendingString:slot]
value:[sender indexOfSelectedItem]];
}
#pragma mark -
#pragma mark Menu Methods
- (IBAction)showPreferencePanel:(id)sender
{
if (!prefController) {
prefController = [[PrefController alloc] init];
}
[prefController showWindow:self];
}
@end