plc4x icon indicating copy to clipboard operation
plc4x copied to clipboard

[Feature Request][OPC-UA]: PublishRequest is required to reduce server pressure

Open zhyang-liu opened this issue 2 years ago • 1 comments

What would you like to happen?

  1. it seems that SubscriptionRequestBuilder is not working properly, it aways saying "opcua.tag isn't a PlcSubscriptionTag".
  2. It seems that PublishRequest is only implemented in MSpec, but is not used.
{
	subRequest, err := connection.SubscriptionRequestBuilder().
		AddChangeOfStateTagAddress("field1", "ns=1;s=values/int64").
		Build()
	if err != nil {
		fmt.Println(fmt.Errorf("error preparing subscription-request: %s", err.Error()))
		// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
		// error preparing subscription-request: *opcua.tag isn't a PlcSubscriptionTag

		os.Exit(1)
	}
	subRequestResult := <-subRequest.Execute()
	if subRequestResult.GetErr() != nil {
		fmt.Println(fmt.Errorf("error executing subscription-request: %s", subRequestResult.GetErr().Error()))
		os.Exit(1)
	}
	resp := subRequestResult.GetResponse()
	fmt.Println(resp.String())
	handle, err := resp.GetSubscriptionHandle("field1")
	if err != nil {
		fmt.Println(fmt.Errorf("error getting handle: %s", err.Error()))
		os.Exit(1)
	}
	handle.Register(func(event model.PlcSubscriptionEvent) {
		fmt.Println("got event:\n", event.String())
	})
}

Programming Languages

  • [ ] plc4j
  • [X] plc4go
  • [ ] plc4c
  • [ ] plc4net

Protocols

  • [ ] AB-Ethernet
  • [ ] ADS /AMS
  • [ ] BACnet/IP
  • [ ] CANopen
  • [ ] DeltaV
  • [ ] DF1
  • [ ] EtherNet/IP
  • [ ] Firmata
  • [ ] KNXnet/IP
  • [ ] Modbus
  • [X] OPC-UA
  • [ ] S7

zhyang-liu avatar Jan 25 '24 08:01 zhyang-liu

Well ... generally the PLC4X API didn't have the concept of a Publish operation, but I have started on working on a PublishAPI extension ... so I guess that#s the reason we haven't got any publish-support yet.

chrisdutz avatar Feb 06 '24 09:02 chrisdutz