HiNTEGROv1.0byCIEMMESRL
Page1/32 ©CopyrightMonday,Jun17,2019,8:09AMbyCIEMMESRL
HiNTEGROScriptEditorv2.1HiNTEGROhalapossibilitàdigestireLogicheevolutegrazieaquestostrumento.ScriptEditormetteadisposizioneunlinguaggiodiscripting(standardECMA-262),concuiscrivereprocedurepersonalizzate.
OggettiGlobaliProprietàValori
NaNInfinityundefined
ProprietàFunzionieval(x)parseInt(string,radix)parseFloat(string)isNaN(number)isFinite(number)decodeURI(encodedURI)decodeURIComponent(encodedURIComponent)encodeURI(uri)encodeURIComponent(uriComponent)
ProprietàCostruttoriObjectFunctionArrayStringBooleanNumberDateRegExpErrorEvalErrorRangeErrorReferenceErrorSyntaxErrorTypeErrorURIError
HiNTEGROv1.0byCIEMMESRL
Page2/32 ©CopyrightMonday,Jun17,2019,8:09AMbyCIEMMESRL
AltreProprietàMathJSON
OggettiStandardProprietàFunzioni
getPrototypeOf(O)getOwnPropertyDescriptor(O,P)getOwnPropertyNames(O)create(O[,Properties])defineProperty(O,P,Attributes)defineProperties(O,Properties)keys(O)
ProprietàOggettiProprietàFunzioni
toString()toLocaleString()valueOf()hasOwnProperty(V)isPrototypeOf(V)propertyIsEnumerable(V)
FunctionObjects
FunctionPrototypeObject
ProprietàFunzionitoString()apply(thisArg,argArray)call(thisArg[,arg1[,arg2,...]])
OggettiArrayCostruttoreArray
HiNTEGROv1.0byCIEMMESRL
Page3/32 ©CopyrightMonday,Jun17,2019,8:09AMbyCIEMMESRL
ProprietàFunzioniisArray(arg)
PrototipoArray
ProprietàFunzionitoString()toLocaleString()concat([item1[,item2[,...]]])join(separator)pop()push([item1[,item2[,...]]])reverse()shift()slice(start,end)sort(comparefn)splice(start,deleteCount[,item1[,item2[,...]]])unshift([item1[,item2[,...]]])indexOf(searchElement[,fromIndex])lastIndexOf(searchElement[,fromIndex])every(callbackfn[,thisArg])some(callbackfn[,thisArg])forEach(callbackfn[,thisArg])map(callbackfn[,thisArg])filter(callbackfn[,thisArg])reduce(callbackfn[,initialValue])reduceRight(callbackfn[,initialValue])
OggettiStringCostruttoreString
ProprietàFunzionifromCharCode([char0[,char1[,...]]])
PrototipoString
ProprietàFunzioni
HiNTEGROv1.0byCIEMMESRL
Page4/32 ©CopyrightMonday,Jun17,2019,8:09AMbyCIEMMESRL
toString()valueOf()charAt(pos)charCodeAt(pos)concat([string1[,string2[,...]]])indexOf(searchString,position)lastIndexOf(searchString,position)localeCompare(that)match(regexp)replace(searchValue,replaceValue)search(regexp)slice(start,end)split(separator,limit)substring(start,end)toLowerCase()toLocaleLowerCase()toUpperCase()toLocaleUpperCase()trim()
BooleanObjectsBooleanPrototypeObject
ProprietàFunzionitoString()valueOf()NumberObjectsNumberPrototypeObject
ProprietàFunzionitoString(radix)toLocaleString()toFixed(fractionDigits)toExponential(fractionDigits)toPrecision(precision)
OggettiMath
ProprietàValori
HiNTEGROv1.0byCIEMMESRL
Page5/32 ©CopyrightMonday,Jun17,2019,8:09AMbyCIEMMESRL
ELN10LN2LOG2ELOG10EPISQRT1_2SQRT2
ProprietàFunzioniabs(x)acos(x)asin(x)atan(x)atan2(y,x)ceil(x)cos(x)exp(x)floor(x)log(x)max([value1[,value2[,...]]])min([value1[,value2[,...]]])pow(x,y)random()round(x)sin(x)sqrt(x)tan(x)
OggettiDateCostruttoreDate
ProprietàFunzioninow()parse(string)UTC(year,month[,date[,hours[,minutes[,seconds[,ms]]]]])
PrototipoDate
HiNTEGROv1.0byCIEMMESRL
Page6/32 ©CopyrightMonday,Jun17,2019,8:09AMbyCIEMMESRL
ProprietàFunzionitoString()toDateString()toTimeString()toLocaleString()toLocaleDateString()toLocaleTimeString()valueOf()getTime()getFullYear()getUTCFullYear()getMonth()getUTCMonth()getDate()getUTCDate()getDay()getUTCDay()getHours()getUTCHours()getMinutes()getUTCMinutes()getSeconds()getUTCSeconds()getMilliseconds()getUTCMilliseconds()getTimeZoneOffset()setTime(time)setMilliseconds(ms)setUTCMilliseconds(ms)setSeconds(sec[,ms])setUTCSeconds(sec[,ms])setMinutes(min[,sec[,ms]])setUTCMinutes(min[,sec[,ms]])setHours(hour[,min[,sec[,ms]]])setUTCHours(hour[,min[,sec[,ms]]])setDate(date)setUTCDate(date)setMonth(month[,date])setUTCMonth(month[,date])setFullYear(year[,month[,date]])setUTCFullYear(year[,month[,date]])toUTCString()toISOString()
HiNTEGROv1.0byCIEMMESRL
Page7/32 ©CopyrightMonday,Jun17,2019,8:09AMbyCIEMMESRL
toJSON()
OggettoRegExpPrototipoRegExp
ProprietàFunzioniexec(string)test(string)toString()
ErrorObjectsErrorPrototypeObject
ProprietàValorinamemessage
ProprietàFunzionitoString()
OggettoJSONProprietàFunzioni
parse(text[,reviver])stringify(value[,replacer[,space]])
Esempidiutilizzodeimetodiedellefunzionidisponibili
eval(x)
scen.log(level.INFO,"eval(10*20)="+eval(10*20));
parseInt(string,radix)
scen.log(level.INFO,"parseInt('10',10)="+parseInt('10',10));
HiNTEGROv1.0byCIEMMESRL
Page8/32 ©CopyrightMonday,Jun17,2019,8:09AMbyCIEMMESRL
scen.log(level.INFO,"parseInt('010',10)="+parseInt('010',10)); scen.log(level.INFO,"parseInt('10',8)="+parseInt('10',8)); scen.log(level.INFO,"parseInt('0x10')="+parseInt('0x10')); scen.log(level.INFO,"parseInt('10',16)="+parseInt('10',16));
isNaN(number)
scen.log(level.INFO,"isNaN(10)="+isNaN(10)); scen.log(level.INFO,"isNaN(NaN)="+isNaN(NaN));
JSON
vartext='{"employees":['+ '{"firstName":"John","lastName":"Doe"},'+ '{"firstName":"Anna","lastName":"Smith"},'+ '{"firstName":"Peter","lastName":"Jones"}]}'; varobj=JSON.parse(text); scen.log(level.INFO,"obj.employees[1].firstName+obj.employees[1].lastName="+obj.employees[1].firstName+""+obj.employees[1].lastName);
Date
scen.log(level.INFO,"Date.now()millisecondsfrommidnight="+Date.now());
vard=newDate();varn=d.getFullYear(); varm=d.getMonth(); varg=d.getDate()
scen.log(level.INFO,"getFullYear()="+n); scen.log(level.INFO,"getMonth()="+m); scen.log(level.INFO,"getDate()="+g);
LoggerLivelli
level.DEBUGlevel.INFOlevel.WARNINGlevel.ERRORlevel.SYSTEM
Utilizzoscen.log(level,message);
HiNTEGROv1.0byCIEMMESRL
Page9/32 ©CopyrightMonday,Jun17,2019,8:09AMbyCIEMMESRL
//EsempiodiutilizzodellafunzioneLoggerperstampareunERROREscen.log(level.ERROR,"Questoéunerrore");
//EsempiodiutilizzodellafunzioneLoggerperstampareunmessaggiodiSISTEMAscen.log(level.SYSTEM,"Questoéunmessaggiodisistema");
//EsempiodiutilizzodellafunzioneLoggerperstampareunAVVISOscen.log(level.WARNING,"Questoéunmessaggiodiavviso");
//EsempiodiutilizzodellafunzioneLoggerperstampareunaINFORMAZIONEscen.log(level.INFO,"Questoéunmessaggiodiinformazione");
//EsempiodiutilizzodellafunzioneLoggerperstampareunmessaggiodiCONTROLLOscen.log(level.DEBUG,"Questoéunmessaggiodidebug");
EsecuzioneComandiScriptEditorpuòeseguiredelleazionisuiGruppiFunzionalidefiniti,attraversolafunzionesetAction.
setActionscen.setAction(action);
actionverràsostituitoconl'azionedaeseguireneigruppifunzionali.
actionsaràcompostodi3partidivisedaunpunto(.):EsempioLUX.1.ON
"LUX"gruppofunzionaleLuci"1"identificativounivocogruppofunzionaleLuci"ON"azionedaEseguire
//Esempiodiesecuzionecomandodiaccensionegruppofunzionaleluce1//scen.setAction("LUX.1.ON");
N.B.nelcasodiluci/automazioni/relèsevieneinseritol'id=0l'azioneverràattuatapertutteleluci/automazioni/rele(EsempioLUX.0.OFFspegnetutteleluci)
Diseguitolepossibiliazionidainviare:
N.B.idverràsostituitoconl'identificatoreunivocodelgruppofunzionale.
LuciLUX.id.ONAccensioneluceLUX.id.OFFSpegnimentoluceLUX.id.TM.XXXAccensionelucecontimerdispegnimentodopoXXXmillisecondi
HiNTEGROv1.0byCIEMMESRL
Page10/32 ©CopyrightMonday,Jun17,2019,8:09AMbyCIEMMESRL
LUX.id.DIM.XXXAccensioneluceallivellodimmerXXXespressoin%(0-100)LUX.id.UPAccensionelucesalendodiunlivellodidimmingLUX.id.DWNSpegnimentolucescendendodiunlivellodidimmingLUX.id.TGLToggleluce.Seaccesavienespentaocontrario
TapparelleAUT.id.UPComandosalita/aperturatapparellaAUT.id.DWNComandodiscesa/chiusuratapparellaAUT.id.STPComandostopAUT.id.LVL.XXXImpostalapercentualediapertura0chiuso-100aperto
ReleRLE.id.ONAccensioneRELERLE.id.OFFSpegnimentoRELERLE.id.BK.XXXLampeggioRELEXXXespressoinms(1000=1secondo)RLE.id.TM.XXXAccensioneTemporizzataRELEespressoinms(1000=1secondo)
HVACClima/TermoregolazioneTHM.id.ONAccensione
THM.id.OFFSpegnimento
THM.id.MODE.ESTCambioModalitàEstate
THM.id.MODE.INVCambioModalitàInverno
THM.id.MODE.DRYCambioModalitàDry
THM.id.MODE.FANCambioModalitàFan
AttenzionelemodalitàDryeFandevonoesseresupportatedall'Hardwareusatoaltrimentiicomandinonverrannopresiinconsiderazione
THM.id.SETP.XXXImpostareSetpointXXXlivellodecimalees.25.5THM.id.UMI.XXXUmidita'relativalivellodecimalees.40.5THM.id.FSP.XXXFanspeedvelocitapercentualeXXX(0Auto33-66-99corrispondentealnumerodellevelocita)
Messaggi/NotificheAttenzionechelaseparazioneusailcarattere|perevitarechepuntioaltropossanoesseremalinterpretati.Nellasezioniimpostazionidevonoessereinseriticorrettamenteiparametripersmtpserver,telegramapieidchateinfimepergliSMSdeveessereaggiuntoeconfiguratounmodemGSMconSIMinstallataeconcreditodisponibile.
MAIL|TO|OBJECT|MESSAGEMailMessage
HiNTEGROv1.0byCIEMMESRL
Page11/32 ©CopyrightMonday,Jun17,2019,8:09AMbyCIEMMESRL
BOT|MESSAGETelegramMessageBOP|URLTelegramPhotoSMS|TO|MESSAGESMSMessage
Irrigazione/SprinklerSPR.ONT.XXXAggiungeunazonadiirrigazioneperXXXminutiSPR.SEQ.ONAttivaSequenzaSPR.SEQ.OFFFermaSequenza
VideoVID.id.PLAYVisualizzalostreamingdell'oggettovideocorrispondenteall'idVID.id.OFFInterrompelostreamingeritornaallaschermatadibase."0"èl'idperilgenerale
//EsempiodiesecuzionecomandoRELEON//scen.setAction("RLE.1.ON");
//EsempiodiesecuzionecomandoRELEOFF//scen.setAction("RLE.1.OFF");
//EsempiodiesecuzionecomandoRELELAMPEGGIO500ms//scen.setAction("RLE.1.BK.500");
//EsempiodiesecuzionecomandoRELETEMPORIZZATO1s//scen.setAction("RLE.1.TM.1000");
//EsempiodiesecuzionecomandoAutomazionesalita//scen.setAction("AUT.1.UP");
//EsempiodiesecuzionecomandoAutomazionediscesa//scen.setAction("AUT.1.DWN");
//EsempiodiesecuzionecomandoAutomazionestop//scen.setAction("AUT.1.STP");
//EsempiodiinvioMailconOggetto:JSSCRIPT,Testo:StartdelloscriptJSetestMailSender.//scen.setAction("MAIL|[email protected]|JSSCRIPT|StartdelloscriptJSetestMailSender");
//EsempiodiinvioTelegram//scen.setAction("BOT|StartdelloscriptJSetestTelegram");
//EsempiodiinvioSMS//scen.setAction("SMS|3480000000|StartdelloscriptJSetestTelegram")
callScenario
HiNTEGROv1.0byCIEMMESRL
Page12/32 ©CopyrightMonday,Jun17,2019,8:09AMbyCIEMMESRL
scen.callScenario(idScenario);
idScenarioverràsostituitoconl'idcorrispondentealloscenariochesivuoleattivare
//Esempiodiesecuzionedelloscenarioconid=1//scen.setAction(1);
CallBackGruppiFunzionaliHiNTEGROperogniGruppoFunzionaleinvial'eventoallaCallBackdiriferimento.Inquestomodo,quandosiaccendeunaluce,siapreosichiudeunatapparellaetc.verrànotificatoloScriptEditorrichiamandolaCallBackdiriferimento.
Luci
event_onLight
functionevent_onLight(_type,_vobj,_status,_level){}
QuestafunzionevienerichiamataperognieventocheaccadeperilgruppofunzionaleLuci.
_type=TipoOggetto(LUX)
_vobj=IdentificatoreUnivocoGruppofunzionale_status=StatoGruppofunzionale
(ON|OFF)
_level=Valoreperlivellodimmer(0-100)
Automazioni
event_onAutomation
functionevent_onAutomation(_type,_vobj,_status,_level){}
QuestafunzionevienerichiamataperognieventocheaccadeperilgruppofunzionaleAutomazioni.
_type=TipoOggetto(AUT)
_vobj=IdentificatoreUnivocoGruppofunzionale
HiNTEGROv1.0byCIEMMESRL
Page13/32 ©CopyrightMonday,Jun17,2019,8:09AMbyCIEMMESRL
_status=StatoGruppofunzionale(UP|DOWN|STOP)
_level=Valoreperlivellotapparelleconritornodistatodelposizionamento(0-100)
Rele
event_onRele
functionevent_onRele(_type,_vobj,_status,_level){}
QuestacallbackvienerichiamataperognieventocheaccadeperilgruppofunzionaleRele.
_type=TipoOggetto(RLE)
_vobj=IdentificatoreunivocoGruppoFunzionale_status=StatoGruppoFunzionale
(ON|OFF|BK|TM)
_level=valoreriferitoallostato(Bk=Blink_level=mslampeggio|TM=Temporizzato_level=mstemporizzato)
Ingressi
event_onInput
TipiSHPPressioneBreveSEPInizioPressioneLungaVEPContinuaPressioneLungaEEPFinePressioneLunga
functionevent_onInput(_type,_vobj,_evt,_tick){}
QuestafunzionevienerichiamataperognieventocheaccadeperilgruppofunzionaleIngressi.
_type=TipoOggetto(INP)
_vobj=IdentificatoreUnivocoGruppofunzionale
HiNTEGROv1.0byCIEMMESRL
Page14/32 ©CopyrightMonday,Jun17,2019,8:09AMbyCIEMMESRL
_evt=StatoGruppofunzionale(SHP|SEP|VEP|EEP)
_tick=Valorediritornopressionecontinua
Eventi
event_onEvent
functionevent_onEvent(_type,_vobj,_evt){}
QuestafunzionevienerichiamataperognieventocheaccadeperilgruppofunzionaleEventi.
_type=TipoOggetto(EVT)
_vobj=IdentificatoreUnivocoGruppofunzionale_evt=StatoGruppofunzionale
(SHP|SEP|VEP|EEP)
HVACClimatizzazione/Termoregolazioneevent_onThermo
functionevent_onThermo(_type,_vobj,_status,_mode,_setpoint,_ambient,_fanspeed,_umidity){}
StatoONOFF
Modalità0CondizionamentoCOOL1RiscaldamentoHEAT2DeumidificatoreDRY3VentilazioneFAN
HiNTEGROv1.0byCIEMMESRL
Page15/32 ©CopyrightMonday,Jun17,2019,8:09AMbyCIEMMESRL
Fanspeed0Automatica1Minima2Media3Massima
QuestafunzionevienerichiamataperognieventocheaccadeperilgruppofunzionaleTermoregolazione.
_type=TipoOggetto(THM)
_vobj=IdentificatoreUnivocoGruppofunzionale_status=Stato
0OFF1ON
_mode=Modalitàfunzionamento0COOL1HEAT2DRY3FAN_setpoint=ValoreTemperaturaSetPointimpostata_ambient=ValoreTemperaturaAmbienterilevata_umidity=Valoreumiditàrilevata
OrologioAstronomicoevent_onAstronomic
TipiSUN.RISESorgeredelsoleSUN.SETTramontodelsoleSUN.ELEElevazioneingradidelsoleSUN.TRANSITMezzogiornosolare
functionevent_onAstronomic(_type,hour,minute){}
QuestafunzionevienerichiamataperognieventoastronomicolegatoalSole.
_type=TipoeventoAstronomico
HiNTEGROv1.0byCIEMMESRL
Page16/32 ©CopyrightMonday,Jun17,2019,8:09AMbyCIEMMESRL
(SUN.RISE|SUN.SET|SUN.ELE|SUN.TRANSIT)hour=ore(0-24)minute=minuti(0-59)
N.B.Perl'eventoSUN.ELEnellavariabilehourvieneriportatoilgradodiElevazione
Messaggisticaevent_onMessage
functionevent_onMessage(_message){}
QuestacallbackvienerichiamataperognimessaggiochearrivaperSMSeTelegram.PuòessereusataperimpartirecomandiadHiNTEGROattraversoiBOTTelegram.
EventiGenericievent_onGenericMessage
functionevent_onGenericMessage(_message){}
LaCallBackvienerichiamatapertuttiglieventimappaticomegenerici.Almomentosonodisponibiliquestieventi
MASER
//MSR.W00.ONPreallarmeminimolivello//MSR.W00.OFFRipristinoPreallarmeminimolivello//MSR.W01.ONAllarmeminimolivello//MSR.W01.OFFRipristinoAllarmeminimolivello//MSR.W02.ONPreallarmemaxlivello//MSR.W02.OFFRipristinoPreallarmemaxlivello//MSR.W03.ONAllarmemaxlivello//MSR.W03.OFFRipristinoAllarmemaxlivello//MSR.W04.ONCaricocisternaincorso//MSR.W04.OFFRipristinoCaricocisternaincorso//MSR.W05.ONFinecaricocisterna//MSR.W05.OFFRipristinoFinecaricocisterna//MSR.W06.ONAllarmeAcqua//MSR.W06.OFFRipristinoAllarmeAcqua//MSR.W07.ONContanteCassaforte//MSR.W07.OFFRipristinoContanteCassaforte//MSR.W08.ONAutomatico
HiNTEGROv1.0byCIEMMESRL
Page17/32 ©CopyrightMonday,Jun17,2019,8:09AMbyCIEMMESRL
//MSR.W08.OFFManuale//MSR.W09.ONAperturaCassaforte//MSR.W09.OFFRipristinoAperturaCassaforte//MSR.W10.ONInputProgrammazione//MSR.W10.OFFRipristinoInputProgrammazione//MSR.W11.ONCambioPrezzi//MSR.W11.OFFRipristinoCambioPrezzi//MSR.W12.ONAperturaanti-tamper//MSR.W12.OFFRipristinoAperturaanti-tamper
//MSR.A00.ONErroresingolasonda//MSR.A00.OFFRipristinoErroresingolasonda//MSR.A01.ONOfflinesingolasonda//MSR.A01.OFFRipristinoOfflinesingolasonda//MSR.A02.ONOfflinetuttelesonde//MSR.A02.OFFRipristinoOfflinetuttelesonde//MSR.A03.ONLettoreBanconoteFuoriServizio//MSR.A03.OFFRipristinoLettoreBanconoteFuoriServizio//MSR.A04.ONEsaurimentocartaStampante//MSR.A04.OFFRipristinoEsaurimentocartaStampante//MSR.A05.ONStampantefuoriservizio//MSR.A05.OFFRipristinoStampantefuoriservizio//MSR.A06.ONErogatorefuoriservizio//MSR.A06.OFFRipristinoErogatorefuoriservizio//MSR.A07.ONPiazzalefuoriservizio//MSR.A07.OFFRipristinoPiazzalefuoriservizio//MSR.A08.ONRipristinoPiazzalefuoriservizio//MSR.A08.OFFRipristinoMemoriaBackuppiena//MSR.A09.ONMinimolivello//MSR.A09.OFFRipristinoMinimolivello//MSR.A10.ONCadutatensione//MSR.A10.OFFRipristinoCadutatensione//MSR.A11.ONErroreDisplay//MSR.A11.OFFRipristinoErroreDisplay//MSR.A12.ONErroreLettroeTessere//MSR.A12.OFFRipristinoLettoreTessere
//MSR.F00.ONUscitainattesacarburante//MSR.F00.OFFRipristinoinattesacarburante//MSR.F16.ONMancanzaconnessioneTCP/IP//MSR.F16.OFFRipristinoconnessioneTCP/IP
Legrand
LGR.AUX.VAR1.VAR2.VAR3
VAR1=idwebserverVAR2=numeroAUXVAR3=valoreAUX
LGR.ALR.VAR1.VAR2.VAR3
VAR1=idwebserver
HiNTEGROv1.0byCIEMMESRL
Page18/32 ©CopyrightMonday,Jun17,2019,8:09AMbyCIEMMESRL
VAR2=zonaVAR=eventoINTRUSION|TAMPER|PANIC
zona:-0Centrale-nZona
evento:Zona0-MAINTENANCE-ACTIVE-BATTERYFAULT-BATTERYOK-NETWORKKO-NETWORKOK-ARM-DISARM-BATTERYKOZonan-INCLUDED-EXCLUDED-INTRUSION-TAMPER-PANIC
LGR.CIT.VAR1
VAR1=idwebserver
Chiamatavideocitofonica
EventoCUSTOMrichiamatodaSCENARIO
LGR.OWN.VAR1.VAR2VAR1=idwebserverVAR2=frame
VAR1=idwebservercorrispondeteall'IDnellapaginagatewayLegrandwebserverVAR2=frameinviata
EventorichiamatodaSCENARIO
JAV.XXX
JAV=chiavecheidentificaun'azionepersonalizzatadaeseguireinjavascriptXXX=stringacheverràpassataaljavascriptpereseguirel'azionepersonalizzata
Es.JAV.PROVAall'internodionGenericMessagesipuòparsareilseguentemessaggioechiederecheselastringacontienePROVAeseguaunadeterminataazione(es.accensionediunaluce)
functionevent_onGenericMessage(_message){ varmsg=_message.split("."); if(msg[0]=="JAV") { if(msg[1]=="PROVA") { scen.log(level.DEBUG,"Messaggiodiprova"); } }}
Energia
functionevent_onEnergy(_type,_vobj,_mesure,_direction,_value,_delta){
HiNTEGROv1.0byCIEMMESRL
Page19/32 ©CopyrightMonday,Jun17,2019,8:09AMbyCIEMMESRL
}
_type=ENR_vobj=IDOggettoVirtuale_mesure=Tipologiamisurazioneeffettuata
powernow(potenzaistantanea)
directionin(Prodotta)out(Consumata)
_value=Valoremisurazione_delta=DifferenzatraEnergiaProdottaeConsumataprecalolato
GoogleHomeWebHook
functionevent_onGoogleMessage(_message){}
QuestacallbackvienerichiamataperogniJSONinviatodalserviziodialogflowGoogle
_message=JSONinviatodaGoogle
KNXE'possibilescriveredirettamentesulbusKNXconlafunzioneKnxWrite.
scen.KnxWrite(a,l,g,value,datapoint);
a=intAreal=intLineag=intGruppovalue=valoreformattatoesempio:datapoint1(1bittrue|false)datapoint5(8bitunsignedvalue0-255)datapoint=datapointknx
datapointsonopredefinitievannosceltitraiseguenti:
knxdtp.Type
Type:
#1.xxx-SWITCH (1.001ON |OFF )-BOOLEAN (1.002TRUE |FALSE )
HiNTEGROv1.0byCIEMMESRL
Page20/32 ©CopyrightMonday,Jun17,2019,8:09AMbyCIEMMESRL
-ENABLE (1.003ENABLE |DISABLE )-RAMP (1.004RAMP |NORAMP )-ALARM (1.005ALARM |NOALARM )-BINARY (1.006HIGH |LOW )-STEP (1.007INCREASE|DECREASE )-UPDOWN (1.008DOWN |UP )-OPENCLOSE (1.009CLOSE |OPEN )-STARTSTOP (1.010START |STOP )-STATE (1.011ACTIVE |INACTIVE )-INVERT (1.012INVERTED|NOTINVERTED)-CYCLIC (1.013CYCLIC |STARTSTOP )-CALCULATED (1.014CALCULATED|FIXED )-RESET (1.015RESET |NOACTION )-ACKNOWLEDGE (1.016ACKNOWLEDGE|NOACTION )-TRIGGERED (1.017TRIGGERED|NOTRIGGERED)-OCCUPANCY (1.018OCCUPIED|NOTOCCUPIED)-OPEN (1.019OPEN|CLOSED )-LOGICAL (1.021AND |OR )-SCENE (1.022SCENEB|SCENEA )-MOVEUP (1.022MOVEUPDOWN|UPDOWNSTOP)-COOLHEAT (1.100HEATING|COOLING )
#5.xxx-PERC100 (5.001PERCENTAGE 0-100)-ANGLE (5.003DEGREES 0-255)-PERC255 (5.004PERCENTAGE 0-255)-RATIO (5.005RATIO 0-255)-TARIFF (5.006TARIFF 0-255)-COUNTER (5.010PULSE 0-255)
#9.xxx-TEMPERATUREC (9.001TEMPERATUREC)-TEMPERATUREDIFF (9.002KELVIN/HOUR)-LUX (9.004LUXINTENSITY)-WINDSPEEDMS (9.005WINDSPEEDM/S)-PRESSURE (9.006PRESSUREPa)-HUMIDITY (9.007HUMIDITY%)-PARTMILLION (9.008PARTS/MILLIONPpa)-AIRFLOW (9.009AIRFLOWM3/H)-TIMESEC (9.010TIMESECONDS)-TIMEMS (9.011TIMEMILLISECONDS)-VOLTAGEMV (9.020VOLATAGEMILLIVOLTS)-CURRENTMA (9.021CURRENTMILLIAMPERE)- POWERWMQ (9.022POWERWATT/M2)-KELVINPERC (9.023KELVIN/PERCENT)-POWERKW (9.024KW/H)-FLOWLH (9.025VOLUMEFLOWL/H)-RAINLMQ (9.026RAINAMOUNTL/M2)-TEMPERATUREF (9.027TEMEPERATUREF)-WINDSPEEDKMH (9.028WINDSPEEDKM/H)
17.xxx
HiNTEGROv1.0byCIEMMESRL
Page21/32 ©CopyrightMonday,Jun17,2019,8:09AMbyCIEMMESRL
-SCENE(17.001SCENENUMBER)
esempiodiinviodatapoint1.001sua/l/g0/0/1
scen.knxWrite(0,0,1,"OFF",knxdtp.SWITCH)
QuestacallbackvienerichiamataperognidatagrammachetransitanelbusKNX
functionevent_onKnxDatagram(_phy_a,_phy_b,phy_c,a,l,g,value){}
_phy_a=PhysycaladdressA
_phy_b=PhysycaladdressB
_phy_c=PhysycaladdressC
_a=Area
_l=Line
_g=Group
value=Valorenontipizzato(daconvertireconildatapointcorretto)eseparatoda|
Inoltree'possibileconvertireilvalorericevutoindicandoildatapointcorrettoconlafunzioneknxConvertValue
vartest=scen.knxConvertValue(knxdtp.BOOLEAN,value);vartest2=scen.knxConvertValue(knxdtp.SWITCH,value);vartest3=scen.knxConvertValue(knxdtp.ENABLE,value);vartest4=scen.knxConvertValue(knxdtp.WINDSPEEDKMH,value);
Nell'esempioprecedenteavremoiseguentirisultatiinformatostringa
test="TRUE"oppure"FALSE"
test2="ON"oppure"OFF"
test3="ENABLE"oppure"DISABLE"
METEOQuestacallbackvienerichiamataperognieventoinviatodallestazionimeteoeinverterintegraticonstazionimeteo
functionevent_onMeteoMessage(_type,_value)
HiNTEGROv1.0byCIEMMESRL
Page22/32 ©CopyrightMonday,Jun17,2019,8:09AMbyCIEMMESRL
{}
_type=tipodimisurazione_value=valorericevuto
valueWNS.XXX=WINDSPEED
MWN.XXX=MAXWINDSPEED
IRR.XXX=IRRADIANCE
XXXvalorericevutoconriferimentoall'unita'dimisurausatadallacentralina
TIMERQuestacallbackvienerichiamataperognieventocronoimpostato
functionevent_onTimerMessage(_id,_value){}
_id=idcrono_value=valorericevuto
valueONIniziocronoOFFFinecrono
HiNTEGROmetteadisposizioneanchetimerconidpergestireeventimultipli
Diseguitounesempiopercreareuntimerripetitivo
varidTimer=scen.setInterval(expression,delay_time);IdTimer=idTimercreato
expression=espressionejavascriptdaEseguire
scen.clearInterval(idTimer);funzioneperterminareuntimeredeliminarlodallamemoria.Unavoltarichiamataquestafunzioneiltimernonesistepiù.
//Esempioditimerconfunzioneascadenza
functionmain(){ varstatusOn=true; varid=scen.setInterval(function(){ if(statusOn){ scen.setAction("RLE.1.OFF"); }else{ scen.setAction("RLE.1.ON"); } statusOn=!statusOn;
HiNTEGROv1.0byCIEMMESRL
Page23/32 ©CopyrightMonday,Jun17,2019,8:09AMbyCIEMMESRL
},2000);}
Diseguitounesempiopercreareuntimersingleshot
varidTimer=scen.setTimeout(expression,delay_time);IdTimer=idTimercreato
expression=espressionejavascriptdaEseguire
scen.clearTimeout(idTimer);funzioneperterminareuntimeredeliminarlodallamemoria.Unavoltarichiamataquestafunzioneiltimernonesistepiù.
//Esempioditimerconfunzioneascadenza
functionmain(){ varstatusOn=true; varid=scen.setTimeout(function(){ if(statusOn){ scen.setAction("RLE.1.OFF"); }else{ scen.setAction("RLE.1.ON"); } statusOn=!statusOn; },2000);}
CONTROLLOACCESSIQuestacallbackvienerichiamataperognieventoinviatodalcontrolloaccessi
functionevent_onAccessEvent(_gate,_type,_code,_result){
}
_gate=numerodelvarcoacuièavvenutol'evento_type=tipodievento_code=codicenumericooalfanumericodellatesseraodelpininserito_result=risultatodell'accesso
type
KYP=KEYPAD(varcocontastinumerici)RFD=varcoconrfid
result
HiNTEGROv1.0byCIEMMESRL
Page24/32 ©CopyrightMonday,Jun17,2019,8:09AMbyCIEMMESRL
OK=l'autenticazioneperaccederehaavutosuccessoKO=l'autenticazioneperaccederenonhaavutosuccesso
MAINHiNTEGROcaricaloscripteloeseguepartendodallafunzionemain.QuindiperpoterpersonalizzareHiNTEGROattraversoloscripteditordeveessereusataquestafunzione.Dalmainpossonoessereusatituttiitipidioggettievariabiliefunzionielencatisopra.
functionmain(){}
LibrerieUartQuestalibreriapermettedileggereescriveresuunaserialecollegataadHiNTEGRO
Percrearelaseriale
serial=newUart();
Persettareiparametriusareleseguentivariabili:
FlowControl:
flowcontrol.noflowcontrolflowcontrol.hardwarecontrolflowcontrol.softwarecontrolflowcontrol.unknownflowcontrol
BaudRate:
1200240048009600192003840057600115200
dichiararepoituttelecallbacknecessarieperlaricezionedeglieventi:
HiNTEGROv1.0byCIEMMESRL
Page25/32 ©CopyrightMonday,Jun17,2019,8:09AMbyCIEMMESRL
serial.onConnect.connect(_onConnect);serial.onDisconnect.connect(_onDisconnect);serial.onData.connect(_onData);serial.onError.connect(_onError);
function_onConnect(_id){}function_onDisconnect(_id){}function_onData(_id,_data){}function_onError(_id,_error){}
Perscriveresullaserialesipuo'usare:
scritturadiunastringaformatotesto
writeData(String);
oppurescritturadiunarrayespecificandolalinghezzadell'arraydascrivere
writeData(Bytearray,length);
serial.writeData(stringa);
varbytearray[]={0x00,0x02,0x03};serial.writeData(bytearray,3);
esempioscript:
varserial;
functionmain(){
serial.setID("serial1"); serial.setBaudRate(9600); serial.setFlowControl(flowcontrol.noflowcontrol);
serial.onConnect.connect(_onConnect); serial.onDisconnect.connect(_onDisconnect); serial.onData.connect(_onData); serial.onError.connect(_onError);
serial.openSerialPort("/dev/ttyUSB0");
}
function_onConnect(_id){ scen.log(level.WARNING,"connesso"); serial.writeData("inviodati\n");}
HiNTEGROv1.0byCIEMMESRL
Page26/32 ©CopyrightMonday,Jun17,2019,8:09AMbyCIEMMESRL
function_onDisconnect(_id){ scen.log(level.WARNING,"Disconnesso");}
function_onData(_id,_data){ scen.log(level.WARNING,_data);}
function_onError(_id,_error){
}
HiNTEGROmetteadisposizionedellelibrerieperlagestionedirettadeibusdicampodirettamentedaJavascript.
LibreriaModbusClientQuestalibreriapermettedicreareModbusClient.
Percreareilclientbastarichiamareilmetodonewesettareipeportadiconnessione.
client=newModbus();client.connectTo("192.168.1.1",502);
dichiararepoituttelecallbacknecessarieperlaricezionedeglieventi:
client.onWriteSuccess.connect(_onWriteSuccess);client.onWriteError.connect(_onWriteError);client.onReadError.connect(_onReadError);client.onReadRegister.connect(_onReadRegister);client.onReadRegisters.connect(_onReadRegisters);client.onReadCoil.connect(_onReadCoil);client.onReadCoils.connect(_onReadCoils);client.onReadInputStatus.connect(_onReadInputStatus);client.onReadInputStatuses.connect(_onReadInputStatuses);client.onReadInputRegister.connect(_onReadInputRegister);client.onReadInputRegisters.connect(_onReadInputRegisters);
function_onWriteSuccess(station,address){}function_onWriteError(station,address,value){}function_onReadError(station,address,value){}function_onReadRegister(station,address,value){}function_onReadCoil(station,address,value){}function_onReadRegisters(station,address,value){}function_onReadCoils(station,address,value){}function_onReadInputStatus(station,address,value){}function_onReadInputStatuses(station,address,value){}function_onReadInputRegister(station,address,value){}function_onReadInputRegisters(station,address,value){}
HiNTEGROv1.0byCIEMMESRL
Page27/32 ©CopyrightMonday,Jun17,2019,8:09AMbyCIEMMESRL
Nelfile_hintegro.jsesistonoenondevonoesseretoccateleprototipazionidelleCallBack!!!
perpoterleggereescrivereiregistrimodbususaremetodiseguenti:
varret=[]; ret=client.r_registers(station,address,nregistri); ret=client.r_register(station,address);
ret=client.r_coil(station,address); ret=client.r_coils(station,address,nregistri);
ret=client.r_input_status(station,address); ret=client.r_input_statuses(station,address,nregistri);
ret=client.r_input_register(station,address); ret=client.r_input_registers(station,address,nregistri);
ret=client.w_registers(station,address,[value,value,value]); ret=client.w_register(station,address,value); ret=client.w_coils(station,address,[value,value,value]); ret=client.w_coil(station,address,value);
Diseguitovieneriportatounesempiocompletodiunprogrammajavascriptperlagestionecompletadelmodbusclient:
varid;
functionmain(){
this.id=1;
varclient=newModbus(); client.connectTo("192.168.2.111",502);
client.onWriteSuccess.connect(_onWriteSuccess); client.onWriteError.connect(_onWriteError); client.onReadError.connect(_onReadError); client.onReadRegister.connect(_onReadRegister); client.onReadRegisters.connect(_onReadRegisters); client.onReadCoil.connect(_onReadCoil); client.onReadCoils.connect(_onReadCoils); client.onReadInputStatus.connect(_onReadInputStatus); client.onReadInputStatuses.connect(_onReadInputStatuses); client.onReadInputRegister.connect(_onReadInputRegister); client.onReadInputRegisters.connect(_onReadInputRegisters);
varret=[]; ret=client.r_registers(1,1,4); ret=client.r_register(1,100);
ret=client.r_coil(1,3); ret=client.r_coils(1,1,11);
ret=client.r_input_status(1,11);
HiNTEGROv1.0byCIEMMESRL
Page28/32 ©CopyrightMonday,Jun17,2019,8:09AMbyCIEMMESRL
ret=client.r_input_statuses(1,1,11);
ret=client.r_input_register(1,11); ret=client.r_input_registers(1,1,11);
ret=client.w_registers(1,1,[1,2,3,4]); ret=client.w_register(1,1,23); ret=client.w_coils(1,1,[1,0,1,0,1,1,1,1,1]); ret=client.w_coil(1,1,0);
}
function_onWriteSuccess(station,address){ scen.log(level.DEBUG,"Writesucessfullyonstation:"+station+"address:"+address);}
function_onWriteError(station,address,value){
}
function_onReadError(station,address,value){
}
function_onReadRegister(station,address,value){ scen.log(level.DEBUG,"Readregisteronstation:"+station+"address:"+address+"value:"+value);}
function_onReadCoil(station,address,value){ scen.log(level.DEBUG,"Readcoilonstation:"+station+"address:"+address+"value:"+value);}
function_onReadRegisters(station,address,value){ value.forEach(function(element){ scen.log(level.INFO,"RegistresReadfromstation:"+station+"fromaddress:"+address+"registersvalue:"+element); address++; });}
function_onReadCoils(station,address,value){ value.forEach(function(element){ scen.log(level.INFO,"CoilsReadfromstation:"+station+"fromaddress:"+address+"registersvalue:"+element); address++; });
HiNTEGROv1.0byCIEMMESRL
Page29/32 ©CopyrightMonday,Jun17,2019,8:09AMbyCIEMMESRL
}
function_onReadInputStatus(station,address,value){ scen.log(level.DEBUG,"Readinputstatusonstation:"+station+"address:"+address+"value:"+value);}
function_onReadInputStatuses(station,address,value){ value.forEach(function(element){ scen.log(level.INFO,"InputstatusReadfromstation:"+station+"fromaddress:"+address+"registersvalue:"+element); address++; });}
function_onReadInputRegister(station,address,value){ scen.log(level.DEBUG,"Readinputregisteronstation:"+station+"address:"+address+"value:"+value);}
function_onReadInputRegisters(station,address,value){ value.forEach(function(element){ scen.log(level.INFO,"InputregisterReadfromstation:"+station+"fromaddress:"+address+"registersvalue:"+element); address++; });}
LibreriaModbusServerQuestalibreriapermettedicreareModbusServerancheconistanzemultiple,bastaassegnareunriferimentounivocoinfasedicreazione.
Lecallbackdeglieventiavrannosempreilriferimentounivocoriportatoneimessaggiinmododicapireinqualsiasimomentodaqualeistanzaarrivailmessaggio.
PercreareilserverbastarichiamareilmetodonewesettareidunivocoeportaTCP/IP:
testModbusServer=newmodbusServer();
testModbusServer.setId(id);testModbusServer.setPort(502);
dichiararepoituttelecallbacknecessarieperlaricezionedeglieventi:
HiNTEGROv1.0byCIEMMESRL
Page30/32 ©CopyrightMonday,Jun17,2019,8:09AMbyCIEMMESRL
testModbusServer.logMessage.connect(_logMessage);testModbusServer.onNewConnection.connect(_onNewConnection);testModbusServer.onError.connect(_onError);testModbusServer.onWriteMultipleRegistersJS.connect(_onWriteMultipleRegisters);testModbusServer.onWriteMultipleCoilsJS.connect(_onWriteMultipleCoils);testModbusServer.onWriteSingleRegister.connect(_onWriteSingleRegister);testModbusServer.onWriteSingleCoil.connect(_onWriteSingleCoil);
function_onWriteSingleCoil(srv,station,address,data){}function_onWriteSingleRegister(srv,station,address,data){}function_onWriteMultipleCoils(srv,station,address,count,data){}function_onWriteMultipleRegisters(srv,station,address,count,data){}function_onNewConnection(srv){}function_onError(srv,message){}function_logMessage(srv,message){}
eperultimofarpartireilmodbusserver:
testModbusServer.startServer();
Lalibreriametteadisposizionelapossibilitàdiscrivereeleggereiregistridirettamentedajavascriptimetodiseguenti:
-testModbusServer.setCoilRegister(serverId,station,address,value); -valueboolean
-testModbusServer.setDiscretInputRegister(serverId,station,address,value); -valueboolean
-testModbusServer.setHoldingRegister(serverId,station,address,value); -valueinteger
-testModbusServer.setInputRegister(serverId,station,address,value); -valueinteger
-testModbusServer.setCoilRegister(serverId,station,address,value); -valueboolean
-testModbusServer.setDiscretInputRegister(serverId,station,address,value); -valueboolean
-testModbusServer.setHoldingRegister(serverId,station,address,value); -valueinteger
-testModbusServer.getInputRegister(serverId,station,address,value); -valueinteger
AssolutamenteilmetodostartServer()deveessererichiamatosolodopoaverdichiaratolecallbackprecedentemente
HiNTEGROv1.0byCIEMMESRL
Page31/32 ©CopyrightMonday,Jun17,2019,8:09AMbyCIEMMESRL
elencate.Nelfile_hintegro.jsesistonoenondevonoesseretoccateleprototipazionidelleCallBack!!!
Diseguitovieneriportatounesempiocompletodiunprogrammajavascriptperlagestionecompletadelmodbusserver:
vartestModbusServer;varid;
functionmain(){
this.id=1;
scen.log(level.INFO,"StartModbusServerwithid:"+this.id);
testModbusServer=newmodbusServer();
testModbusServer.setId(id);
testModbusServer.setPort(502);
testModbusServer.logMessage.connect(_logMessage); testModbusServer.onNewConnection.connect(_onNewConnection); testModbusServer.onError.connect(_onError);testModbusServer.onWriteMultipleRegistersJS.connect(_onWriteMultipleRegisters); testModbusServer.onWriteMultipleCoilsJS.connect(_onWriteMultipleCoils); testModbusServer.onWriteSingleRegister.connect(_onWriteSingleRegister); testModbusServer.onWriteSingleCoil.connect(_onWriteSingleCoil);
testModbusServer.setHoldingRegister(1,1,150,56);
testModbusServer.startServer();
}
function_onWriteSingleCoil(srv,station,address,data){
}
function_onWriteSingleRegister(srv,station,address,data){
}
function_onWriteMultipleCoils(srv,station,address,count,data){
}
function_onWriteMultipleRegisters(srv,station,address,count,data){
data.forEach(function(element){ scen.log(level.INFO,"MultipleHoldingRegisterserverId:"+srv+
HiNTEGROv1.0byCIEMMESRL
Page32/32 ©CopyrightMonday,Jun17,2019,8:09AMbyCIEMMESRL
"ValuesWritefromstation:"+station+"fromaddress:"+address+"for:"+count+"registersvalue:"+element); });data .forEach(function(element){
scen.log(level.INFO,"MultipleHoldingRegisterserverId:"+srv+"ValuesWritefromstation:"+station+"fromaddress:"+address+"for:"+count+"registersvalue:"+element); });
}
function_onNewConnection(srv){ scen.log(level.DEBUG,"NewConnectionincomingonsrv"+srv);}
function_onError(srv,message){ scen.log(level.ERROR,"erroronsrv"+srv+":"+message);}
function_logMessage(srv,message){scen.log(level.DEBUG,"messageonsrv"+srv+":"+message);}