//------------------------------------------------------------------------------ // Multi Read //------------------------------------------------------------------------------ void MultiRead() { int res; // Multiread buffers byte MB[16]; // 16 Merker bytes byte EB[16]; // 16 Digital Input bytes byte AB[16]; // 16 Digital Output bytes word TM[8]; // 8 timers word CT[8]; // 8 counters // Prepare struct TS7DataItem Items[5]; // NOTE : *AMOUNT IS NOT SIZE* , it's the number of items // Merkers Items[0].Area =S7AreaMK; Items[0].WordLen =S7WLByte; Items[0].DBNumber =0; // Don't need DB Items[0].Start =0; // Starting from 0 Items[0].Amount =16; // 16 Items (bytes) Items[0].pdata =&MB; // Digital Input bytes Items[1].Area =S7AreaPE; Items[1].WordLen =S7WLByte; Items[1].DBNumber =0; // Don't need DB Items[1].Start =0; // Starting from 0 Items[1].Amount =16; // 16 Items (bytes) Items[1].pdata =&EB; // Digital Output bytes Items[2].Area =S7AreaPA; Items[2].WordLen =S7WLByte; Items[2].DBNumber =0; // Don't need DB Items[2].Start =0; // Starting from 0 Items[2].Amount =16; // 16 Items (bytes) Items[2].pdata =&AB; // Timers Items[3].Area =S7AreaTM; Items[3].WordLen =S7WLTimer; Items[3].DBNumber =0; // Don't need DB Items[3].Start =0; // Starting from 0 Items[3].Amount =8; // 8 Timers Items[3].pdata =&TM; // Counters Items[4].Area =S7AreaCT; Items[4].WordLen =S7WLCounter; Items[4].DBNumber =0; // Don't need DB Items[4].Start =0; // Starting from 0 Items[4].Amount =8; // 8 Counters Items[4].pdata =&CT; res=Cli_ReadMultiVars(Client, &Items[0], 5); if (Check(res,"Multiread Vars")) { // Result of Client->ReadMultivars is the "global result" of // the function, it's OK if something was exchanged. // But we need to check single Var results. // Let shall suppose that we ask for 5 vars, 4 of them are ok but // the 5th is inexistent, we will have 4 results ok and 1 not ok. printf("Dump MB0..MB15 - Var Result : %d\n",Items[0].Result); if (Items[0].Result==0) hexdump(&MB,16); printf("Dump EB0..EB15 - Var Result : %d\n",Items[1].Result); if (Items[1].Result==0) hexdump(&EB,16); printf("Dump AB0..AB15 - Var Result : %d\n",Items[2].Result); if (Items[2].Result==0) hexdump(&AB,16); printf("Dump T0..T7 - Var Result : %d\n",Items[3].Result); if (Items[3].Result==0) hexdump(&TM,16); // 8 Timers -> 16 bytes printf("Dump Z0..Z7 - Var Result : %d\n",Items[4].Result); if (Items[4].Result==0) hexdump(&CT,16); // 8 Counters -> 16 bytes }; }
//--------------------------------------------------------------------------- int TS7Client::ReadMultiVars(PS7DataItem Item, int ItemsCount) { return Cli_ReadMultiVars(Client, Item, ItemsCount); }