use of org.eclipse.titan.log.viewer.parsers.data.LogRecord in project titan.EclipsePlug-ins by eclipse.
the class MSCModel method extractNodes.
/**
* Extracts the nodes from the provided event object.
*
* @param ievent the event to extract the data from.
* @param occurrence the number at which time this event happened in its order.
*
* @return the resulting list of nodes.
*/
private MSCNode[] extractNodes(final IEventObject ievent, final int occurrence) {
if (!(ievent instanceof EventObject)) {
return new MSCNode[] {};
}
EventObject event = (EventObject) ievent;
String ref = event.getReference();
String target = event.getTarget();
String name = event.getName();
String time = event.getTime();
String type = event.getEventType();
String sourcePort = event.getPort();
String targetPort = event.getTargetPort();
switch(event.getType()) {
// TC start
case TC_START:
return testCaseStart(name, time, this.frame.lifeLinesCount(), occurrence);
// TC end
case TC_END:
return testCaseEnd(name, time, this.frame.lifeLinesCount(), occurrence);
// Creation of System Component
case SYSTEM_CREATE:
ref = Constants.SUT_REFERENCE;
return createComponent(ref, time, this.lifelines.get(ref), occurrence);
// Creation of Host Controller (HC)
case HC_CREATE:
ref = Constants.HC_REFERENCE;
return createComponent(ref, time, this.lifelines.get(ref), occurrence);
// Creation of Main Test Component (MTC)
case MTC_CREATE:
{
ref = Constants.MTC_REFERENCE;
Lifeline lifeLine = this.lifelines.get(ref);
return createComponent(ref, time, lifeLine, occurrence);
}
// Creation of Parallel Test Component (PTC)
case PTC_CREATE:
return createComponent(ref, time, this.lifelines.get(ref), occurrence);
// Termination of System Component
case SYSTEM_TERMINATE:
ref = Constants.SUT_REFERENCE;
return terminateComponent(ref, time, occurrence);
// Termination of Host Controller (HC)
case HC_TERMINATE:
ref = Constants.HC_REFERENCE;
return terminateComponent(ref, time, occurrence);
// Termination of Main Test Component (MTC)
case MTC_TERMINATE:
ref = Constants.MTC_REFERENCE;
return terminateComponent(ref, time, occurrence);
// Termination of Parallel Test Component (PTC)
case PTC_TERMINATE:
return terminateComponent(ref, time, occurrence);
// Messages
case SEND:
return addSignal(new SendSignal(), ref, target, name, time, occurrence);
case RECEIVE:
return addSignal(new ReceiveSignal(), ref, target, name, time, occurrence);
// Enqueued messages
case ENQUEUED:
return addEnqueued(ref, target, name, time, occurrence);
// Silent events
case SILENT_EVENT:
LogRecord logrecord = null;
try {
logrecord = ValueReader.getInstance().readLogRecordFromLogFile(this.logFilePath, event);
} catch (final IOException valueException) {
return addSilentEvent(ref, "", type, time, occurrence);
} catch (final ParseException e) {
return addSilentEvent(ref, "", type, time, occurrence);
}
String messageText = getMessageTextFromRecord(logrecord);
return addSilentEvent(ref, messageText, type, time, occurrence);
// Functions
case FUNCTION:
return addFunctionNode(new Function(), ref, target, name, time, occurrence);
// Function done
case PTC_DONE:
return addFunctionNode(new FunctionDone(), ref, target, name, time, occurrence);
// Setverdict
case SETVERDICT:
case SETVERDICT_INCONC:
case SETVERDICT_NONE:
case SETVERDICT_PASS:
return addSetVerdict(ref, name, time, occurrence);
// Port mappings
case MAPPING_PORT:
return addPortEventNode(new PortMapping(sourcePort, targetPort), ref, target, time, occurrence);
// Port unmappings
case UNMAPPING_PORT:
return addPortEventNode(new PortUnmapping(sourcePort, targetPort), ref, target, time, occurrence);
// Port connections
case CONNECTING_PORT:
return addPortEventNode(new PortConnection(sourcePort, targetPort), ref, target, time, occurrence);
// Port disconnections
case DISCONNECTING_PORT:
return addPortEventNode(new PortDisconnection(sourcePort, targetPort), ref, target, time, occurrence);
default:
return new MSCNode[] {};
}
}
use of org.eclipse.titan.log.viewer.parsers.data.LogRecord in project titan.EclipsePlug-ins by eclipse.
the class OpenValueViewAction method run.
@Override
public void run() {
if (selectedLine == null || this.mscView == null || selectedLine < 2 || selectedLine >= this.mscView.getModel().getNumberOfEvents() + 2) {
return;
}
IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
if (activePage == null) {
return;
}
LogFileMetaData logFileMetaData = this.mscView.getLogFileMetaData();
IProject project = getProjectByName(logFileMetaData);
IFile logFile = getLogFileFromProject(logFileMetaData, project);
if (!logFile.exists()) {
IViewReference[] viewReferences = activePage.getViewReferences();
ActionUtils.closeAssociatedViews(activePage, viewReferences, logFile);
// $NON-NLS-1$
TitanLogExceptionHandler.handleException(new UserException(Messages.getString("OpenValueViewAction.1")));
return;
}
if (LogFileCacheHandler.hasLogFileChanged(logFile)) {
LogFileCacheHandler.handleLogFileChange(logFile);
return;
}
DetailsView detailsview = (DetailsView) activePage.findView(Constants.DETAILS_VIEW_ID);
if (detailsview == null && !forceEditorOpening) {
return;
}
if (forceEditorOpening) {
try {
detailsview = (DetailsView) activePage.showView(Constants.DETAILS_VIEW_ID);
} catch (PartInitException e) {
ErrorReporter.logExceptionStackTrace(e);
// $NON-NLS-1$
TitanLogExceptionHandler.handleException(new TechnicalException(Messages.getString("OpenValueViewAction.4") + e.getMessage()));
return;
}
}
// pass log file meta data
detailsview.setLogFileMetaData(this.mscView.getLogFileMetaData());
ExecutionModel model = this.mscView.getModel();
IEventObject ieventObject = model.getEvent(selectedLine - 2);
if (!(ieventObject instanceof EventObject)) {
return;
}
EventObject eventObject = (EventObject) ieventObject;
String testCase = model.getTestCase().getTestCaseName();
if ((testCase == null) || eventObject.getRecordNumber() == 0) {
return;
}
// get value
LogRecord logrecord;
try {
logrecord = ValueReader.getInstance().readLogRecordFromLogFileCached(this.mscView.getLogFileMetaData().getFilePath(), eventObject);
} catch (Exception e) {
ErrorReporter.logExceptionStackTrace(e);
// $NON-NLS-1$
TitanLogExceptionHandler.handleException(new TechnicalException(Messages.getString("OpenValueViewAction.3")));
return;
}
String message = logrecord.getMessage();
DetailData detailData = new DetailData(eventObject.getName(), eventObject.getPort(), message, testCase, eventObject.getEventType(), logrecord.getSourceInformation());
detailsview.setData(detailData, false);
}
use of org.eclipse.titan.log.viewer.parsers.data.LogRecord in project titan.EclipsePlug-ins by eclipse.
the class FilteredLogReader method runFilter.
public void runFilter(final FilterPattern filterPattern, final IProgressMonitor monitor) throws ParseException, IOException {
monitor.beginTask("Filtering", logReader.size());
if (filterPattern == null || filterPattern.equals(this.filterPattern) || logReader.size() == 0) {
monitor.done();
return;
}
List<Integer> tmpFilteredRecords = new ArrayList<Integer>();
for (int i = 0; i < logReader.size(); ++i) {
if (monitor.isCanceled()) {
monitor.done();
return;
}
LogRecord aRecord;
try {
aRecord = logReader.getRecord(i);
} catch (ParseException e) {
ErrorReporter.logExceptionStackTrace(e);
// $NON-NLS-1$
ParseException throwable = new ParseException("Could not parse the " + i + "th record ", 0);
throwable.initCause(e);
monitor.done();
throw throwable;
}
if (filterPattern.match(aRecord)) {
tmpFilteredRecords.add(i);
}
monitor.worked(1);
}
filtered = true;
filteredRecords = tmpFilteredRecords;
this.filterPattern = filterPattern;
monitor.done();
}
use of org.eclipse.titan.log.viewer.parsers.data.LogRecord in project titan.EclipsePlug-ins by eclipse.
the class SequentialLogFileReader method getNext.
/**
* Returns the next log record or null if the reader is at the end of the file.
* @return The parsed log record
* @throws ParseException
* @throws IOException
*/
public LogRecord getNext() throws ParseException, IOException {
if (!hasNext()) {
return null;
}
currentRecord++;
LogRecord result = recordParser.parse(readRecord());
result.setRecordOffset(logRecordIndexes[currentRecord].getFileOffset());
result.setRecordLength(logRecordIndexes[currentRecord].getRecordLength());
result.setRecordNumber(logRecordIndexes[currentRecord].getRecordNumber());
return result;
}
use of org.eclipse.titan.log.viewer.parsers.data.LogRecord in project titan.EclipsePlug-ins by eclipse.
the class ValueReader method getValue.
private String getValue(final URI logFilePath, final long offset, final int length) throws IOException, ParseException {
RandomAccessFile random = null;
String message = null;
try {
random = new RandomAccessFile(new File(logFilePath), MSCConstants.READ_ONLY);
random.seek(offset);
byte[] buffer = new byte[length];
random.read(buffer, 0, length);
RecordParser recordParser = new RecordParser();
LogRecord logRecord = recordParser.parse(buffer);
message = logRecord.getMessage();
} finally {
IOUtils.closeQuietly(random);
}
return message;
}
Aggregations