static public byte[] RequestExchange(byte[] pdubytes) { // At this time the only thing I want to handle is a SZL-Request of SZL ID 0x0131 Index 3 and // make my own response to it. // So do it the simple way... bool header_ok, parameter_ok, data_ok; short SZL_id, SZL_index; // 1. Check length: A SZL request is 26 bytes long if (pdubytes.Length == 26) { // 2. Check Header header_ok = (pdubytes[0] == 0x32 && pdubytes[1] == 0x07 && // Protocol ID, Userdata pdubytes[6] == 0x00 && pdubytes[7] == 0x08 && // Length of Parameter is 8 bytes pdubytes[8] == 0x00 && pdubytes[9] == 0x08); // Length of data is 8 bytes if (header_ok) { // 3. Check parameter parameter_ok = (pdubytes[10] == 0x00 && pdubytes[11] == 0x01 && pdubytes[12] == 0x12 && pdubytes[13] == 0x04 && pdubytes[14] == 0x11 && pdubytes[15] == 0x44 && pdubytes[16] == 0x01 && pdubytes[17] == 0x00); if (parameter_ok) { // 4. Check data data_ok = (pdubytes[18] == 0xff && pdubytes[19] == 0x09 && pdubytes[20] == 0x00 && pdubytes[21] == 0x04); if (data_ok) { SZL_id = ByteConvert.GetInt16at(pdubytes, 22); SZL_index = ByteConvert.GetInt16at(pdubytes, 24); /* 4.11.2015: As we now support cyclic telegrams, * it is no longer neccessary to build answers for ID 0x0131. * LED-State SZL still not supported by Plcsim. */ //System.Diagnostics.Debug.Print("SZL-Request ID " + SZL_id + " Index " + SZL_index); //if (SZL_id == 0x0131 && SZL_index == 0x0003) //{ // return GetSzlId0131_idx3_response(ref pdubytes); if (SZL_id == 0x0074 && SZL_index == 0x0000) { return(GetSzlId0x0074_response(ref pdubytes)); } else if (SZL_id == 0x0f74 && SZL_index == 0x0000) { return(GetSzlId0x0f74_idx0_response(ref pdubytes)); } else if (SZL_id == 0x0174) { return(GetSzlId0x0174_response(SZL_index, ref pdubytes)); } /* * else if (SZL_id == 0x0011) * { * return GetSzlId0x0011_response(ref pdubytes); * } * else if (SZL_id == 0x001c) * { * return GetSzlId0x001c_response(ref pdubytes); * } * */ } } } } return(null); }