-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathDeviceConfigurator.m
124 lines (97 loc) · 2.82 KB
/
DeviceConfigurator.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
//
// DeviceConfigurator.m
// data_m
//
// Created by Mike Fluff on 3/16/11.
// Copyright 2011 __MyCompanyName__. All rights reserved.
//
#import "DeviceConfigurator.h"
#import "Device.h"
#import "Test_Activity_Controller.h"
@implementation DeviceConfigurator
@synthesize TAC;
@synthesize iperfClients;
- (id)init
{
self = [super init];
if (self) {
// Initialization code here.
}
return self;
}
- (id)initWithTest:(NSString *)test withIntNum:(NSInteger)lnk withPairsNum:(NSInteger)prs devices:(NSSet *)devs
{
self = [super init];
if (self) {
testType = [[NSString alloc] initWithString:test];
links = lnk;
pairs = prs;
neocount = 1;
devices = devs;
iperfClients = [[NSMutableArray alloc] init];
lock = [[NSLock alloc] init];
threadcount = 0;
}
return self;
}
-(id)neo
{
}
-(void)setNeo:(Device *)dev
{
Neo_controller *neo = [[Neo_controller alloc] initWithIp:[dev valueForKey:@"manageip"]];
[neo configureDeviceForTest:testType withIntNum:links withPairsNum:pairs side:nil okt:(10*neocount) type:@"Neo"];
neocount++;
}
-(id)endpoint
{
}
//this method used to configure devices from devSet
-(void)configureDevices
{
for (Device *dev in devices)
{
// NSLog(@"%@",[dev valueForKey:@"type"]);
[self setValue:dev forKey:[dev valueForKey:@"type"]];
}
}
-(void)setEndpoint:(Device *)dev
{
Endpoint_controller *endpoint = [[Endpoint_controller alloc] init];
[endpoint setDelegate:self];
[endpoint initWithIp:[dev valueForKey:@"manageip"] login:[dev valueForKey:@"login"] password:[dev valueForKey:@"password"]];
endpoint.lock = lock;
if([dev.isServer intValue] == YES)
{
[endpoint configureDeviceForTest:testType withIntNum:links withPairsNum:pairs side:@"Right" okt:10*([devices count]-1) type:@"Endpoint"];
// [lock lock];
[NSThread detachNewThreadSelector:@selector(processConfig) toTarget:endpoint withObject:nil];
// [lock unlock];
// [lock lock];
[NSThread detachNewThreadSelector:@selector(startEndpointPerfServer) toTarget:endpoint withObject:nil];
threadcount++;
// [lock unlock];
// [endpoint processConfig];
}
else
{
[endpoint configureDeviceForTest:testType withIntNum:links withPairsNum:pairs side:@"Left" okt:10 type:@"Endpoint"];
// [lock lock];
[NSThread detachNewThreadSelector:@selector(processConfig) toTarget:endpoint withObject:nil];
threadcount++;
// [lock unlock];
// [endpoint processConfig];
[iperfClients addObject:endpoint];
}
}
- (void)threadFinished
{
threadcount--;
if(threadcount == 0)
TAC.isConfigured = YES;
}
- (void)dealloc
{
[super dealloc];
}
@end