roccomuso / node-ads

NodeJS Twincat ADS protocol implementation
58 stars 21 forks source link

Update code base to ES6 #34

Open Jozo132 opened 4 years ago

Jozo132 commented 4 years ago

**Includes ADS indexOffset fix caused 'read' 'write' and 'notify' to return values of 0 or false Added '// @ts-check' for improved type checking Replaced all 'var' types to 'const' and 'let' respectively Replaced all 'function' types to 'const' arrow functions Replaced all function inheritences of 'this' to pass as first parameter instead Reduced code size by about 350 lines and structural imrpovements

Code examples must be updated becuase 'this' has to be replaced with your 'client' object Example:

let client = ads.connect(amsConfig, () => {
    console.log(`Trying to read symbol:`, sym)

    //* // Read symbol
    client.read(sym, (err, handle) => {
        if (err) console.log(err)
        console.log('Response:', handle.value)
        client.end()
    })//*/

    /* // Add symbol to notify
    client.notify(sym)
    client.on('notification', handle => {
        console.log('Response:', handle.value);
    });//*/

})
client.on('error', e => {
    console.log(e)
})
roccomuso commented 4 years ago

Rebase needed. Also, We might want to support old node versions.

Jozo132 commented 4 years ago

Rebase needed. Also, We might want to support old node versions.

First time I'm doing rebase .. I think I done it right. // Inexperienced GIT user here I agree with the support for old node versions, so do as you see fit. I'll be working on my fork and will do some more testing when I have spare time. What I needed was ADS support for latest node versions on Windows systems, so that's how it got me here.

roccomuso commented 4 years ago

cool keep us updated