Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

converting raw data to proper data types #62

Open
miladghasemid opened this issue Sep 28, 2019 · 0 comments
Open

converting raw data to proper data types #62

miladghasemid opened this issue Sep 28, 2019 · 0 comments

Comments

@miladghasemid
Copy link

Data read from DBs are in the form of byte array. these bytes can be converted into more meaningful types such as REAL or INTEGER just like the way they are define in VAT in simatic manager. But due to efficiency, it seems to be better to read multiple data items from a DB(if they have consecutive addresses) and save it in an array of bytes, making possible for user to read each portion of buffer and convert it to data types.
here is the example:
suppose user wants to read two REALs, from DB100,DBD0 and DB100,DBD4. for the sake of efficiency, a function reads 8bytes of data from DB100 and saves it into a local variable. another function call on that variable can convert data to more meaningful data.

class DataItems{
   vector<char> itemsBuffer;
   float rawData2REAL(int index)
}

user can access data using some code like this.

DataItems items = new DataItems();
s7client.readArea(DB100,8,&items);
float value01 =items.rawData2Real(0);
float value02 =items.rawData2Real(4);

but i think data does not need to be converted to node js objects until the raw value is completely converted to primitive data types, meaning itemsBuffer does not need to be visible in javascript code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant