WinCC V62 SP2 VBS for Creating Procedures and Actions.docx

上传人:b****8 文档编号:30550364 上传时间:2023-08-16 格式:DOCX 页数:13 大小:70.81KB
下载 相关 举报
WinCC V62 SP2 VBS for Creating Procedures and Actions.docx_第1页
第1页 / 共13页
WinCC V62 SP2 VBS for Creating Procedures and Actions.docx_第2页
第2页 / 共13页
WinCC V62 SP2 VBS for Creating Procedures and Actions.docx_第3页
第3页 / 共13页
WinCC V62 SP2 VBS for Creating Procedures and Actions.docx_第4页
第4页 / 共13页
WinCC V62 SP2 VBS for Creating Procedures and Actions.docx_第5页
第5页 / 共13页
点击查看更多>>
下载资源
资源描述

WinCC V62 SP2 VBS for Creating Procedures and Actions.docx

《WinCC V62 SP2 VBS for Creating Procedures and Actions.docx》由会员分享,可在线阅读,更多相关《WinCC V62 SP2 VBS for Creating Procedures and Actions.docx(13页珍藏版)》请在冰豆网上搜索。

WinCC V62 SP2 VBS for Creating Procedures and Actions.docx

WinCCV62SP2VBSforCreatingProceduresandActions

SIMATICHMI

WinCCV6.2SP2

VBSforCreatingProceduresand

Actions

1.VBSforCreatingProceduresandActions

Contents

WinCCprovidesthepossibilityofdynamizingtheRuntimeenvironmentusingtheVisual

BasicScript.ItispossibletouseVBStoprogramglobalactionsandproceduresaswellas

dynamizinggraphicobjectsandtriggeringactionsinRuntime.

Thischapterwillshowyou

•HowtoworkwithVBScripteditors

•Howtocreateandeditprocedures

•Howtocreateandeditactions

•HowtoactivateVBScriptsinRuntime

•Howtoexecutediagnosticsonscripts

•TheobjectmodelofgraphicRuntimes

•DetailedexamplesonusingVBScript

2.UsingVisualBasicScriptinWinCC

Introduction

InadditiontotheCscript,WinCCalsoprovidestheVBScriptprogramlanguageasaprogramminginterfaceinordertomaketheWinCCRuntimeenvironmentdynamic.

TargetGroupoftheDocumentation

ThisdocumentationisaimedatprojectengineerswithexperienceofVisualBasicorWinCCScriptings(C)usedtodate.

ApplicationOptions

VBScript(VBS)providesaccesstotagsandobjectsofthegraphicalRuntimesystematRuntimeandcanexecutepicture-independentfunctions:

•Tags:

Tagvaluescanbereadandwritteninorder,forexample,tospecifytagvaluesforthePLCbyclickingthemousewhenpositionedonabutton.

•Objects:

Objectpropertiescanbemadedynamicusingactionsandactionscanbetriggeredbyeventsinfluencingobjects.

•Picture-independentActions:

Picture-independentactionscanbetriggeredcyclicallyoraccordingtotagvalues,e.g.forthedailytransferofvaluesintoanExceltable.

VBScanbeusedatthefollowingpointsinWinCC:

•IntheGlobalScriptEditor:

Thisisusedtoconfigurepicture-independentactionsandprocedures.Theprocedurescanbeusedinpicture-dependentandpicture-independentactions.Severalproceduresarecompiledinatopic-relatedmodule.

•InGraphicsDesigner:

Picture-dependentactionscanbeconfiguredwithwhichthepropertiesofgraphicobjectscanbemadedynamicorcausedtorespondtoeventsinRuntime.

ApplicationScenarios

VBScanbeusedinRuntime,forexample:

•toconfiguresetpointvaluespecificationfortagsfortheoperationofagraphicobjectin

ordertodefineavalueforthePLCbyclickingamouse,forexample.

•toconfigureswitchingtheRuntimelanguagefortheoperationofagraphicobject.

