Industry Online Support
Technical Forum
3/25/2008 11:25 AM | |
Joined: 12/8/2006 Last visit: 11/27/2023 Posts: 170 Rating: (26) |
hi candy, ------------------------- (1) Tag prefix ------------------------- If you are using the tag prefix of the picture window, you will get an error "unknown tagname..." if you use the tag prefix in tagname! The tag prefix is active in global script too. http://support.automation.siemens.com/WW/view/en/22282555 faq with demo project (tag prefix) http://support.automation.siemens.com/WW/view/en/23690358 faq aboutpicture window open http://support.automation.siemens.com/WW/view/en/24193022 ------------------------- (2) Using Wait()-functions ------------------------- It's better to use functions "GetTagWait()" and "SetTagWait()" instead of "GetTag()" and "SetTag()". void OnClick(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName) { char a[22] ,b[22]; //strcpy(a,GetTagPrefix("PicWindow","PIC_WINDOW")); //tag prefix is already active strcpy(b,"_Running"); SetTagBitWait(b, !GetTagBitWait(b)); } vbs http://support.automation.siemens.com/WW/view/en/19478679 ---------------------------------------- (3) check bit ---------------------------------------- to check if a bit is set or reset you can use bitwise AND-operator "&"in "C". WORD wValue; //tag wValue = GetTagWord("YourTagName"); if (wValue & 0x004){ //Bit 6 is set } else{ //Bit 6 is not set } bit number hexadecimal value Bit 0 0x0001 Bit1 0x0002 Bit2 0x0004 Bit3 0x0008 Bit4 0x0010 Bit5 0x0020 Bit6 0x0040 Bit7 0x0080 Bit8 0x0100 Bit9 0x0200 Bit 10 0x0400 Bit 11 0x0800 Bit 12 0x1000 Bit 13 0x2000 Bit 14 0x4000 Bit 15 0x8000 Note! - It is easier to use hexedecimal data format instead of decimal data format!!!! - you can check multiple by using bitwise or-operator WORD wValue; //tag wValue = GetTagWord("YourTagName"); if (wValue & (0x0004 | 0x0001)){ //0x0005 //Bit 0OR Bit 6 is set } else{ //Bit 0 AND Bit 6 are not set } |
3/25/2008 10:26 PM | |
Joined: 5/17/2006 Last visit: 2/26/2024 Posts: 218 Rating: (26) |
Dear Ateam , Thank you very much for your help. That was impeccable! Best regards, |
Genetic Fuzzy PID Controller |
|
Follow us on