Back to project page diagnostic-tool.
The source code is released under:
Copyright (c) 2014 Ford Motor Company All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are me...
If you think the Android project diagnostic-tool listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.openxc.openxcdiagnostic.util; //w w w .ja v a2s.c om import java.util.Timer; import com.openxc.messages.Command; import com.openxc.messages.DiagnosticRequest; import com.openxc.messages.VehicleMessage; /** * * Class for emulating fake responses. * */ public class ResponseEmulator { private static Timer mTimer = new Timer(); public static void emulate(VehicleMessage request, VehicleMessage.Listener listener) { if (MessageAnalyzer.isDiagnosticRequest(request)) { DiagnosticRequest diagReq = (DiagnosticRequest) request; if (diagReq.getFrequency() != null && diagReq.getFrequency() > 0) { RecurringResponseGenerator generator = new RecurringResponseGenerator( diagReq, listener); mTimer.schedule(generator, 100, 1000); } } if (MessageAnalyzer.isCommand(request)) { listener.receive(Utilities .generateRandomFakeCommandResponse((Command) request)); } else if (MessageAnalyzer.isDiagnosticRequest(request)) { listener.receive(Utilities .generateRandomFakeResponse((DiagnosticRequest) request)); } } }