•toconfigurethechangeofcolor,e.g.cyclically(flashing)ortodisplaystatuses(motoron).

ApartfromthespecificWinCCapplications,thegeneralfunctionalityofVBScanalsobe

usedtocustomizetheWindowsenvironment,e.g.:

•totransferdatatoanotherapplication(e.g.Excel).

•tostartexternalapplicationsfromWinCC.

•tocreatefilesandfolders.

Theautomationobjectsinyourenvironmentareavailablewithwhichtocustomizethe

Windowsenvironment.

Note

AlltheobjectssuppliedwiththeWindowsScriptHost(WSH)fromMicrosoftcanbe

integratedintheenvironmentusingthestandardVBSmethodCreateObject.However,there

isnodirectaccesstotheWSHobjectitselfusingVBSfromWinCC.

ThereisnoguaranteenorWinCCsupportfortheVBSfunctionalitywithregardtoits

adaptationtotheWindowsenvironment.

LimitstoOtherProgrammingLanguagesinWinCC

VBSandC

VBScriptcanbeusedinWinCCparalleltoC-Script,butdonotmixthescripttypes:

•VBScriptsandC-scriptscanbeconfiguredwithinapictureandproject.

•C-scriptscannotbeinvokedinVBScriptsandviceversa.

•VBSprovidesinternalinterfacestotagsandpictureobjectswhiletheCenvironmentenablesaccesstootherWinCCsubsystems(e.g.thereportsystem).

VBSandVBA

VBAisusedinWinCCConfigurationduringtheconfigurationinordertoadaptGraphicsDesignertoyourindividualrequirementsandtosimplifyandautomateconfiguration.VBAprogramsonlyrunintheWinCCconfigurationenvironment.

AsopposedtoVBA,VBscriptsonlyruninWinCCRuntimeand,fromthere,enableaccesstographicobjectsandtags.ObjectsandpicturescanbeneithercreatednormodifiedonapermanentbasisinVBS,asopposedtoVBA.

Themainlanguage-relateddifferencesbetweenVBAandVBSaree.g.:

•VBSwasdevelopedforuseinInternet,VBAfortheautomationofsoftwareapplications.

•ThedatatypeofVBStagsisalwaysVARIANT.VBA,ontheotherhand,differentiatestheindividualdatatypessuchasINT,DOUBLE,STRING,etc.

•CertainlanguageconstructsfromVBAhavebeenremovedfromoraddedtoVBS.

•ErrorsarehandleddifferentlyinVBScomparedtoVBA.

AcompletelistofthedifferencesbetweenVBAandVBSisprovidedintheAppendixin"BasicPrinciplesofVBScript".

Procedures,ModulesandActions

VBSinWinCCallowstheuseofprocedures,modulesandactionstomaketheRuntimeenvironmentdynamic:

•Procedures:

Codesarestoredinprocedureswhicharethenusedatseveralpointsintheconfiguration.Retrievethecodeoranotherprocedureinanactionbyinvokingtheprocedurename.ProcedurescanbecreatedinWinCCwithorwithoutreturnvalues.

Proceduresdonothavetheirowntrigger,theyarealwaysretrievedbyanaction.

•Modules:

Itisadvantageoustocompilerelatedprocedurestounitsinmodules.Createmodulesforprocedures,forexample,whichmustbeusedinaspecificpictureorbelongtoaspecifictopic,suchasauxiliarymathematicalfunctionsordatabaseaccessfunctions.

•Actions:

Actionsarealwaysactivatedbyatrigger,namelyatriggeringevent.Actionsareconfiguredingraphicobjectproperties,ineventswhichoccuronagraphicobjectorgloballyinaproject.Codesusedseveraltimescanbecalled,intheformofprocedures,inactions.

3.ModulesandProcedures

Introduction

Proceduresareusedtomakecodes,createdonlyonce,availableatseveralpointsinaproject.Insteadofenteringthecodeseveraltimes,simplycallinthecorrespondingprocedure.Thecodeisclearerandeasiertomaintain.

