On.. event functions
public static int Global_OnComm(int Com, long EventCode) {
String s = "OnComm - Event: 0x" + Long.toHexString(EventCode);
if (SuperCom.IsBitSet(EventCode, SuperCom.EV_RXCHAR)) {
s = s + ", EV_RXCHAR";
}
if (SuperCom.IsBitSet(EventCode, SuperCom.EV_TXEMPTY)) {
s = s + ", EV_TXEMPTY";
}
if (SuperCom.IsBitSet(EventCode, SuperCom.EV_RXFLAG)) {
s = s + ", EV_RXFLAG";
}
if (SuperCom.IsBitSet(EventCode, SuperCom.EV_TRIGGER)) {
s = s + ", EV_TRIGGER";
}
if (SuperCom.IsBitSet(EventCode, SuperCom.EV_RI)) {
s = s + ", EV_RI"; // ringing?
}
if (SuperCom.IsBitSet(EventCode, SuperCom.EV_DCD)) {
s = s + ", EV_DCD"; // connected
}
if (SuperCom.IsBitSet(EventCode, SuperCom.EV_DSR)) {
s = s + ", EV_DSR";
}
if (SuperCom.IsBitSet(EventCode, SuperCom.EV_CTS)) {
s = s + ", EV_DSR";
}
// : weitere Bits können gesetzt sein,
// es genügt nur die benötigten zu behandeln
System.out.format("COM_%d)%s\n",(Com+1),s);
return 0;
}
// Sammeln von kompletten Datenpaketen im Hintergrung.
public static int Global_OnDataPacket(int Com, short Action, byte[] Data)
{
int res = 0;
String s = "OnDataPacket Event:";
switch (Action) {
case SuperCom.SCOMM_DATAPACKET_OK:
s+=", OK [";
s+=SuperCom.ByteArrayToString(Data);
s+="]";
break;
case SuperCom.SCOMM_DATAPACKET_NOK:
s+=", ein unvollständiges Datenpaket [";
s+=SuperCom.ByteArrayToHexString(Data);
s+="]";
break;
}
System.out.format("COM_%d)%s\n",(Com+1),s);
return res;
}
public static int Global_OnConnect(int Com, short Action, int TimeLeft) {
int res = SuperCom.infCONTINUE;
String s="OnConnect-Event: " + Action;
if (Action == SuperCom.acCONNECT_INFO) {
s = s + ", INFO";
} else if (Action == SuperCom.acCONNECT_INIT) {
s = s + ", INIT";
} else if (Action == SuperCom.acCONNECT_DIALING) {
s = s + ", acCONNECT_DIALING";
} else if (Action == SuperCom.acCONNECT_CONNECTING) {
s = s + ", CONNECTING";
} else if (Action == SuperCom.acCONNECT_OK) {
s = s + ", CONNECTED!";
}else if (Action == SuperCom.acCONNECT_FAILED) {
s = s + ", erfolglos!";
}
System.out.format("COM_%d)%s\n",(Com+1),s);
return res;
}
public static int Global_OnFile(int Com, short Action, long Data, SuperCom.PFILEINFOPROC.TFDATA FileData) {
int res = SuperCom.infCONTINUE;
String s = "OnFile Event: ";
switch (Action) {
case SuperCom.acFILEDATA:
s = s + "acFILEDATA, ";
s = s + SuperCom.ZeroTerminatedByteArrayToString(FileData.FileName);
s = s + ", Filesize=" + FileData.FileSize;
s = s + ", Date=" + FileData.FileDate.Year + "-" + FileData.FileDate.Month + "-" + FileData.FileDate.Day;
s = s + ", Time=" + FileData.FileDate.Hour + ":" + FileData.FileDate.Min + ":" + FileData.FileDate.Sec;
break;
case SuperCom.acFILENAME: // Empfänger Dateiname,
s = s + "acFILENAME"; // hier kann z.B. eine 'DownloadDir' gesetzt werden
break;
case SuperCom.acTXING:
s = s + "acTXING, Data=";
s = s + Data;
break;
case SuperCom.acRXING:
s = s + "acRXING, Data=";
s = s + Data;
break;
case SuperCom.acTXFIN:
s = s + "acTXFIN, Data=" + (Data);
break;
case SuperCom.acRXFIN:
s = s + "acRXFIN, Data=" + (Data);
break;
case SuperCom.acUSERBREAK:
res = SuperCom.infBREAK;
break;
:
:
}
System.out.format("COM_%d)%s\n",(Com+1),s);
return res;
}