您好,欢迎访问三七文档
HMIRuntime.Screen£¨»Ã棩HMIRuntime.tags£¨±äÁ¿£©HMIRuntime.ActiveScreen£¨»î¶¯µÄ»Ã棩·½·¨ÓÐHMIRuntime.Stop£¨Í£Ö¹ÔËÐУ©HMIRuntime.tags(±äÁ¿Ãû).readHMIRuntime.tags(±äÁ¿Ãû).writeʾÀýÒ»¡¢»ÃæÌøתVBSubOnLButtonDown(ByValItem,ByValFlags,ByValx,ByValy)HMIRuntime.BaseScreenName=zjk_line4EndSub¶þ¡¢°´¼üÌøת»ÃæVBSubOnLButtonDown(ByValItem,ByValFlags,ByValx,ByValy)DimaSeta=ScreenItems(jichuang)a.TagPrefix=DNC008.EndSubÈý¡¢¶¯»£¨C½Å±¾£©1.ÄÚ²¿±äÁ¿¡°temp_start¡±¶þ½øÖÆ¡°temp¡±ÎÞ·ûºÅ8λ2.²åÈ롰״̬ÏÔʾ¡±£¬²åÈëͼƬ3.ʼþ-ÆäËü-´ò¿ª»Ãæ-cSetTagBit(temp_start,1);SetTagWord(temp,0);4.ÊôÐÔ-ÆäËü-ÏÔʾ-cinta,b;a=GetTagBit(temp_start);if(a==1){b=GetTagWord(temp);if(b9)b=0;SetTagWord(temp,b+1);}elseSetTagBit(temp_start,0);return0;5.£¨Ñ¡Ï²åÈë°´Å¥£¨1£©¡°¿ªÊ¼¡±Ê¼þ-Êó±ê-°´×ó¼üSetTagBit(temp_start,1);£¨2£©¡°Í£Ö¹¡±Ê¼þ-Êó±ê-°´×ó¼üSetTagBit(temp_start,0);£¨3£©¡°Í˳öÔËÐÐϵͳ¡±Ê¼þ-Êó±ê-°´×ó¼üDeactivateRTProject();6.±£´æ-ÔËÐÐϵͳËÄ¡¢Tanks¶¯»£¨±äÁ¿Á¬½Ó£©1.н¨ÄÚ²¿±äÁ¿¡°Fill_level¡±ÎÞ·ûºÅ8λ2.²åÈëÈ«¾Ö¿âÖеÄTank13.ÊôÐÔ-Óû§¶¨Òå1-process-¶¯Ì¬-±äÁ¿Ñ¡Ôñ±äÁ¿¡°Fill_level¡±4.±£´æ-ÔËÐÐϵͳ5.´ò¿ªSimulationEdit-NewTag:Ìí¼Ó±äÁ¿Properties-Incactive:ÉèÖÃÊýÖµListofTags-StartSimulationÎå¡¢Tanks¶¯»£¨¶¯Ì¬¶Ô»°¿ò£©1.н¨ÄÚ²¿±äÁ¿¡°Fill_level¡±ÎÞ·ûºÅ8λ2.²åÈëÈ«¾Ö¿âÖеÄTank13.ÊôÐÔ-Óû§¶¨Òå1-process-¶¯Ì¬-¶¯Ì¬¶Ô»°¿òÑ¡Ôñ±äÁ¿¡°Fill_level¡±¹«Ê½¡°Fill_level¡±+1Êý¾ÝÀàÐÍ£ºÖ±½Ó4.ÊôÐÔ-Óû§¶¨Òå1-max/minÉèÖÃÖµ5.ÊôÐÔ-ÑÕÉ«-BackColor-¶¯Ì¬-¶¯Ì¬¶Ô»°¿òÑ¡Ôñ±äÁ¿¡°Fill_level¡±Êý¾ÝÀàÐÍ£ºÄ£ÄâÁ¿Ìí¼Ó£ºÉ趨ÊýÖµ·¶Î§¼°ÏàÓ¦±ä»¯ÑÕÉ«6.±£´æ-ÔËÐÐϵͳ7.´ò¿ªSimulationEdit-NewTag:Ìí¼Ó±äÁ¿Properties-Incactive:ÉèÖÃÊýÖµListofTags-StartSimulationÁù¡¢Tanks¶¯»£¨Ö±½ÓÁ¬½Ó£©1.н¨ÄÚ²¿±äÁ¿¡°Fill_level¡±ÎÞ·ûºÅ8λ2.²åÈëÈ«¾Ö¿âÖеÄTank13.²åÈë¡°¹ö¶¯Ìõ¡±Ê¼þ-ÊôÐÔÖ÷Ìâ-ÆäËü-¹ý³ÌÇý¶¯Æ÷Á¬½Ó-¸ü¸Ä-¶¯×÷-Ö±½ÓÁ¬½Ó-ÊôÐÔ-¸Ã¶ÔÏó-¹ý³ÌÇý¶¯Æ÷Á¬½Ó-»ÃæÖеĶÔÏó-Tank1-process-È·¶¨4.±£´æ-ÔËÐÐϵͳÆß¡¢Tanks¶¯»£¨½Å±¾¶¯×÷£©1.н¨ÄÚ²¿±äÁ¿¡°Fill_level¡±ÎÞ·ûºÅ8λ2.²åÈëÈ«¾Ö¿âÖеÄTanks13.ÊôÐÔ-ÆäËü-ÏÔʾ-cinta;a=GetTagBit(NewPdl0.Pdl,Tank1,Process);if(a100)SetPropWord(NewPdl0.Pdl,Tank1,Process,a+1);elseSetPropWord(NewPdl0.Pdl,Tank1,Process,0);return0;4.´¥·¢Æ÷-ÖÜÆÚ-250ms5.±£´æ-ÔËÐÐϵͳ°Ë¡¢¼ä½ÓÑ°Ö·1.´´½¨±äÁ¿¡°tank1_level¡±ÎÞ·ûºÅ16λ¡°tank2_level¡±ÎÞ·ûºÅ16λ¡°textvariable¡±Îı¾±äÁ¿8λ×Ö·û¼¯2.´´½¨»Ãæ²åÈëÈ«¾Ö¿âTank4-ÊôÐÔ-Óû§¶¨Òå1-process-±äÁ¿tank1_level-ÖÜÆÚ£ºÓб仯ʱ²åÈë¹ö¶¯Ìõ-Ñ¡Ôñ±äÁ¿tank1_level-ÖÜÆÚ£ºÓб仯ʱ3.Öظ´2¶¯×÷£¬±äÁ¿Ñ¡Ôñtank2_level4.²åÈëÁ½¸ö¾²Ì¬Îı¾¿ò£¬·Ö±ðÊÇ:ÇëÊäÈë¶ÔÏóÃû³Æ¡¢µ±Ç°Ë®ÏäҺλÏÔʾ5.²åÈëÊäÈëÊä³öÓò-ÊôÐÔ-ÊäÈëÊä³ö-¶¯Ì¬-±äÁ¿textvariable-ÖÜÆÚ£ºÓб仯ʱ-Êý¾Ý¸ñʽ£º×Ö·û´®6.²åÈëÊäÈëÊä³öÓò-ÊôÐÔ-Êä³ö-¶¯Ì¬-±äÁ¿textvariable-ÖÜÆÚ£ºÓб仯ʱ-Êý¾Ý¸ñʽ£ºÊ®½øÖÆÊý-Ñ¡Ôñ¼ä½Ó7.±£´æ-ÔËÐÐϵͳÔÚµÚÒ»¸öÊäÈëÊä³ö¿òÄÚ·Ö±ðÊäÈë±äÁ¿Ãû³Ætank1_level¡¢tank2_level¾Å¡¢IOÓòÏÔʾÕûÊý±äÁ¿ÎªÐ¡Êý¸ñʽ1.½¨Á¢Ò»¸ö±äÁ¿¡°TestIO¡±ÎÞ·ûºÅ16λÊý2.½¨Á¢Ò»¸ö»Ã棬²åÈëÒ»¸öÊäÈëÊä³ö¿ò-ÊôÐÔ-Êä³ö¸ñʽ£º9999.9Êä³öÖµ-C¶¯×÷doubleTestIO;TestIO=GetTagDouble(TestIO)/10;returnTestIO;ʼþ-ÊôÐÔÖ÷Ìâ-Êä³ö/ÊäÈë-ÊäÈëÖµ-¸ü¸Ä-C¶¯×÷floatin1;in1=GetPropDouble(IpszPictureName,IpszObjectName.InputValue);If((long)(Ln1*10)%10!=0){MessageBox(NULL£¬¡°ÇëÊäÈë0µ½9999Ö®¼äµÄÕûÊý£¡¡±£¬¡°Ìáʾ¡±£¬MB_OK|MB_IONQESTION|MB_SETFOREGROUND|MB_SYSTEMMODAL);}else{SetTagWord(TestIO,GeiPropWord(IpszPicture,IpszObjectName,¡°InputValue¡±));//Return-Type:longInt}}(ÅжÏÊäÈëÖµÊÇ·ñÊÇСÊý£¬Èç¹ûÊÇСÊý£¬µ¯³ö¶Ô»°¿ò¡°ÇëÊäÈë0µ½9999Ö®¼äµÄÕûÊý£¡¡±Èç¹ûΪÕûÊýÔò½«ÊäÈëÖµ¸³¸ø±äÁ¿¡°TestIO¡±Ê®¡¢²Ù×÷¼Ç¼£¨²Ù×÷Ô±ÏûÏ¢£©1.´´½¨±äÁ¿¡°Tag¡±ÎÞ·ûºÅ16λÊý2.´´½¨»Ãæ-²åÈëÊäÈëÊä³ö¿ò-Ñ¡Ôñ±äÁ¿¡°Tag¡±ÊäÈëÊä³ö¿òÊôÐÔ-ÆäËü-²Ù×÷Ô±ÏûÏ¢-ÊÇ£¨²Ù×÷Ô±¼¤»î±¨±í-ÊÇ£©3.²åÈë¿Ø¼þWinCCAlarmControl-Ñ¡ÔñÏûÏ¢¿é¼°ÁÐÈëÏûÏ¢Áбí4.±£´æ-ÔËÐÐÊ®Èý¡¢Êä³ö¸ñʽ999.999Õýs999.999¸ºÊ®ËÄ¡¢Ë®Á÷¶¯»1.Ìí¼Ó¹ÜµÀ-¼¸ºÎx=50£¬y=55Ïß¿í=202.Ìí¼ÓÕÛÏÖ-¼¸ºÎ-µ±Ç°Öµx=40£¬y=55£¬ÑÕÉ«-À¶£¬Ïß¿í=10£¬Ñùʽ3.ÕÛÏß-µ±Ç°ÖµX-VBS£¨XÖálft¡¢YÖátop£©FunctionActualPointLeft_Trigger(ByValItem)DimpolyDimlftDimspeedSetpoly=HMIRuntime.ActiveScreen.ScreenItems(polyline01)poly.Index=1lft=poly.ActualPointLeftIfHMIRuntime.SmartTags(WaterFlowDirection)=FalseThenIfHMIRuntime.SmartTags(WaterFlowSpeed)=2ThenActualPointLeft_Trigger=lft+3ElseActualPointLeft_Trigger=lft+1EndIfIflft=58Thenpoly.ActualPointLeft=40ActualPointLeft_Trigger=40EndIfElseIfHMIRuntime.SmartTags(WaterFlowSpeed)=2ThenActualPointLeft_Trigger=lft-3ElseActualPointLeft_Trigger=lft-1EndIfIflft=40Thenpoly.ActualPointLeft=58ActualPointLeft_Trigger=58EndIfEndIf4.Ìí¼ÓÆô¶¯¿ª¹Ø-VBSSubOnClick(ByValItem)DimPoly1Setpoly1=HMIRuntime.ActiveScreen.ScreenItems(polyline01)poly1.Visible=TrueSelectCaseHMIRuntime.SmartTage(WaterFlowSpeed)Case0poly1.ActivateDynamicActualPointLeft,CycleTime500msCase1poly1.ActivateDynamicActualPointLeft,CycleTime125msCase2poly1.ActivateDynamicActualPointLeft,CycleTime125msEndSelecthmiruntime.SmartTags(WaterFlowStart)=TrueEndSub5.Ìí¼ÓÍ£Ö¹¿ª¹Ø-VBSSubOnClick(ByValItem)DimPolySetpoly=HMIRuntime.ActiveScreen.ScreenItems(polyline01)poly.DeactivateDynamicActualPointLeftpoly.Visible=Falsehmiruntime.SmartTags(WaterFlowStart)=FalseEndSub6.Ìí¼Ó»»Ïò¿ª¹Ø-VBSSubOnClick(ByValItem)hmiruntime.SmartTags(WaterFlowDirection)=FalseEndSub7.Ìí¼Ó»»Ïò¿ª¹Ø-VBSSubOnClick(ByValItem)hmir
本文标题:WinCC小脚本
链接地址:https://www.777doc.com/doc-3945333 .html