Relatedproceduresshouldbestoredinmodules.WhenacertainprocedureisretrievedviaanactioninRuntime,themodulethatcontainsthatprocedureisloaded.Observethefollowingwhenstructuringthemodulesandprocedures:

•Themoremodulesthatmustbeloadedwhenapictureiscalledin,theworsetheperformanceinRuntime.

•Thelargeramodule,themoreproceduresarecontainedand,thus,thelongertheloadingtimeforthemodule.

Organizethemodulessensibly,e.g.amodulewithproceduresforaspecificsystempart/picture.

Anothertypeofstructuringofproceduresinmodulesisthefunctionalstructuring,e.g.amodulecontainingmathematicalfunctions.Usethisstructure,forexample,formoduleswhichshouldbeusedgloballyforprojects.Thefollowingexampleillustratesamodulecontainingmathematicalfunctionsderivedfromthestandardfunctions:

ProcedureFeatures

TheproceduresinWinCChavethefollowingproperties:

•Theyarecreatedandmodifiedbytheuser.

•Theycanbeprotectedagainstmodificationandviewingbymeansofapassword.

•Theydonothaveatrigger.

•Theyarestoredinamodule.

WinCCdoesnotprovidepredefinedprocedures,butdoesprovidecodetemplatesandIntellisense,forexample,tosimplifyprogramming.Proceduresdifferaccordingtomoduleassignmentin:

•Standardproceduresapplygloballytoprojectslocatedonthecomputeronwhichthey

werecreated.

•Projectprocedurescanonlybeusedintheprojectinwhichtheywerecreated.

ModuleFeatures

Amoduleisafileinwhichoneorproceduresisstored.ThemodulesinWinCChavethe

followingproperties:

•Theycanbeprotectedagainstmodificationandviewingbymeansofapassword.

•Thehavethefileextension*.bmo.

Modulesdifferaccordingtothevalidityoftheirproceduresin:

•StandardModules:

Containprocedureswhicharegloballyavailabletotheproject.StandardmodulesarestoredintheWinCCfilesystemunder:

\ApLib\ScriptLibStd\.bmo

•ProjectModules:

Containproject-specificprocedures.ProjectmodulesarestoredintheWinCCfilesystemunder:

\ScriptLib\.bmo.Sincetheprojectmodulesarestoredintheprojectdirectory,theyarecopiedwhentheWinCCprojectiscopied.

Note

IfWinCCmustbereinstalledandthestandardproceduresandmodulesneedtobeusedagain,savethemodulefilespriortothereinstallationinadifferentdirectoryandcopythemintherelevantWinCCdirectoryafterthereinstallationhasbeencompleted.Otherwise,thestandardmodulesintheWinCCinstallationdirectoryaredeletedduringtheinstallationroutine.

UsingProceduresandModules

Proceduresareusedin:

•Actions(inGraphicsDesignerandGlobalScript)

•Otherprocedures(inGlobalScript)

Proceduresarestructuredinmodules.

4.Actions

Introduction

Anactionisalwaysstartedbyatrigger.Anaction,forexample,istriggeredinRuntimewhenanobjectisoperatedbyamouseclick,acertaintimehasoccurredorataghasbeenmodified.

ActionFeatures

ActionsaredefinedonceinGlobalScriptandthenavailableindependentofthepicture.

GlobalScriptactionsareonlyvalidintheprojectinwhichtheyweredefined.Actionslinkedtoagraphicobjectareonlyvalidinthepictureinwhichtheyweredefined.

Note

VBSdoesnotcurrentlyallowthecreationofcomputer-specificactions.

Thefollowingappliesforclientsinamulti-usersystem:

Allglobalactionsconfiguredona

serverarealsoexecutedonaclientwhenaprojectisopened.

Thefollowingappliestoclientsinadistributedsystem:

Ifactionsshouldbeusedonaclient

computer,copyalltheactionfilesinthecorrespondingprojectdirectoryonthe

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 工程科技 > 机械仪表

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1