Example: barber

Programming Reference Guide - Ewon

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,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 undocum

including any applicable laws, regulations, codes and standards. Further, HMS Networks will under no circumstances assume liability or responsibility for any problems that may arise as a result from the use of undocumented features ... Programming Reference Guide Reference Guide RG-0006-01 1.9 en-US

Tags:

  Programming, Standards, Owens

Information

Domain:

Source:

Link to this page:

Please notify us if you found a problem with this document:

Other abuse

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,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.

2 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:ProgrammingReferenceGuideFor additionalrelateddocumentationand file downloads,pleasevisit :Newversionof :TemplateADDED: :Typoin the ONDATE functionCHANGED:COMCFG parametersCHANGED:Overalltypo,examplesco rrections.

3 :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. 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.

4 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!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 :myVar= 0 PRINT"myVaris reset"If the is downloadedusingan FTP client,the followingcodewillbe en-USBASIC languagedefinition8 (110)Rem---eWONstartsection:CyclicSectio neWON_cyclic_section.

5 Rem---eWONuser(start)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: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.

6 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: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.

7 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. In that case,an erroris loggedin theeventsfile and requests are not executedwiththe exactprecisionof a timer, dependingon thecurrentload of the BASIC whenthe ASP blockneedsto be executedbecausethe devicemust delivera web pageto aclient,the ASP blockis also put in the an example,if an ASP blockcontainsthe followinglines:FromWebVar= Var1!PRINT#0;TIME$Thenthe queuewill reflectthe following:BASICQ ueue Var1!PRINT#0;TIME$2gotoMyLabel1gotoewon_ cyclic_sectionCYCLIC_SECTIONIf a requestin the queuecontainsmorethan1 BASIC line, the blockis appendedto the end ofthe programas a temporarysection:ewon_one_shot_section:f romWebVar= Var1 PRINT#0;TIME$ENDThe temporarylabelis calledgoto executionis done,thetemporarysectionis deleted fromthe a consequence,the followingapplies: Any globalvariableor labelcan be or ASP blocks;subroutinescan becalledin the ASP blocksand can sharecommonvariableswiththe program.

8 If a sectionis beingexecutedwhenthe ASP sectionis posted, all the requestsin the queuemustfirst be executed. This may havean impacton the responsivenessof the websitewhenASP is used. WhenusingASP;it is recommendedto groupthe blocksin orderto avoidposting too manydifferentrequests in the doingso, queueextractionand BASIC contextswitcheswill be reduced. If a big amountof or long ASP requests are posted to the BASICvia the web server, it mayslowdownnormalexecutionof the en-USBASIC languagedefinition11 (110) Sectionsare neverinterrupted by othersections:this is alwaystrue!Whena programsequenceis written, it will neverbe brokenby anotherexecution(of timer, web requestoranythingelse). StringA character string can containany set of characters. Whencreatingan alphanumericstringwithaquoted string the or delimitermustbe character string can be stored eitherin an alphanumerictypevariableor in an 3 validstrings"abcd" abdc "abc def ghi" commandis an instructionthat has noneor severalcomma(,)

9 Separated ,"name","Power"SETSYSTAG,"SAVE"Thereare 2 exceptionsto the integer is a numberbetween-2147483648and +2147483647whichbe storedin an parameterof integertypeis specifiedfor a functionor a commandand this variableisactuallyof real type,the deviceconvertsautomaticallythe real valueto an expectedvalueis of integer typeand the transmitted valueis a characterstring, thedevicegeneratesan real numberis a numberin floatingpointrepresentationof whichvalueis + this typecan be storedin a variableof real typeor in anarrayof real numberhas approximately7 meansthat conversionof a numberwithmorethan7 significantdigitsto real will lead to a lost in functionexpectsa real numberand an integeris transmitted, the deviceconvertsautomaticallythe integer into a real the functionawaitsa real and a characterstringis passed,the eWONgeneratesan deviceusesIEEE 754 singleprecisionrepresentation(32 bits).

10 The fractionis codedon 23bits, whichrepresentsabout7 on the web interface of the device, en-USBASIC languagedefinition12 (110)valuesof the tags are displayedonly with6 a tag is usedin BASIC scripting,the 7significantdigitsare alphanumericcharacter is one of the ASCII characters. EachASCII characterhas a numericalrepresentationbetween0 and ASCII codeof a character, and theCHR$functionconvertstheASCII codeto a string of a functionis a BASIC commandhavingnoneor severalparameters and returninga resultthatcan be of integer, real or "HOP"GETSYSTAG,"NAME" declarea function,2 keywordsare needed: FUNCTIONIt is usedto start the functiondefinitionand is followedon the sameline by the functionnamewhichlengthmustbe greater thanone character. ENDFNIt is usedto end the :Howto Declarea FunctionFUNCTIONmy_function// functiondefinitionbeginsPRINT"my_string" functionreturnvalueis specifiedby usingthe followingfunctionnameconvention: If the functionreturnsan integer:Functionmy_function% If the functionreturnsa string:Functionmy_function$ If the functionreturnsa float:Functionmy_functionTo specifythe returnvalueof a function,an implicitvariableis created automaticallybasedonthe functionexits,the returnvalueis the last valueof this en-USBASIC languagedefinition13 (110)Example2:ReturnValueof a FunctionFUNCTIONmy_function$my_function= 1$my_function= $my_function+ 1 PRINT"my_string"ENDFNThis exampleprintsmy_stringin the consolebut the returnvalueis return insideFunctionsThe keywordreturncan be usedat any placeinsidea functionto end.


Related search queries