GithubHelp home page GithubHelp logo

Comments (4)

kyle-github avatar kyle-github commented on June 12, 2024

I looked briefly at B4X. Seems nice, but it is commercial. If you are working on a new wrapper, I would suggest wrapping the C library directly.

The way that you are calling each tag with a timeout will serialize the tag access and prevent the library from getting good performance.

For the best performance, you should start reading in asynchronous mode. You do that by calling read, but with a timeout of zero. The C library will start reading in the background. You can either set up a callback function or check the status of the tag to tell when the read is done. The status will be PLCTAG_STATUS_PENDING while the read is happening and will change to PLCTAG_STATUS_OK when it is done. If it changes to anything else, an error occurred. The example program async.c shows how to do this (in C, so hopefully you can translate that to your language).

from libplctag4j.

InofensivoJimmy avatar InofensivoJimmy commented on June 12, 2024

Something like this?

Private Sub bucle
Do While working

	rc=tag4.Read(0)
	If Not(rc=tag4.PLCTAG_STATUS_OK) Then
'		Log ("Unable to create the tag")
	Else
'		Log("Tag created")
	End If
	
	val4 = tag4.GetString(0)
	LabelTAG_STRING.Text = val4
	

	Sleep(50)
Loop

End Sub

it works really well, I was just wondering if reading the status of many tags constantly affects the performance of the device.

from libplctag4j.

kyle-github avatar kyle-github commented on June 12, 2024

Reading status does not impact performance. Only read() and write() go to the PLC. Inside the library these are asynchronous operations. If you have a timeout, then the library waits at least that long for the operation to complete. If you have no timeout then the library will start the operation and you can wait for it to complete by checking the status. Internally, the library will check for a response from the PLC.

The PLC cannot handle a very high rate of network packets. But, it can handle many requests per packet. So the best performance is to use asynchronous mode and trigger many reads/writes at once, then wait for them to complete.

from libplctag4j.

InofensivoJimmy avatar InofensivoJimmy commented on June 12, 2024

thanks for the explanation

from libplctag4j.

Related Issues (6)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.