-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathSwitch.java
More file actions
82 lines (74 loc) · 1.91 KB
/
Switch.java
File metadata and controls
82 lines (74 loc) · 1.91 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
package com.powerdata.openpa;
/*
* Copyright (c) 2016, PowerData Corporation, Incremental Systems Corporation
* All rights reserved.
* Licensed under the BSD-3 Clause License.
* See full license at https://powerdata.github.io/openpa/LICENSE.md
*/
public class Switch extends TwoTermDev
{
public enum State
{
Closed(false), Open(true);
State(boolean st) {_state = st;}
boolean _state;
public boolean getState() {return _state;}
public static State fromBoolean(boolean b) {return b?State.Open:State.Closed;}
public static State[] fromBoolean(boolean[] b)
{
int n = b.length;
State[] rv = new State[n];
for(int i=0; i < n; ++i)
rv[i] = fromBoolean(b[i]);
return rv;
}
public static State fromString(String s)
{
char c = Character.toLowerCase(s.charAt(0));
return (c=='t'||c=='o')?State.Open:State.Closed;
}
public static State[] fromString(String[] s)
{
int n = s.length;
State[] rv = new State[n];
for(int i=0; i < n; ++i)
rv[i] = fromString(s[i]);
return rv;
}
}
SwitchList _list;
public Switch(SwitchList list, int ndx)
{
super(list, ndx);
_list = list;
}
public State getState() throws PAModelException {return _list.getState(_ndx);}
public void setState(State state) throws PAModelException
{
_list.setState(_ndx, state);
}
public boolean isOperableUnderLoad() throws PAModelException
{
return _list.isOperableUnderLoad(_ndx);
}
public void setOperableUnderLoad(boolean op) throws PAModelException
{
_list.setOperableUnderLoad(_ndx, op);
}
public boolean isEnabled() throws PAModelException
{
return _list.isEnabled(_ndx);
}
public void setEnabled(boolean enable) throws PAModelException
{
_list.setEnabled(_ndx, enable);
}
public float getTransitTime() throws PAModelException
{
return _list.getTransitTime(_ndx);
}
public void setTransitTime(float t) throws PAModelException
{
_list.setTransitTime(_ndx, t);
}
}