Untitled

mail@pastecode.io avatar
unknown
java
2 years ago
1.8 kB
2
Indexable
Never
	//parses radar triggering config packet From Device (FRD)
	public RadarConfig parse_FRD_Radar_triggering_config(byte[] baFRD, RadarConfig radar) throws Exception
	{
		Error err = new Error();

		switch(baFRD[9]){
		case (byte) PERRC:
			err = parse_FRD_Error_Code(baFRD);
			break;
		case (byte) PPR:
		case (byte) PPTNV:	
				int iPar_length = get_packet_body_length(baFRD, FRD_packet_body_size_position);
				byte[] baParameters = new byte[iPar_length - 1];
				System.arraycopy(baFRD, FRD_packet_body_start_position, baParameters, 0, iPar_length - 1);
				Logger.getLogger("").info(String.format("Odgovor sa znaka - PPTNV: %s", ByteArray_to_hexString(baParameters)));
				for(int i=0; i< baParameters.length; i=i+3)
				{										
					if(baParameters[i] == (byte)radar.iTriggeringSpeeds_ID)
					{
						radar.iLowerTriggeringSpeed = (int) baParameters[i+1] & 0xFF;
						radar.iHigherTriggeringSpeed = (int) baParameters[i+2] & 0xFF;							
					}
					else if(baParameters[i] == (byte)radar.iTriggeringSignalPlan_ID)
					{
						radar.iTriggeringSignalPlan1 = baParameters[i+1];
						radar.iTriggeringSignalPlan2 = baParameters[i+2];
						radar.iTriggeringSignalPlan3 = baParameters[i+3];
					}
				}
				break;
		case (byte) PPTV:		
		case (byte) PEVENT:
			break;
		}		
		Logger.getLogger("").info(String.format("Odgovor sa znaka - RadarTriggeringConfiguration - iLowerTriggeringSpeed: %d(kmh), " +
						"iHigherTriggeringSpeed: %d(kmh), iTriggeringSignalPlan1: %d, iTriggeringSignalPlan2: %d, " + 
						"iTriggeringSignalPlan3: %d", radar.iLowerTriggeringSpeed, radar.iHigherTriggeringSpeed, radar.iTriggeringSignalPlan1,  
						radar.iTriggeringSignalPlan2, radar.iTriggeringSignalPlan3));
		radar.eErr = err;
		return radar;
	}