\r
public class AnalyzerConstants {\r
// if log change occurs then increase save data version!!\r
+ public static final String DA_VERSION = "2.1";\r
public static final String SAVE_DATA_VERSION = "0.84"; //$NON-NLS-1$\r
public static final boolean CHECK_INTERNAL = true;\r
\r
public static final String MSG_START = "100"; //$NON-NLS-1$\r
public static final String MSG_STOP = "101"; //$NON-NLS-1$\r
public static final String MSG_OPTION = "103"; //$NON-NLS-1$\r
+ public static final String MSG_VERSION = "999"; //$NON-NLS-1$\r
+ public static final String MSG_OK = "901"; //$NON-NLS-1$\r
+ public static final String MSG_NOT_OK = "902"; //$NON-NLS-1$\r
\r
public static final int OPT_OFF = 0x0000;\r
public static final int OPT_CPUMEM = 0x0001;\r
public static final int LOCAL_PORT = 8000;
public static final int REMOTE_PORT = 8001;
+ private static Socket controlSock = null;
private static Socket sock = null;
private static SmartDevelopmentBridge sdbBridge = null;
private static AppDesktopInfo selectedApp = null;
private static DeviceInfo currentDevice = null;
private static BufferedWriter writer = null;
private static BufferedReader reader = null;
+ private static BufferedWriter controlWriter = null;
+ private static BufferedReader controlReader = null;
private static boolean isRunning = false;
private static List<DeviceInfo> devices = null;
private static List<AppDesktopInfo> appDesktopList = null;
return sock;
}
+ public static Socket createControlSocket(int port) {
+ try {
+
+ controlSock = new Socket(CommonConstants.LOCAL_HOST, port);
+ if (null == controlSock) {
+ System.out.println("failed to create a control socket"); //$NON-NLS-1$
+ return null;
+ }
+
+ controlSock.setSoTimeout(AnalyzerConstants.SOCKET_TIMEOUT);
+ controlSock.setReuseAddress(true);
+ controlSock.setTcpNoDelay(true);
+
+ controlReader = new BufferedReader(new InputStreamReader(
+ controlSock.getInputStream()));
+ controlWriter = new BufferedWriter(new OutputStreamWriter(
+ controlSock.getOutputStream()));
+ } catch (SocketTimeoutException e) {
+ System.out.println("socket timeout."); //$NON-NLS-1$
+ e.printStackTrace();
+ } catch (UnknownHostException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ return controlSock;
+ }
+
public static void closeSocket() {
AnalyzerUtil.tryClose(reader, writer, sock);
}
}
}
+ public static String handleControlMessage(String message) {
+ String result = null;
+ try {
+ if (null != controlSock) {
+ controlWriter.write(message);
+ controlWriter.flush();
+ }
+
+ System.out.println("wait for ack...");
+ while (isRunning) {
+ if (null != (result = controlReader.readLine())
+ && !result.isEmpty()) {
+ break;
+ }
+ System.out.println("wait!!");
+ }
+ System.out.println("pass");
+// result = "test ack message";
+
+ } catch (IOException e) {
+ System.out.println(e.getMessage());
+ return null;
+ }
+ return result;
+ }
+
public static SyncResult push(String local, String remote) {
return push(local, remote, SyncService.getNullProgressMonitor());
}
*/
package org.tizen.dynamicanalyzer.communicator;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
import org.tizen.dynamicanalyzer.common.AnalyzerConstants;
import org.tizen.dynamicanalyzer.common.CommonConstants;
import org.tizen.dynamicanalyzer.model.DeviceInfo;
import org.tizen.dynamicanalyzer.nl.ConfigureLabels;
+import org.tizen.dynamicanalyzer.resources.ImageResources;
import org.tizen.dynamicanalyzer.ui.toolbar.ConfigureManager;
+import org.tizen.dynamicanalyzer.ui.widgets.DADialog;
+import org.tizen.dynamicanalyzer.utils.AnalyzerUtil;
public class ResourceCommunicator extends DACommunicator {
setRunning(true);
- if (null == createSocket(LOCAL_PORT)) {
+ if (null == createControlSocket(LOCAL_PORT)) {
System.out.println("socket creation failed."); //$NON-NLS-1$
return false;
}
-
return true;
}
- public static void sendStartMessage() {
+ public static boolean sendVersionMessage() {
+ String message = AnalyzerConstants.MSG_VERSION
+ + CommonConstants.CMD_SPLIT + AnalyzerConstants.DA_VERSION;
+ System.out.println("Send control message :" + message); //$NON-NLS-1$
+
+ String result = handleControlMessage(message);
+
+ // test
+ result = "901|1|0";
+ // result = "902|3|2.0";
+ if (null != result) {
+ System.out.println("version message ack :" + result);
+ String[] splitResult = result.split(CommonConstants.CMD_SPLIT_READ);
+
+ if (AnalyzerConstants.MSG_NOT_OK.equals(splitResult[0])) {
+ final String deviceVersion = splitResult[2];
+ Display.getDefault().syncExec(new Runnable() {
+ @Override
+ public void run() {
+ Shell shell = AnalyzerUtil.getWorkbenchWindow()
+ .getShell();
+ DADialog warning = new DADialog(shell, SWT.NONE);
+ warning.setMessage("Version is invalid (device :"
+ + deviceVersion + " host :"
+ + AnalyzerConstants.DA_VERSION);
+ warning.setIcon(ImageResources.DIALOG_WARNING_ICON);
+ warning.open();
+ }
+ });
+ return false;
+ } else if (AnalyzerConstants.MSG_OK.equals(splitResult[0])) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public static boolean sendStartMessage() {
int isArm = 0;
int isEmul = 0;
int res = 0;
isEmul = 1;
}
- String rearMessage = ""+res
- + isEmul
- + isArm
- + CommonConstants.CMD_SPLIT
- + getConfiguration()
+ String rearMessage = "" + res + isEmul + isArm
+ + CommonConstants.CMD_SPLIT + getConfiguration()
+ CommonConstants.CMD_SPLIT
+ ResourceCommunicator.getSelectedApp().getExecPath();
String message = AnalyzerConstants.MSG_START
- + CommonConstants.CMD_SPLIT
-// + (ResourceCommunicator.getSelectedApp().getExecPath().length() + 7)
- + rearMessage.length()
- + CommonConstants.CMD_SPLIT
- + rearMessage;
-// + res
-// + isEmul
-// + isArm
-// + CommonConstants.CMD_SPLIT
-// + getConfiguration()
-// + CommonConstants.CMD_SPLIT
-// + ResourceCommunicator.getSelectedApp().getExecPath();
+ + CommonConstants.CMD_SPLIT + rearMessage.length()
+ + CommonConstants.CMD_SPLIT + rearMessage;
System.out.println("Send message :" + message); //$NON-NLS-1$
- sendMessage(message);
+
+ String result = handleControlMessage(message);
+ if (null != result) {
+ System.out.println("start message ack :" + result);
+ String[] splitResult = result.split(CommonConstants.CMD_SPLIT_READ);
+ if (AnalyzerConstants.MSG_OK.equals(splitResult[0])) {
+ createSocket(LOCAL_PORT);
+ return true;
+ }
+ }
+ return false;
}
- public static void sendSnapshotMessage(int state) {
+ public static boolean sendStopMessage() {
+ if (ResourceCommunicator.isRunning()) {
+ String message = AnalyzerConstants.MSG_STOP
+ + CommonConstants.CMD_SPLIT + 0 + CommonConstants.CMD_SPLIT;
+ System.out.println("stop send message :" + message);
+
+ String result = handleControlMessage(message);
+ if (null != result) {
+ System.out.println("stop message ack :" + result);
+ String[] splitResult = result
+ .split(CommonConstants.CMD_SPLIT_READ);
+ if (AnalyzerConstants.MSG_OK.equals(splitResult[0])) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ public static boolean sendSnapshotMessage(int state) {
String statestr = Integer.toString(state);
String message = AnalyzerConstants.MSG_OPTION
- + CommonConstants.CMD_SPLIT + statestr.length() + CommonConstants.CMD_SPLIT
- + statestr;
- sendMessage(message);
+ + CommonConstants.CMD_SPLIT + statestr.length()
+ + CommonConstants.CMD_SPLIT + statestr;
+
+ String result = handleControlMessage(message);
+ if (null != result) {
+ System.out.println("snapshot message ack :" + result);
+ String[] splitResult = result.split(CommonConstants.CMD_SPLIT_READ);
+ if (AnalyzerConstants.MSG_OK.equals(splitResult[0])) {
+ return true;
+ }
+ }
+ return false;
}
public static int getConfiguration() {
messages = message.split(CommonConstants.CMD_SPLIT_READ, 2);
- System.out.println("message :" + message);
try {
int index = Integer.parseInt(messages[0]);
if (AnalyzerConstants.MSG_APP_INFO == index) {
sentenceIndex = AnalyzerConstants.MSG_APP_INFO;
sentence = message;
- } else if (AnalyzerConstants.MSG_START.equals(messages[0])) {
- // start application
- DACommunicator.execCommand(ResourceCommunicator.getSelectedApp().getExecPath());
- } else {
+ }
+// else if (AnalyzerConstants.MSG_START.equals(messages[0])) {
+// // start application
+// DACommunicator.execCommand(ResourceCommunicator
+// .getSelectedApp().getExecPath());
+// }
+ else {
if (AnalyzerConstants.MSG_APP_INFO == sentenceIndex) {
processMessage(sentence);
sentence = null;
DAPageComposite page = AnalyzerManager.getCurrentPage();
if (page instanceof RangePage) {
AnalyzerUtil.changePage(TimelinePage.ID);
+ } else {
+ page.updateView();
}
DATabComposite mainTab = AnalyzerUtil.getMainTab();
if (logCenters.get(i).getId() != LogCenterConstants.LOG_DEVICE
&& logCenters.get(i).getId() != LogCenterConstants.LOG_PROFILING) {
Logs logs = new Logs(logCenters.get(i).getId());
- input = SqlManager.getInstance().selectArea(logCenters.get(i), from, to);
+ input = SqlManager.getInstance().selectArea(
+ logCenters.get(i), from, to);
logs.setLogs(input);
logPackage.setLogs(logCenters.get(i).getId(), logs);
}
for (int i = 0; i < size; i++) {
if (logCenters.get(i).getId() == LogCenterConstants.LOG_PROFILING) {
Logs logs = new Logs(logCenters.get(i).getId());
- input = SqlManager.getInstance().selectArea(logCenters.get(i), from, to);
+ input = SqlManager.getInstance().selectArea(
+ logCenters.get(i), from, to);
logs.setLogs(input);
profilePackage.setLogs(logCenters.get(i).getId(), logs);
}
package org.tizen.dynamicanalyzer.ui.toolbar;
-import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
import org.tizen.dynamicanalyzer.common.AnalyzerConstants;
import org.tizen.dynamicanalyzer.common.AnalyzerManager;
-import org.tizen.dynamicanalyzer.common.CommonConstants;
-import org.tizen.dynamicanalyzer.common.PathManager;
import org.tizen.dynamicanalyzer.communicator.ResourceCommunicator;
import org.tizen.dynamicanalyzer.handlers.ReplayTraceHandler;
import org.tizen.dynamicanalyzer.logparser.LogParser;
import org.tizen.dynamicanalyzer.nl.AnalyzerLabels;
-import org.tizen.dynamicanalyzer.resources.ImageResources;
import org.tizen.dynamicanalyzer.services.RecordStateSourceProvider;
import org.tizen.dynamicanalyzer.ui.file.FileChartManager;
import org.tizen.dynamicanalyzer.ui.summary.profiling.FunctionUsageProfiler;
import org.tizen.dynamicanalyzer.ui.userinterface.UIDataManager;
-import org.tizen.dynamicanalyzer.ui.widgets.DADialog;
import org.tizen.dynamicanalyzer.uirecorder.UIRecorderTool;
import org.tizen.dynamicanalyzer.utils.AnalyzerUtil;
import org.tizen.dynamicanalyzer.utils.UpdateViewTimer;
Display.getDefault().syncExec(new Runnable() {
@Override
public void run() {
- final Shell shell = AnalyzerUtil.getWorkbenchWindow()
- .getShell();
- DADialog dialog = new DADialog(shell, SWT.NONE);
- dialog.setIcon(ImageResources.DIALOG_WARNING_ICON);
- dialog.setMessage(AnalyzerLabels.START_TRACE_ERROR
- + PathManager.getLogPath());
- dialog.open();
+ // final Shell shell = AnalyzerUtil.getWorkbenchWindow()
+ // .getShell();
+ // DADialog dialog = new DADialog(shell, SWT.NONE);
+ // dialog.setIcon(ImageResources.DIALOG_WARNING_ICON);
+ // dialog.setMessage(AnalyzerLabels.START_TRACE_ERROR
+ // + PathManager.getLogPath());
+ // dialog.open();
ToolbarArea.getInstance().setToolbarState(
ToolbarArea.TOOLBAR_STATE_READY);
return false;
}
if (!AnalyzerManager.isExit()) {
+ // version check
+ if (!ResourceCommunicator.sendVersionMessage()) {
+ return false;
+ }
+ // version ok?
+
+ // send start message
+ if (!ResourceCommunicator.sendStartMessage()) {
+ return false;
+ }
+ // all right??
+
UIRecorderTool.getInstance().startRecorder();
- ResourceCommunicator.sendStartMessage();
ToolbarArea.getInstance().startTimer();
LogParser.startLogParser();
FileChartManager.getInstance().startUpdateLogThread();
}
});
- if (ResourceCommunicator.isRunning()) {
- ResourceCommunicator
- .sendMessage(AnalyzerConstants.MSG_STOP
- + CommonConstants.CMD_SPLIT + 0
- + CommonConstants.CMD_SPLIT);
- System.out.println("stop send message :"
- + AnalyzerConstants.MSG_STOP + CommonConstants.CMD_SPLIT
- + 0 + CommonConstants.CMD_SPLIT);
- }
+ // if (ResourceCommunicator.isRunning()) {
+ // ResourceCommunicator
+ // .sendMessage(AnalyzerConstants.MSG_STOP
+ // + CommonConstants.CMD_SPLIT + 0
+ // + CommonConstants.CMD_SPLIT);
+ // System.out.println("stop send message :"
+ // + AnalyzerConstants.MSG_STOP + CommonConstants.CMD_SPLIT
+ // + 0 + CommonConstants.CMD_SPLIT);
+ // }
+ ResourceCommunicator.sendStopMessage();
}
}
public void setSettingValueFromConfigFile() {
// Table Feature
-
- for (String featureName : ConfigurationDialogValues.getInstance()
- .getFeature()) {
- // boolean featuresStatus = true;
-
- int featuresStatus = Integer.parseInt(mConfig.getValue(featureName));
- // if (mConfig.getValue(featureName).equals(ON)) {
- // featuresStatus = true;
- // } else {
- // featuresStatus = false;
- // }
- if (featureName.equals(ConfigureLabels.FUNCTIONPROFILING)) {
- setbFunctionProfilingCall(featuresStatus);
- } else if (featureName.equals(ConfigureLabels.ALLOCATION)) {
- setbAllocationCall(featuresStatus);
- } else if (featureName.equals(ConfigureLabels.FILE)) {
- setbFileCall(featuresStatus);
- } else if (featureName.equals(ConfigureLabels.THREAD)) {
- setbThreadCall(featuresStatus);
- } else if (featureName.equals(ConfigureLabels.USERINTERFACE)) {
- setbUserInterfaceCall(featuresStatus);
- } else if (featureName.equals(ConfigureLabels.SNAPSHOT)) {
- setbSnapshotCall(featuresStatus);
- } else if (featureName.equals(ConfigureLabels.EVENT)) {
- setbEventCall(featuresStatus);
- } else if (featureName.equals(ConfigureLabels.RECORDING)) {
- setbRecordingCall(featuresStatus);
- } else {
- System.out.println("failed undefine features");
- }
- }
-
- // Setting
- if (mConfig.getValue(ConfigureLabels.SHOW_INITIAL).equals(ON)) {
- setShowInitia(true);
- } else {
- setShowInitia(false);
- }
- if (mConfig.getValue(ConfigureLabels.AUTO_STOP).equals(ON)) {
- setAutoStop(true);
- } else {
- setAutoStop(false);
- }
+//
+// for (String featureName : ConfigurationDialogValues.getInstance()
+// .getFeature()) {
+// // boolean featuresStatus = true;
+//
+// int featuresStatus = Integer.parseInt(mConfig.getValue(featureName));
+// // if (mConfig.getValue(featureName).equals(ON)) {
+// // featuresStatus = true;
+// // } else {
+// // featuresStatus = false;
+// // }
+// if (featureName.equals(ConfigureLabels.FUNCTIONPROFILING)) {
+// setbFunctionProfilingCall(featuresStatus);
+// } else if (featureName.equals(ConfigureLabels.ALLOCATION)) {
+// setbAllocationCall(featuresStatus);
+// } else if (featureName.equals(ConfigureLabels.FILE)) {
+// setbFileCall(featuresStatus);
+// } else if (featureName.equals(ConfigureLabels.THREAD)) {
+// setbThreadCall(featuresStatus);
+// } else if (featureName.equals(ConfigureLabels.USERINTERFACE)) {
+// setbUserInterfaceCall(featuresStatus);
+// } else if (featureName.equals(ConfigureLabels.SNAPSHOT)) {
+// setbSnapshotCall(featuresStatus);
+// } else if (featureName.equals(ConfigureLabels.EVENT)) {
+// setbEventCall(featuresStatus);
+// } else if (featureName.equals(ConfigureLabels.RECORDING)) {
+// setbRecordingCall(featuresStatus);
+// } else {
+// System.out.println("failed undefine features");
+// }
+// }
+//
+// // Setting
+// if (mConfig.getValue(ConfigureLabels.SHOW_INITIAL).equals(ON)) {
+// setShowInitia(true);
+// } else {
+// setShowInitia(false);
+// }
+// if (mConfig.getValue(ConfigureLabels.AUTO_STOP).equals(ON)) {
+// setAutoStop(true);
+// } else {
+// setAutoStop(false);
+// }
}
private void setConfig(boolean featureStatus, String featureName) {