Echelon ISI User Manual
Page 35

33
ISI Programmer’s Guide
E
XAMPLE
1
The following example opens automatic enrollment:
void IsiUpdateUserInterface(IsiEvent Event, unsigned Parameter) {
if (Event == isiWarm && !IsiIsConnected(MyAssembly)) {
IsiInitiateAutoEnrollment(&MyCsmoData, MyAssembly);
}
}
E
XAMPLE
2
The following example opens manual enrollment for a simple assembly with
one network variable, using the network variable’s global index as the
application-specific assembly number:
void startEnrollment(void) {
unsigned
myAssembly;
myAssembly = nvoValue::global_index;
IsiOpenEnrollment(myAssembly);
}
E
XAMPLE
3
The following example opens controlled enrollment for a simple assembly
with one network variable, using the network variable’s global index as the
application-specific assembly number:
void sendControlResponse(boolean success) {
IsiMessage ctrlResp;
ctrlResp.Header.Code = isiCtrp;
ctrlResp.Ctrp.Success = success;
memcpy(ctrlResp.Ctrp.NeuronID,
read_only_data.neuron_id, NEURON_ID_LEN);
resp_out.code = isiApplicationMessageCode;
memcpy(resp_out.data, &ctrlResp,
sizeof(IsiMessageHeader)+sizeof(IsiCtrp));
resp_send();
}
when (msg_arrives) {
IsiMessage
inMsg;
unsigned
myAssembly;
if (IsiApproveMsg()) {
memcpy(&inMsg,
msg_in.data,
sizeof(IsiMessage));
myAssembly
=
nvoValue::global_index;
if (inMsg.Header.Code == isiCtrq) {
if (inMsg.Ctrq.Control == isiOpen &&
inMsg.Ctrq.Parameter
==
myAssembly)
{
sendControlResponse(TRUE);
IsiOpenEnrollment(myAssembly);
// Other requests deleted for this example
…
}
else
{
sendControlResponse(FALSE);
}
} else {
(void) IsiProcessMsgS();
}