tomcx / tame4 Goto Github PK
View Code? Open in Web Editor NEWJS library for the access to a TwinCAT PLC. Current version V4.3.1 final.
License: GNU General Public License v3.0
JS library for the access to a TwinCAT PLC. Current version V4.3.1 final.
License: GNU General Public License v3.0
Hello,
Thanks for a great library!
My previous project built with Jquery. Today I have migrate the project to angular2 framework.
There is a problem trying to read arrays or structs. I have followed your documentation but couldn't resolve the issue. Any idea what can be the problem?
Hello!
for me it seems that on iOS devices the onready function isn't called. Could you please habe a look on it.
Hi @tomcx ,
I have an app in Node.js where I used your library. I trying to do write and read request.
The problem is that to use the read function "handles" is necessary. I tried to get it previously with "getHandles()" function but it does not work.
I'm a little lost on the subject of "handles".
You can see my code here: https://github.com/danihbelan/WebSoftPLC/blob/development/privates/softPLC/PLC.js
And thanks for your fantastic library!
Hi there, I apologise if this is really simple to solve. However, I can't manage to get the examples working.
I'm using TwinCat 3. I've created the ADS server and it works. This can be confirmed as I'm able to run a PLC application using Beckhoff's HMI in Visual Studio, connecting to the PLC variables.
I've copied the Tamex file into the IIS virtual directory and I access the site through localhost.
This is my webService setup.
function startClient(handles) {
Plc = TAME.WebServiceClient.createClient({
serviceUrl: 'http://localhost/TcAdsWebService/TcAdsWebService.dll',
//configFileUrl: 'http://192.168.1.2/tamex/resources/demo2.tpy', //Path to the TPY file
amsNetId: '172.16.0.23.1.1',
amsPort: '851', //default
useHandles: handles, //use handles
alignment: '8', //default, set it to "4" if you have TC2 and an ARM based PLC device (i.e. CX90xx), to 8 with TC3
//language: 'ge', //default, set it to "en" for english names of days and months
onReady: loadExample //this function is defined in each example
});
}
And, I've tried various of other combinations. However, I still get XMLHttpRequest always returns an error Status code : 0 and I'm not able to access any of the variables (Read or write) within your examples.
If you could point me in the right direction, that would be greatly appreciated!
Thanks!
Hello,
first many thanks for your great work!
I try with Tame 4.0.1 to connect a variable from TwinCat 3.1 (CX9020) and show
the values in an apache cordova android app. (With TwinCat 2.11 it works)
The connection works. Unfortunately i get no value from plc (MAIN.Ramp1).
Code:
`
(webservice.js)
var Plc;
function startClient(handles) {
Plc = TAME.WebServiceClient.createClient({
serviceUrl: 'http://192.168.1.88/TcAdsWebService/TcAdsWebService.dll',
amsNetId: '192.168.1.88.1.1',
amsPort: '851',
alignment: '8',
language: 'en',
onReady: dataconnection
});
}
(demo.js)
Plc.sumReadReq({
id: 1,
items: [
{
name: 'MAIN.Ramp1',
jvar: 'ai_flow.data'
}
],
oc: function() {
}
});
`
Still needs anything set in the webservice.js like typ paht?
Thanks, regards
Daniel
When I use the library with express I have this error:
Error: Cross origin null forbidden
How can it be solved? I try with this npm package https://www.npmjs.com/package/cors but don't work.
Thanks @tomcx
A package.json for NPM would lead to a smarter installation and update procedure.
Hi and thanks for this great library!
I've noticed that the members of a structure are stored in an object. The library seems to rely on the order of the object's properties.
However, according to these two Stack Overflow questions the correct iteration order of an object is not guaranteed, especially if a "for...in" loop is used (even if used with arrays).
At least there seems to be some consistency across current major browsers regarding the order of object properties. As far as I know, this isn't the case for "for...in" loops.
This could be a major problem as the data for reading/writing structs might be completely wrong if a browser with untested behaviour is used.
Do you have any plans on making the creation of structs "waterproof" (maybe by using an array with names of the struct members)?
Hi,
First of all thanks for a great library!
I wanted to ask about how to use handles. I have structs inside structs and also struct that contain array of structs. I've used the manual but could not get it right. Can you provide a little example please?
Thanks and keep up the good job!
Hi Tom, is there a way to invoke commands trough a specific URL. I'm experimenting with linking Tame to Siri shortcuts, my way of doing so would be to invoke commands directly trough the URL.
Hi,
I'm testing TAME4 on different hardware/possibilities.
Connecting remotely to
CX5130 / CX9020
Connecting TAME4 to ADS on CX9020 I run into the HTTP access control and pre-flight errors.
On a CX5130 with windows embedded standard 7 you can add the needed headers into IIS and everything is running fine.
The CX9020 running windows embedded compact I see no possibility to add the needed headers somewhere.
As I am not a javascript expert I had no luck trying xdomain or any proxy possibility to bypass this issue.
Do you see any resolution to this?
Great work!
Bryan
Hi,
We created our web service and constructed a polling structure. When we watch the polled values on browser's inspect element, we can see their values as true or false but in the if statements in oc function the variables are not processed as they suppose to. As an example:
oc: function() {
if (s_B2D_k === true) {document.getElementById('field_s_B2D').style.backgroundColor = 'red';}
else if(s_B2D_y===true) {document.getElementById('field_s_B2D').style.backgroundColor = 'green';}
else if(s_B2D_s===true) {document.getElementById('field_s_B2D').style.backgroundColor = 'yellow';}
else {document.getElementById('field_s_B2D').style.backgroundColor = 'orange';}
}
since we see s_B2D_k as true on the inspection the element background color becomes orange for some reason and when I try to show the s_B2D_k's value on window.alert() in oc:function() it says "undefined". Also there are a lot of warnings comes from tame.js and TcAdsWebService.dll which is not explaining any issue properly but it says "Request Dropped". Also if it means anything, we are not connected to Internet when we run the program, we are just connected to PLC. We can send you the files if it is necessary..
Can you help? Any suggestions?
``var Plc;
function startClient() {
Plc = TAME.WebServiceClient.createClient({
serviceUrl: 'http://192.168.1.150/TcAdsWebService.dll',
//configFileUrl: 'http://192.168.1.2/tamex/resources/demo2.tpy', //Path to the TPY file
amsNetId: '5.22.187.194.1.1',
amsPort: '801', //default
// useHandles: handles, //use handles
alignment: '4', //default, set it to "4" if you have TC2 and an ARM based PLC device (i.e. CX90xx), to 8 with TC3
//language: 'ge', //default, set it to "en" for english names of days and months
onReady: test //this function is defined in each example
});
}
function test()
{
Plc.writeBool({name:"MAIN.Licht_Hobby1", val: true});
}``
I can read the values but when i modify the variable value it shows me no error but does not changes its value.
Hello!
Chrome is giving me following warning:
Subresource requests whose URLs contain embedded credentials (e.g. https://user:pass@host/
) are deprecated, and will be blocked in M59, around June 2017. See https://www.chromestatus.com/feature/5669008342777856 for more details.
J @ tame.js:11
TAME.WebServiceClient @ tame.js:11
TAME.WebServiceClient.createClient @ tame.js:11
What to do?
Hi tomcx! First of all, you made a great job!! I think Tame4 is really useful and makes things much more easy with respect to the JS WebService offered by Twincat.
I have a question for you, if you can help.
Would you suggest a way to use your library in a NodeJS application? When it comes to function calls made directly from the browser there is no problem, but I would like to create a server that offers a REST API in NodeJS, so that at each request against the REST endpoint the server can call a Tame4 function to retrieve data from Twincat.
The problem is that, as I have seen, Tame4 is "browser" based: it relies in XmlHttpRequests and "window" calls, for instance, and I cannot use them in a "nodejs" environment..
Hope you understood my doubts and maybe can give me some hints :)
Nicola
Hello!
I have a Problem with the tpy-Parser, when I include the M-Bus lib.
I've figured out that the problem must be at this datatype (at subitem pcomin)
Please have a look at it.
Hello,
is there a way to get an error when connection to plc is lost or a Reconnect function or any idea to solve it?
Many thanks
Daniel
Hi, first off really awesome library you have put together here.
Much easier to work with than the stuff Beckhoff put together.
One request.
Is it possible to make a small example to demonstrate the advantages of using the tpy file as described in the readme?
Digging in the source did not give me much.
Best regards
Hey! This package is a gift from heavens for my new project, I was set out to do something similar by myself, but now that I see how much stuff is involved with this I'm very glad I didn't have to do that part of the project.
With the initial tests, I noticed that when I try to connect with WinCE own version of Internet Explorer, it crashes with errors. I was able to find and fix the said errors and I'm glad to find out it works (more or less) in the CE Internet Explorer too. This is important for me because I use the Beckhoff Control Panel CP6606 in my project and I would like to access the site locally too.
I'm new to GitHub and web development in general so I'm not sure about branching nor how to package the .tame.js as you've done but I was able to debug and correct by replaceing that tame.js with tame-with-comments.js.
The 'error' was that the IE of WinCE can't handle var { } where the last entry was commented out, resulting in "," being the last character of the code inside brackets. There was I think 3 iterations of those and 1 which had "," without any commented section afterwards .
Thanks a bunch for letting us use this!
In your library the amsPort has to be in the range (801-891) but mi IIS assign me the port 35347. So when I try to run the example I have the next error: "TAME library error: AMS Port Number (35347) is out of range (801-891)!" @tomcx
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.