Public Member Functions | |
| void | setLen (byte len) |
| byte | getLen () |
| void | setTransportControl (byte d_r, byte tag, byte mpr, byte seg) throws IndexOutOfBoundsException |
| byte[] | getTransportControl () |
| void | setSegmentNr (byte segNr) |
| byte | getSegmentNr () |
| void | setInvokeID (byte invokeID) |
| byte | getInvokeID () |
| void | setCentralControl (byte centralControlID, byte centralControlSubID) |
| byte[] | getCentralControl () |
| void | setIslandControl (byte islandControlID, byte islandControlSubID) |
| byte[] | getIslandControl () |
| void | setDataPointID (byte[] dataPointID) throws IndexOutOfBoundsException |
| byte[] | getDataPointID () |
| void | setOperationsCode (byte fct_id, byte tab_id, byte dp_type, byte dp_subtype) throws IndexOutOfBoundsException |
| byte[] | getOperationsCode () |
| void | setApplicationControl (byte prd, byte rpr, byte emq) throws IndexOutOfBoundsException |
| byte[] | getApplicationControl () |
| void | setMask (byte val, byte apr, byte mis, byte msk) throws IndexOutOfBoundsException |
| byte[] | getMask () |
| void | setInfoEvent (byte info, byte event) throws IndexOutOfBoundsException |
| byte[] | getInfoEvent () |
| boolean[] | getInfoEventBits () |
| void | setInfoCode (byte exc_1, byte exc_2) |
| byte[] | getInfoCode () |
| void | setDateTime (byte year, byte month, byte day, byte hour, byte minute, byte second) throws IndexOutOfBoundsException |
| byte[] | getDateTime () |
| void | setDataPart (byte[] data) throws IndexOutOfBoundsException |
| byte[] | getDataPart () |
| byte[] | getFndDatagramByteArray () |
| FND_DataPointContext | getContext () |
| void | setContext (FND_DataPointContext context) |
| byte[] | getDatagramHeader () |
| byte | getDatapointType () |
| void | setDatapointType (byte dpointtype) |
| byte | getDatagramSegmentType () |
| void | setDatagramSegmentType (byte dgramsegtype) |
| byte | getDatagramTag () |
| void | setDatagramTag (byte dgramattr) |
| byte | getDatagramType () |
| void | setDatagramType (byte dgramtype) |
| int | getProtocolVersion () |
| InetAddress | getSender () |
| void | setSender (InetAddress address) |
Static Public Attributes | |
| final int | FND10 = 0xF0 |
| final int | FND20 = 0xF1 |
| final byte | TAG_NORMAL = 0 |
| final byte | TAG_REJECT = 1 |
| final byte | TAG_ERROR = 2 |
| final byte | D_R_CMD = 0 |
| final byte | D_R_RSP = 3 |
| final byte | D_R_USM = 2 |
| final byte | D_R_ACK = 1 |
| final byte | MPR_NORMAL = 0 |
| final byte | MPR_IMPORTANT = 1 |
| final byte | MPR_HIGH = 2 |
| final byte | MPR_URGENT = 3 |
| final byte | SEG_NO = 0 |
| final byte | SEG_FIRST = 3 |
| final byte | SEG_NEXT = 2 |
| final byte | SEG_LAST = 1 |
| final byte | IMPLICIT_FCT = 0 |
| final byte | READ_FCT = 1 |
| final byte | MODIFY_FCT = 2 |
| final byte | DP_TAB_0 = 0 |
| final byte | DP_TAB_1 = 1 |
| final byte | DP_TAB_2 = 2 |
| final byte | DP_TAB_1_2 = 3 |
Package Attributes | |
| FND_DataPointContext | context = null |
| InetAddress | sender = null |
| byte[] | data = null |
| int | dataLen = 0 |
J. Seitter
|
|
Returns applicationControl.
00592 {
00593 // For explanation and an example what's happening here see
00594 // getTransportControl()
00595 byte[] applicationControl = {(byte) ((data[27] & 0xC0) >>> 6), // id
00596 (byte) ((data[27] & 0x30) >>> 4), // rights
00597 (byte) ((data[27] & 0x0F)) // mec
00598 };
00599 return applicationControl;
00600 }
|
|
|
Returns CentralControlID and centralControlSubID.
00275 {
00276 byte[] centralControl = { data[5], data[6] };
00277 return centralControl;
00278 }
|
|
|
01131 {
01132 return context;
01133 }
|
|
|
01154 {
01155
01156 //copy the header part of the datagram
01157 byte[] header = new byte[38];
01158 for(int i=0; i<38; i++){
01159 header[i]=this.data[i];
01160 }
01161 return header;
01162 }
|
|
|
01217 {
01218 // returns the tag field
01219 // it's used together with the constants
01220 return this.getTransportControl()[1];
01221 }
|
|
|
Returns DateTime.
01109 {
01110 byte[] dataPart = new byte[data[1] - 36];
01111 // space for dataPart (length-2-36)
01112 for (int i = 0; i < dataPart.length; i++) {
01113 dataPart[i] = data[38 + i];
01114 }
01115 return dataPart;
01116 }
|
|
|
Returns dataPointID.
00346 {
00347 byte[] dataPointID = new byte[16];
00348 for (int i = 0; i < 16; ++i) {
00349 dataPointID[i] = data[i + 9]; // data[9] to [25]
00350 }
00351 return dataPointID;
00352 }
|
|
|
01167 {
01168 // returns the dp_type field already casted to int
01169 // it's used together with the constants
01170 return this.getOperationsCode()[2];
01171 }
|
|
|
Returns DateTime.
01065 {
01066 byte[] dateTime =
01067 {
01068 (byte) (data[32]),
01069 (byte) (data[33]),
01070 (byte) (data[34]),
01071 (byte) (data[35]),
01072 (byte) (data[36]),
01073 (byte) (data[37])};
01074 return dateTime;
01075 }
|
|
|
Returns raw byte array of the FND_Datagram. This is needed for sending the FND_Datagram with i.e. UDP
01125 {
01126 return data;
01127 }
|
|
|
Returns InfoCode.
00951 {
00952 // For an explanation and an example what's happening here, see
00953 // getTransportControl()
00954 byte[] infoCode = {(byte) (data[30]), (byte) (data[31])};
00955 return infoCode;
00956 }
|
|
|
Returns InfoEvent.
00789 {
00790 byte[] infoEvent = {(byte) ((data[29] & 0xF0) >>> 4), // info
00791 (byte) ((data[29] & 0x0F)) // event
00792 };
00793 return infoEvent;
00794 }
|
|
|
returns the InfoEvent field as an array of boolean values
00801 {
00802 boolean[] infoEventBits = new boolean[8];
00803 if((data[29] & 0x01)==1)
00804 {infoEventBits[0]=true;}
00805 else
00806 {infoEventBits[0]=false;}
00807
00808 if(((data[29] & 0x02)>>>1)==1)
00809 {infoEventBits[1]=true;}
00810 else
00811 {infoEventBits[1]=false;}
00812
00813 if(((data[29] & 0x04)>>>2)==1)
00814 {infoEventBits[2]=true;}
00815 else
00816 {infoEventBits[2]=false;}
00817
00818 if(((data[29] & 0x08)>>>3)==1)
00819 {infoEventBits[3]=true;}
00820 else
00821 {infoEventBits[3]=false;}
00822
00823 if(((data[29] & 0x10)>>>4)==1)
00824 {infoEventBits[4]=true;}
00825 else
00826 {infoEventBits[4]=false;}
00827
00828 if(((data[29] & 0x20)>>>5)==1)
00829 {infoEventBits[5]=true;}
00830 else
00831 {infoEventBits[5]=false;}
00832
00833 if(((data[29] & 0x40)>>>6)==1)
00834 {infoEventBits[6]=true;}
00835 else
00836 {infoEventBits[6]=false;}
00837
00838 if(((data[29] & 0x80)>>>7)==1)
00839 {infoEventBits[7]=true;}
00840 else
00841 {infoEventBits[7]=false;}
00842
00843 return infoEventBits;
00844 }
|
|
|
Returns Datagrams invoke ID.
00243 {
00244 return this.data[4];
00245 }
|
|
|
Returns islandControlID and islandControlSubID.
00308 {
00309 byte[] islandControl = { data[7], data[8] };
00310 return islandControl;
00311 }
|
|
|
00102 {
00103 return this.data[1];
00104 }
|
|
|
Returns Mask.
00730 {
00731 // For an explanation and an example what's been done here, see
00732 // getTransportControl()
00733 byte[] mask = {(byte) ((data[28] & 0xC0) >>> 6), // val (2 bits)
00734 (byte) ((data[28] & 0x30) >>> 4), // apr (2 bits)
00735 (byte) ((data[28] & 0x0C) >>> 2), // mis (2 bits)
00736 (byte) ((data[28] & 0x03)) // msk (2 bits)
00737 };
00738 return mask;
00739 }
|
|
|
Returns operationsCode.
00468 {
00469 // for an example and what's happening here, see getTransportControl()
00470 byte[] operationCode =
00471 {(byte) ((this.data[25] & 0xF0) >>> 4), // fct_id
00472 (byte) ((this.data[25] & 0x0F)), // tab_id
00473 (byte) ((this.data[26] & 0xF0) >>> 4), // dp_type
00474 (byte) ((this.data[26] & 0x0F)) // dp_subtype
00475 };
00476 return operationCode;
00477 }
|
|
|
01259 {
01260 return (int) data[0];
01261 }
|
|
|
Returns Datagrams segment number.
00219 {
00220 return this.data[3];
00221 }
|
|
|
01266 {
01267 return sender;
01268 }
|
|
|
Used to get the four values of the transport-control byte.
00185 {
00186 // masks out the values inside the transportControl byte (data[2]) and
00187 // builds a byte array.
00188 byte[] transportControl = {(byte) ((this.data[2] & 0xC0) >>> 6), //d_r
00189 (byte) ((this.data[2] & 0x30) >>> 4), // tag
00190 (byte) ((this.data[2] & 0x0C) >>> 2), // mpr
00191 (byte) (this.data[2] & 0x03) // seg
00192 };
00193 // transportControl tag extraction (example):
00194 // transportControl 1011 0110
00195 // 1011 0110 & 0x30 => 0011 0000
00196 // 0011 0000 >>> 4 => 0000 0011 -> tag = 3
00197
00198 return transportControl;
00199 }
|
|
||||||||||||||||
|
These settings are used to implement acces rights and access priorities.
00554 {
00555 if (prd > 3) {
00556 throw (
00557 new IndexOutOfBoundsException(
00558 "FND_Datagram.setApplicationControl() parameter id, above maximum, value="
00559 + prd
00560 + "maximum value=3"));
00561 }
00562 if (rpr > 3) {
00563 throw (
00564 new IndexOutOfBoundsException(
00565 "FND_Datagram.setApplicationControl() parameter rights, above maximum, value="
00566 + rpr
00567 + "maximum value=3"));
00568 }
00569 if (emq > 15) {
00570 throw (
00571 new IndexOutOfBoundsException(
00572 "FND_Datagram.setApplicationControl() parameter mec, above maximum, value="
00573 + emq
00574 + "maximum value=15"));
00575 }
00576
00577 this.data[27] = prd;
00578 this.data[27] <<= 2;
00579 this.data[27] |= rpr;
00580 this.data[27] <<= 2;
00581 this.data[27] |= emq;
00582 }
|
|
||||||||||||
|
This information is used to indentify the central control associated with the datagram
00261 {
00262 this.data[5] = centralControlID;
00263 this.data[6] = centralControlSubID;
00264 }
|
|
|
01140 {
01141 this.context = context;
01142 }
|
|
|
Put raw byte data into the data-part of the FND_Datagram.
01088 {
01089 if (data.length > 90) {
01090 throw (
01091 new IndexOutOfBoundsException(
01092 "FND_Datagram.SetDataPart() parameter data, above maximum length, value="
01093 + data.length
01094 + "maximum length=90"));
01095 }
01096
01097 for (int i = 0; i < data.length; ++i) {
01098 this.data[38 + i] = data[i];
01099 }
01100 }
|
|
|
The DataPoint ID is a unique ID assigned to every datapoint.
00325 {
00326
00327 if (dataPointID.length > 16) {
00328 throw (
00329 new IndexOutOfBoundsException("FND_Datagram.setDataPointID: dataPointID too large (too many characters"));
00330 }
00331 System.arraycopy(dataPointID, 0, data, 9, dataPointID.length);
00332
00333 // If the dataPointID is shorter than 16 characters, zeros are added.
00334 for (int i = dataPointID.length; i <= 16; ++i) {
00335 this.data[9 + dataPointID.length] = 0;
00336 }
00337 }
|
|
|
01178 {
01179 // returns the dp_type field
01180 // it's used together with the constants
01181 byte[] tmp_dpointtype = this.getTransportControl();
01182 tmp_dpointtype[2] = dpointtype;
01183 this.setTransportControl(
01184 tmp_dpointtype[0],
01185 tmp_dpointtype[1],
01186 tmp_dpointtype[2],
01187 tmp_dpointtype[3]);
01188 }
|
|
||||||||||||||||||||||||||||
|
Date and time the datagram was created.
00989 {
00990 if (year > 99) {
00991 throw (
00992 new IndexOutOfBoundsException(
00993 "FND_Datagram.SetDateTime() parameter year, above maximum, value="
00994 + year
00995 + "maximum value=99"));
00996 }
00997 if (month == 0) {
00998 throw (
00999 new IndexOutOfBoundsException(
01000 "FND_Datagram.SetDateTime() parameter month, below minimum, value="
01001 + month
01002 + "minumum value=1"));
01003 } else if (month > 12) {
01004 throw (
01005 new IndexOutOfBoundsException(
01006 "FND_Datagram.SetDateTime() parameter month, above maximum, value="
01007 + month
01008 + "maximum value=12"));
01009 }
01010 if (day == 0) {
01011 throw (
01012 new IndexOutOfBoundsException(
01013 "FND_Datagram.SetDateTime() parameter day, below minimum, value="
01014 + day
01015 + "minimum value=1"));
01016 } else if (day > 31) {
01017 throw (
01018 new IndexOutOfBoundsException(
01019 "FND_Datagram.SetDateTime() parameter day, above maximum, value="
01020 + day
01021 + "maximum value=31"));
01022 }
01023 if (hour > 23) {
01024 throw (
01025 new IndexOutOfBoundsException(
01026 "FND_Datagram.SetDateTime() parameter hour, above maximum, value="
01027 + hour
01028 + "maximum value=23"));
01029 }
01030 if (minute > 59) {
01031 throw (
01032 new IndexOutOfBoundsException(
01033 "FND_Datagram.SetDateTime() parameter minute, above maximum, value="
01034 + minute
01035 + "maximum value=59"));
01036 }
01037 if (second > 59) {
01038 throw (
01039 new IndexOutOfBoundsException(
01040 "FND_Datagram.SetDateTime() parameter second, above maximum, value="
01041 + second
01042 + "maximum value=59"));
01043 }
01044
01045 this.data[32] = year;
01046 this.data[33] = month;
01047 this.data[34] = day;
01048 this.data[35] = hour;
01049 this.data[36] = minute;
01050 this.data[37] = second;
01051 }
|
|
||||||||||||
|
If the parameter "tag" from the transport control byte is 1, the datagram has been rejected. The info-code is used to specify the reason for the reject.
Possible values for the two parameters exc_1 and exc_2:
00938 {
00939 this.data[30] = exc_1;
00940 this.data[31] = exc_2;
00941 }
|
|
||||||||||||
|
These Settings are used to specify additional information about the data-point and wich events occured. The possible parameter values depend on the type of the data point.
00761 {
00762 if (info > 15) {
00763 throw (
00764 new IndexOutOfBoundsException(
00765 "FND_Datagram.setInfoEvent() parameter info, above maximum, value="
00766 + info
00767 + "maximum value=15"));
00768 }
00769 if (event > 15) {
00770 throw (
00771 new IndexOutOfBoundsException(
00772 "FND_Datagram.setInfoEvent() parameter event, above maximum, value="
00773 + event
00774 + "maximum value=15"));
00775 }
00776
00777 this.data[29] = info;
00778 this.data[29] <<= 4;
00779 this.data[29] |= event;
00780 }
|
|
|
The invode ID is used as an internal flow control and securing mechanism. It limits the number of currently pending request or processings by issueing a ticket (the invokeID) out of a limited pool. After completion of the request or process, the ticket is returned to the pool and can be issued again. If all avaialable tickets are in use no more request are accepted.
00233 {
00234 this.data[4] = invokeID;
00235 }
|
|
||||||||||||
|
This information is used to indentify the island control associated with the datagram
00293 {
00294 this.data[7] = islandControlID;
00295 this.data[8] = islandControlSubID;
00296 }
|
|
|
Set Length of Datagram. Has to be the complete length of FND_Datagram (in bytes) minus 2.
00094 {
00095 this.data[1] = len;
00096 }
|
|
||||||||||||||||||||
|
These settings are used to specify permissions and the message surpression of a datapoint.
00681 {
00682 if (val > 3) {
00683 throw (
00684 new IndexOutOfBoundsException(
00685 "FND_Datagram.setMask() parameter val, above maximum, value="
00686 + val
00687 + "maximum value=3"));
00688 }
00689 if (apr > 3) {
00690 throw (
00691 new IndexOutOfBoundsException(
00692 "FND_Datagram.setMask() parameter apr, above maximum, value="
00693 + apr
00694 + "maximum value=3"));
00695 }
00696 if (mis > 3) {
00697 throw (
00698 new IndexOutOfBoundsException(
00699 "FND_Datagram.setMask() parameter mis, above maximum, value="
00700 + mis
00701 + "maximum value=3"));
00702 }
00703 if (msk > 3) {
00704 throw (
00705 new IndexOutOfBoundsException(
00706 "FND_Datagram.setMask() parameter msk, above maximum, value="
00707 + msk
00708 + "maximum value=3"));
00709 }
00710
00711 this.data[28] = val;
00712 this.data[28] <<= 2;
00713 this.data[28] |= apr;
00714 this.data[28] <<= 2;
00715 this.data[28] |= mis;
00716 this.data[28] <<= 2;
00717 this.data[28] |= msk;
00718 }
|
|
||||||||||||||||||||
|
Sets all parameters of the operations code. It is used to determine wich operation is requested and wich DataPoint tables is to be modified.
00419 {
00420 if (fct_id > 2) {
00421 throw (
00422 new IndexOutOfBoundsException(
00423 "FND_Datagram.setOperationsCode: Parameter fct_id, above maximum, value="
00424 + fct_id
00425 + "maximum value=2"));
00426 }
00427 if (tab_id > 3) {
00428 throw (
00429 new IndexOutOfBoundsException(
00430 "FND_Datagram.setOperationsCode: Parameter tab_id, above maximum, value="
00431 + tab_id
00432 + "maximum value=3"));
00433 }
00434 if (dp_type > 6) {
00435 throw (
00436 new IndexOutOfBoundsException(
00437 "FND_Datagram.setOperationsCode: Parameter dp_type, above maximum, value="
00438 + dp_type
00439 + "maximum value=6"));
00440 }
00441 if (dp_subtype > 6) {
00442 throw (
00443 new IndexOutOfBoundsException(
00444 "FND_Datagram.setOperationsCode: Parameter dp_subtype, above maximum, value="
00445 + dp_subtype
00446 + "maximum value=6"));
00447 }
00448
00449 // Adding and shifting
00450 this.data[25] = fct_id;
00451 this.data[25] <<= 4;
00452 this.data[25] |= tab_id;
00453 this.data[26] = dp_type;
00454 this.data[26] <<= 4;
00455 this.data[26] |= dp_subtype;
00456 }
|
|
|
Used to set the segment number. If there is no segmentation, the value is zero. In case there is a segmentation this number needs to be a 0-based, continously increasing value, used in all fragments of the FND datagram.
00209 {
00210 this.data[3] = segNr;
00211 }
|
|
|
01274 {
01275 sender = address;
01276 }
|
|
||||||||||||||||||||
|
Creates the transport control byte by combining all the function parameters. The maximum value for every parameter is 3.
00133 {
00134
00135 // Check wether any parameter has exceeded it's maximum allowed value.
00136 if (d_r >= 4) {
00137 throw (
00138 new IndexOutOfBoundsException(
00139 "FND_Datagram.setTransportControl: d_r parameter, above maximum, value="
00140 + d_r
00141 + " maximum value=3"));
00142 }
00143 if (tag >= 4) {
00144 throw (
00145 new IndexOutOfBoundsException(
00146 "FND_Datagram.setTransportControl: tag parameter, above maximum, value="
00147 + tag
00148 + " maximum value=3"));
00149 }
00150 if (mpr >= 4) {
00151 throw (
00152 new IndexOutOfBoundsException(
00153 "FND_Datagram-setTransportControl: mpr parameter, above maximum, value="
00154 + mpr
00155 + " maximum value=3"));
00156 }
00157 if (seg >= 4) {
00158 throw (
00159 new IndexOutOfBoundsException(
00160 "FND_Datagram-setTransportControl: seg parameter, above maximum, value="
00161 + seg
00162 + " maximum value=3"));
00163 }
00164
00165 this.data[2] = d_r;
00166 this.data[2] <<= 2;
00167 this.data[2] |= tag;
00168 this.data[2] <<= 2;
00169 this.data[2] |= mpr;
00170 this.data[2] <<= 2;
00171 this.data[2] |= seg;
00172 }
|
1.3.3