Skip to content

Commit 84ab841

Browse files
authored
Merge pull request #21 from Paashaas/master
added client connect, client close connection, reservation URCB, get number of open connections
2 parents 552aa68 + 178b74c commit 84ab841

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

client_rcb.go

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ type OptFlds struct {
3030
type ClientReportControlBlock struct {
3131
Ena bool // 使能
3232
IntgPd int // 周期上送时间
33+
Resv bool // Reservation for URCB
3334
TrgOps TrgOps // 触发条件
3435
OptFlds OptFlds // 报告选项
3536
}
@@ -45,6 +46,7 @@ func (c *Client) GetRCBValues(objectReference string) (*ClientReportControlBlock
4546
return &ClientReportControlBlock{
4647
Ena: c.getRCBEnable(rcb),
4748
IntgPd: int(c.getRCBIntgPd(rcb)),
49+
Resv: c.getRCBResv(rcb),
4850
TrgOps: c.getTrgOps(rcb),
4951
OptFlds: c.getOptFlds(rcb),
5052
}, nil
@@ -60,6 +62,11 @@ func (c *Client) getRCBIntgPd(rcb C.ClientReportControlBlock) uint32 {
6062
return uint32(intgPd)
6163
}
6264

65+
func (c *Client) getRCBResv(rcb C.ClientReportControlBlock) bool {
66+
resv := C.ClientReportControlBlock_getResv(rcb)
67+
return bool(resv)
68+
}
69+
6370
func (c *Client) getOptFlds(rcb C.ClientReportControlBlock) OptFlds {
6471
optFlds := C.ClientReportControlBlock_getOptFlds(rcb)
6572
g := int(optFlds)
@@ -140,11 +147,18 @@ func (c *Client) SetRCBValues(objectReference string, settings ClientReportContr
140147
optFlds = optFlds | C.RPT_OPT_CONF_REV
141148
}
142149

143-
C.ClientReportControlBlock_setTrgOps(rcb, trgOps) // 触发条件
144-
C.ClientReportControlBlock_setRptEna(rcb, C.bool(settings.Ena)) // 报告使能
150+
C.ClientReportControlBlock_setTrgOps(rcb, trgOps) // 触发条件
151+
C.ClientReportControlBlock_setRptEna(rcb, C.bool(settings.Ena)) // 报告使能
152+
C.ClientReportControlBlock_setResv(rcb, C.bool(settings.Resv))
145153
C.ClientReportControlBlock_setIntgPd(rcb, C.uint32_t(settings.IntgPd)) // 周期上送时间
146154
C.ClientReportControlBlock_setOptFlds(rcb, optFlds)
147-
C.IedConnection_setRCBValues(c.conn, &clientError, rcb, C.RCB_ELEMENT_RPT_ENA|C.RCB_ELEMENT_TRG_OPS|C.RCB_ELEMENT_INTG_PD, true)
155+
156+
if bool(C.ClientReportControlBlock_isBuffered(rcb)) {
157+
C.IedConnection_setRCBValues(c.conn, &clientError, rcb, C.RCB_ELEMENT_RPT_ENA|C.RCB_ELEMENT_TRG_OPS|C.RCB_ELEMENT_INTG_PD, true)
158+
} else {
159+
C.IedConnection_setRCBValues(c.conn, &clientError, rcb, C.RCB_ELEMENT_RESV|C.RCB_ELEMENT_RPT_ENA|C.RCB_ELEMENT_TRG_OPS|C.RCB_ELEMENT_INTG_PD, true)
160+
}
161+
148162
if err := GetIedClientError(clientError); err != nil {
149163
return err
150164
}

server.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,11 @@ func (is *IedServer) GetUTCTimeAttributeValue(node *ModelNode) int64 {
130130
return int64(timestamp)
131131
}
132132

133+
// GetNumberOfOpenConnections reads the amount of connections with the server
134+
func (is *IedServer) GetNumberOfOpenConnections() int {
135+
return int(C.IedServer_getNumberOfOpenConnections(is.server))
136+
}
137+
133138
// SetServerIdentity updates the server identity of the IedServer
134139
func (is *IedServer) SetServerIdentity(vendor string, model string, version string) {
135140
cVendor := C.CString(vendor)

0 commit comments

Comments
 (0)