Transcription of Programming Reference Guide - Ewon
1 En-USENGLISHI mportantUserInformationDisclaimerThe informationin this documentis for informationalpurposesonly. PleaseinformHMSN etworksof anyinaccuraciesor omissionsfoundin this responsibilityor liabilityfor anyerrors that may appearin this rightto modifyits products in line withits policyof informationin this documentshallthereforenot be construedas a commitmenton the part of HMSN etworksand is subjectto commitmentto update or keepcurrenttheinformationin this data,examplesand illustrationsfoundin this documentare includedfor illustrativepurposesand are onlyintendedto help improveunderstandingof the functionalityand handlingof the viewof the widerangeof possibleapplicationsof the product,and becauseof the manyvariablesand requirementsassociated withanyparticularimplementation,HMSN etworkscannotassumeresponsibilityor liabilityfor actualuse basedon the data.
2 Examplesor illustrationsincludedin this documentnor for any damagesincurredduringinstallationof the the use of the productmust acquiresufficientknowledgein orderto ensurethat the productis usedcorrectlyin theirspecificapplicationand that the applicationmeetsall performanceand safetyrequirementsincludingany applicablelaws,regulations,codesand , HMSN etworkswill underno circumstancesassumeliabilityor responsibilityfor any problemsthat may ariseas a resultfrom the use of undocumentedfeaturesor functionalside effectsfoundoutsidethe documented scopeof the effectscausedby any directorindirectuse of suchaspectsof the productare undefinedand may compatibilityissuesand en-USTableof ContentsPage1.
3 Of the 213 List of # (bit extractionoperator).. (comment).. $.. $.. - NEXT- .. , .. $.. , THEN,ELSE, .. # .. $.. $.. $.. 1054 1075 BASICE rror 1086 109 This page intentionallyleft blankPreface5 (110) DocumentThis documentdescribesthe BASIC scriptingand all its possibilitieswhenrunningon an documentis an evolutionof the formerRG-002 contentwritten in this documentcan be appliedonly on eWONF lexyrunninga firmwareversion higheror equalto (eWONCD and eWONF lexy)must referto: Firmwareof the device<= : RG-002:ProgrammingReferenceGuide > firmwareof the device< : RG-0006 00.
4 ProgrammingReferenceGuideFor additionalrelateddocumentationand file downloads,pleasevisit :Newversionof :TemplateADDED: :Typoin the ONDATE functionCHANGED:COMCFG parametersCHANGED:Overalltypo,examplesco rrections,.. :FS, p. :ONWAN,p. :RESPONSEHTTPX,p. :LOGGROUPIO,p. 62 Updated:LOGIO,p. :CommandofS2inREQUESTHTTPX,p. :LOGGROUPIO,p. 62 Changed:HTTPX,p. 54 Changed:TagNameVariable,p. :CyclicSectionas of ,p. 5 Changed:LOGGROUPIO,p. 62andLOGIO,p. is a registeredtrademarkof HMSI ndustrial NetworksSA. All othertrademarksmentionedin this documentare the propertyof of of firmwareversion ,the cyclicsection of the BASICIDE is no longerdisplayedonthe EwonGUI en-USPreface6 (110)Manyclientsusedthe cyclicsectionin a wrongway which,dependingon the scriptused,couldhavea negativeimpacton the mostof the typicalbasicscriptuse cases,you shouldn tconsiderthe for specificreasonyou needto add the cyclicsection,thenyou llhaveto performas follows:1.
5 Downloadthe fromthe Ewondevice(usingFTP or the FilesTransfermenu).2. Add the followinglinesinsidethe downloadedfile:Rem---eWONstartsection:Cy clicSectioneWON_cyclic_section:Rem---eWO Nuser(start)// Theremustbe at leastoneinstruction(or comment)to keep// thecyclicsectiondisplayedinsidethe BasicIDERem---eWONuser(end)EndRem---eWON endsection:CyclicSection3. Re-uploadthe on the en-USBASIC languagedefinition7 (110) programof the eWONis basedon syntaxcloseto the BASIC, possiblethanksto the BASICIDE availableon the web interfaceof the this document,the followingconvention(if not indicated otherwise)is usedto representtheparameters:ParameterTypeE1, E2 IntegerS1, S2 StringF1, F2 RealCACharacter (if stringpassed,first char is evaluated) is importantto understandhow the deviceexecutesits program!
6 There'sa differencebetweenthe recordand the executionof the programwithinthe device:theunit has a programtask that extractsBASIC requestsfrom a queueand request can be: A singlecommand:myVar=1 A branchto a label:goto myLabel A list of commandssuchas a programblockIn the first case,the commandis executed thenthe BASIC task is readyto executethe the secondcase,the BASIC task goesto labelmyLabeland executeswhat s insideuntiltheENDcommandappears or untilan error devicehasn tany programbut anInit Section,aCyclicSectionand a customsectionlabeledmyNewSectionare created:Init SectionCLSmyVar= 0 CyclicSectionFORV% = 0 TO 10myVar= myVar+ 1 NEXTV%PRINTmyVarmyNewSectionmyNewSection .
7 MyVar= 0 PRINT"myVaris reset"If the is downloadedusingan FTP client,the followingcodewillbe en-USBASIC languagedefinition8 (110)Rem---eWONstartsection:CyclicSectio neWON_cyclic_section:Rem---eWONuser(star t)FORV% = 0 TO 10myVar= myVar+ 1 NEXTV%PRINTmyVarRem---eWONuser(end)EndRe m---eWONendsection:CyclicSectionRem---eW ONstartsection:InitSectioneWON_init_sect ion:Rem---eWONuser(start)CLSmyVar= 0 Rem---eWONuser(end)EndRem---eWONendsecti on:InitSectionRem---eWONstartsection:myN ewSectionRem---eWONuser(start)mynew_sect ion:myVar= 0 PRINT"myVaris reset"Rem---eWONuser(end)EndRem---eWONen dsection.
8 MyNewSectionThe codewritten in the BASICIDE is displayed,but the devicealso addedsomeremarksandlabelsto allowthe modificationand provideprogramflow IDE has addedanEndstatementat the end of eachsectionto preventthe programfromcontinuingto the examplealso showsthat eachlabelis globalto the wholeprogramand shouldnot be not correlationbetweenthe nameof the sectionand the labelusedin that sectionnameis only a methodto organizeprogramlisting can containspaceswhilethe programlabelscan programstarts ( : by clickingtheRUNbutton from the top menuof the IDE),thedeviceposts2 commandsin the queue:BASICQ ueue BASIC task of the devicewill readthe request,fromthe queue,that has the lowestindexandwill execute it untilanEndis foundor untilan first followinglineswill be executed:Rem---eWONstartsection:InitSect ioneWON_init_section.
9 Rem---eWONuser(start)CLSmyVar= 0 Rem---eWONuser(end)EndRem--- en-USBASIC languagedefinition9 (110)TheEndcommandon the line beforelast will end the programand the BASIC task will checkinthe queuefor a new request:BASICQ ueue first availablecommandisgotoewon_cyclic_sectio n,it will also be executeduntiltheEndcommandis executedthe BASIC task will detect that the sectionthatjust run was aCYCLIC_SECTIONand will thenpost a newgoto ewon_cyclic_sectionrequestin explainshow the programis continuouslyexecuted(andforever)as long as the BASICis a numberof actionsthat can be programmedto occuruponevent,like ONTIMER.
10 TSET1,10 ONTIMER1, "gotomyLabel"If the abovelineswerein theInit Section,it wouldstart a timer#1 withan intervalof 10 secondsand programagoto myLabelrequestwhentimer#1 ,the deviceposts thegoto myLabelrequestin the be finished,the timerrequestwill be extracted fromthe queueand thenexecuted. If theCYCLICSECTION takesa long timeto execute, thenthe timercanelapsemorethanonceduringthe executionof theCYCLICSECTION resultingin moretimeractionto be posted in the en-USBASIC languagedefinition10 (110)BASICQ ueue 4 Queuepos BASIC queuecan holdmorethan100 requests but ifTIMER goestoo fast or if othereventssuchasONCHANGEare usedthenthe queuecan overflow.