-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModule2.bas
More file actions
201 lines (180 loc) · 6.54 KB
/
Module2.bas
File metadata and controls
201 lines (180 loc) · 6.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
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
Attribute VB_Name = "Module2"
Public N1500P As Meters
Public N1450 As Meters
Public S200 As Meters
Public S250 As Meters
Public S270 As Meters
Public Sub Setmeters()
Set N1500P = New Meters
With N1500P
'.Normal = False 'Muna
.Normal = True
.CurrentSag = True
.Duration = 3000
.VSurge = 110
.VSag = 90
.ISurge = 200
.ISag = 0
End With
Set S200 = New Meters
With S200
.Normal = False
.CurrentSag = False
.Duration = 533
.VSurge = 120
.VSag = 80
.ISurge = 200
.ISag = 0
End With
Set S250 = New Meters
With S250
.Normal = False
.CurrentSag = False
.Duration = 533
.VSurge = 120
.VSag = 80
.ISurge = 200
.ISag = 0
End With
Set S270 = New Meters
With S270
.Normal = False
.CurrentSag = False
.Duration = 533
.VSurge = 120
.VSag = 80
.ISurge = 200
.ISag = 0
End With
End Sub
Public Sub Colorize(MType As String, cnt As Integer)
Dim Unit As Meters
eventE = 0
If MType = "Nexus 1500+" Then
Set Unit = N1500P
ElseIf MType = "Nexus 1450" Then
Set Unit = N1450
ElseIf MType = "Shark 200" Then
Set Unit = S200
ElseIf MType = "Shark 250" Then
Set Unit = S250
ElseIf MType = "Shark 270" Then
Set Unit = S700
End If
For i = 1 To cnt
Dim Act As Double
Dim Exp As Double
Dim StatA As String
Dim StatE As String
Dim StatAf As String
Dim StatEf As String
Dim Param
Dim Thres As Double
Thres = CDbl(ActiveWorkbook.Sheets("Main").Range("D11").Value) * 100
If ThisW.Range(Cells(2 + i, 2).Address()).Value <> "" Then
If Left(ThisW.Range(Cells(2 + i, 2).Address()).Value, 1) = "V" Then
If Mid(ThisW.Range(Cells(2 + i, 2).Address()).Value, 4, 3) = "Sur" Then
Exp = DUT(MType).VSurge
ElseIf Mid(ThisW.Range(Cells(2 + i, 2).Address()).Value, 4, 3) = "Sag" Then
Exp = DUT(MType).VSag
End If
ElseIf Left(ThisW.Range(Cells(2 + i, 2).Address()).Value, 1) = "I" Then
If Mid(ThisW.Range(Cells(2 + i, 2).Address()).Value, 4, 3) = "Sur" Then
Exp = DUT(MType).ISurge
ElseIf Mid(ThisW.Range(Cells(2 + i, 2).Address()).Value, 4, 3) = "Sag" Then
Exp = DUT(MType).ISag
End If
End If
StatEf = Split(ThisW.Range(Cells(2 + i, 2).Address()).Value, "|")(0)
Else
StatE = ""
End If
If ThisW.Range(Cells(2 + i, 5).Address()).Value <> "" Then
Act = CDbl(Replace(Split(ThisW.Range(Cells(2 + i, 5).Address()).Value, "|")(1), "%", "")) 'Value%
Param = Left(ThisW.Range(Cells(2 + i, 5).Address()).Value, 1) 'Volts or Cur
StatA = Mid(ThisW.Range(Cells(2 + i, 5).Address()).Value, 4, 3) 'Sag or Surge
StatAf = Split(ThisW.Range(Cells(2 + i, 5).Address()).Value, "|")(0) 'All
Else
StatAf = ""
End If
If StatEf <> StatAf Then
If StatAf <> "" Then
If StatA = "Nor" Then
If (100 - Act) < Thres Or (Act - 100) < Thres Then
ThisW.Range(Cells(2 + i, 5).Address()).Interior.Color = RGB(144, 238, 144)
End If
Else
ThisW.Range(Cells(2 + i, 5).Address()).Interior.Color = RGB(205, 92, 92)
eventE = eventE + 1
End If
End If
ElseIf StatEf = StatAf Then
If StatA = "Sur" Then
If Param = "V" Then
If (Act - Unit.VSurge) < Thres Then
ThisW.Range(Cells(2 + i, 5).Address()).Interior.Color = RGB(144, 238, 144) 'Green
Else
ThisW.Range(Cells(2 + i, 5).Address()).Interior.Color = RGB(205, 92, 92) 'Red
eventE = eventE + 1
End If
ElseIf Param = "I" Then
If (Act - Unit.ISurge) < Thres Then
ThisW.Range(Cells(2 + i, 5).Address()).Interior.Color = RGB(144, 238, 144)
Else
ThisW.Range(Cells(2 + i, 5).Address()).Interior.Color = RGB(205, 92, 92)
eventE = eventE + 1
End If
End If
ElseIf StatA = "Sag" Then
If Param = "V" Then
If (Unit.VSag - Act) < Thres Then
ThisW.Range(Cells(2 + i, 5).Address()).Interior.Color = RGB(144, 238, 144)
Else
ThisW.Range(Cells(2 + i, 5).Address()).Interior.Color = RGB(205, 92, 92)
eventE = eventE + 1
End If
ElseIf Param = "I" Then
If (Unit.ISag - Act) < Thres Then
ThisW.Range(Cells(2 + i, 5).Address()).Interior.Color = RGB(144, 238, 144)
Else
ThisW.Range(Cells(2 + i, 5).Address()).Interior.Color = RGB(205, 92, 92)
eventE = eventE + 1
End If
End If
End If
End If
Next i
End Sub
Public Function CoAd(Col As Integer, Row As Integer) As String
CoAd = Range("B1").Offset(Row, Col).Address()
End Function
Public Function DUT(MType As String) As Meters
Dim Unit As Meters
If MType = "Nexus 1500+" Then
Set Unit = N1500P
ElseIf MType = "Nexus 1450" Then
Set Unit = N1450
ElseIf MType = "Shark 200" Then
Set Unit = S200
ElseIf MType = "Shark 250" Then
Set Unit = S250
ElseIf MType = "Shark 270" Then
Set Unit = S270
End If
Set DUT = Unit
End Function
Public Function Normals(MType As String) As Boolean
Dim Unit As Meters
If MType = "Nexus 1500+" Then
Set Unit = N1500P
ElseIf MType = "Nexus 1450" Then
Set Unit = N1450
ElseIf MType = "Shark 200" Then
Set Unit = S200
ElseIf MType = "Shark 250" Then
Set Unit = S250
ElseIf MType = "Shark 270" Then
Set Unit = S270
End If
Normals = Unit.Normal
End Function