@@ -13,6 +13,24 @@ type ControlObjectParam struct {
13
13
OperateTime uint64
14
14
}
15
15
16
+ type ControlObjectParamAPC struct {
17
+ CtlVal float32
18
+ OrIdent string
19
+ OrCat int
20
+ Test bool
21
+ Check bool
22
+ OperateTime uint64
23
+ }
24
+
25
+ type ControlObjectParamINC struct {
26
+ CtlVal int
27
+ OrIdent string
28
+ OrCat int
29
+ Test bool
30
+ Check bool
31
+ OperateTime uint64
32
+ }
33
+
16
34
func NewControlObjectParam (ctlVal bool ) * ControlObjectParam {
17
35
return & ControlObjectParam {
18
36
CtlVal : ctlVal ,
@@ -24,11 +42,121 @@ func NewControlObjectParam(ctlVal bool) *ControlObjectParam {
24
42
}
25
43
}
26
44
45
+ func NewControlObjectParamAPC (ctlVal float32 ) * ControlObjectParamAPC {
46
+ return & ControlObjectParamAPC {
47
+ CtlVal : ctlVal ,
48
+ OrIdent : "" ,
49
+ OrCat : 0 ,
50
+ Test : false ,
51
+ Check : false ,
52
+ OperateTime : 0 ,
53
+ }
54
+ }
55
+
56
+ func NewControlObjectParamINC (ctlVal int ) * ControlObjectParamINC {
57
+ return & ControlObjectParamINC {
58
+ CtlVal : ctlVal ,
59
+ OrIdent : "" ,
60
+ OrCat : 0 ,
61
+ Test : false ,
62
+ Check : false ,
63
+ OperateTime : 0 ,
64
+ }
65
+ }
66
+
27
67
// ControlForDirectWithNormalSecurity 控制模式 1[direct-with-normal-security]
28
68
func (c * Client ) ControlForDirectWithNormalSecurity (objectRef string , ctlVal bool ) error {
29
69
return c .ControlByControlModel (objectRef , CONTROL_MODEL_DIRECT_NORMAL , NewControlObjectParam (ctlVal ))
30
70
}
31
71
72
+ func (c * Client ) ControlByControlModelINC (objectRef string , controlModel ControlModel , param * ControlObjectParamINC ) error {
73
+ cObjectRef := C .CString (objectRef )
74
+ defer C .free (unsafe .Pointer (cObjectRef ))
75
+
76
+ control := C .ControlObjectClient_create (cObjectRef , c .conn )
77
+ if control == nil {
78
+ return CreateControlObjectClientFail
79
+ }
80
+
81
+ ctlVal := C .MmsValue_newIntegerFromInt32 (C .int (param .CtlVal ))
82
+ defer C .MmsValue_delete (ctlVal )
83
+
84
+ switch controlModel {
85
+ case CONTROL_MODEL_SBO_NORMAL :
86
+ if ! bool (C .ControlObjectClient_select (control )) {
87
+ return ControlSelectFail
88
+ }
89
+ case CONTROL_MODEL_DIRECT_ENHANCED :
90
+ C .ControlObjectClient_setCommandTerminationHandler (control , nil , nil )
91
+ case CONTROL_MODEL_SBO_ENHANCED :
92
+ C .ControlObjectClient_setCommandTerminationHandler (control , nil , nil )
93
+ if ! bool (C .ControlObjectClient_selectWithValue (control , ctlVal )) {
94
+ return ControlSelectFail
95
+ }
96
+ }
97
+
98
+ var cOrIdent * C.char
99
+ if param .OrIdent != "" {
100
+ cOrIdent = C .CString (param .OrIdent )
101
+ defer C .free (unsafe .Pointer (cOrIdent ))
102
+ }
103
+
104
+ C .ControlObjectClient_setControlModel (control , C .ControlModel (controlModel ))
105
+ C .ControlObjectClient_setOrigin (control , cOrIdent , C .int (param .OrCat ))
106
+ C .ControlObjectClient_setInterlockCheck (control , C .bool (param .Check ))
107
+ C .ControlObjectClient_setSynchroCheck (control , C .bool (param .Check ))
108
+ C .ControlObjectClient_setTestMode (control , C .bool (param .Test ))
109
+
110
+ if ! bool (C .ControlObjectClient_operate (control , ctlVal , 0 )) {
111
+ return ControlObjectFail
112
+ }
113
+ return nil
114
+ }
115
+
116
+ func (c * Client ) ControlByControlModelAPC (objectRef string , controlModel ControlModel , param * ControlObjectParamAPC ) error {
117
+ cObjectRef := C .CString (objectRef )
118
+ defer C .free (unsafe .Pointer (cObjectRef ))
119
+
120
+ control := C .ControlObjectClient_create (cObjectRef , c .conn )
121
+ if control == nil {
122
+ return CreateControlObjectClientFail
123
+ }
124
+
125
+ ctlVal := C .MmsValue_newFloat (C .float (param .CtlVal ))
126
+ defer C .MmsValue_delete (ctlVal )
127
+
128
+ switch controlModel {
129
+ case CONTROL_MODEL_SBO_NORMAL :
130
+ if ! bool (C .ControlObjectClient_select (control )) {
131
+ return ControlSelectFail
132
+ }
133
+ case CONTROL_MODEL_DIRECT_ENHANCED :
134
+ C .ControlObjectClient_setCommandTerminationHandler (control , nil , nil )
135
+ case CONTROL_MODEL_SBO_ENHANCED :
136
+ C .ControlObjectClient_setCommandTerminationHandler (control , nil , nil )
137
+ if ! bool (C .ControlObjectClient_selectWithValue (control , ctlVal )) {
138
+ return ControlSelectFail
139
+ }
140
+ }
141
+
142
+ var cOrIdent * C.char
143
+ if param .OrIdent != "" {
144
+ cOrIdent = C .CString (param .OrIdent )
145
+ defer C .free (unsafe .Pointer (cOrIdent ))
146
+ }
147
+
148
+ C .ControlObjectClient_setControlModel (control , C .ControlModel (controlModel ))
149
+ C .ControlObjectClient_setOrigin (control , cOrIdent , C .int (param .OrCat ))
150
+ C .ControlObjectClient_setInterlockCheck (control , C .bool (param .Check ))
151
+ C .ControlObjectClient_setSynchroCheck (control , C .bool (param .Check ))
152
+ C .ControlObjectClient_setTestMode (control , C .bool (param .Test ))
153
+
154
+ if ! bool (C .ControlObjectClient_operate (control , ctlVal , 0 )) {
155
+ return ControlObjectFail
156
+ }
157
+ return nil
158
+ }
159
+
32
160
func (c * Client ) ControlByControlModel (objectRef string , controlModel ControlModel , param * ControlObjectParam ) error {
33
161
cObjectRef := C .CString (objectRef )
34
162
defer C .free (unsafe .Pointer (cObjectRef ))
0 commit comments