| 1 |
/* Copyright (C) 2022-2025 Free Software Foundation |
| 2 |
|
| 3 |
This program is free software; you can redistribute it and/or modify |
| 4 |
it under the terms of the GNU General Public License as published by |
| 5 |
the Free Software Foundation, either version 3 of the License, or |
| 6 |
(at your option) any later version. |
| 7 |
|
| 8 |
This program is distributed in the hope that it will be useful, |
| 9 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 |
GNU General Public License for more details. |
| 12 |
|
| 13 |
You should have received a copy of the GNU General Public License |
| 14 |
along with this program. If not, see <http://www.gnu.org/licenses>. */ |
| 15 |
|
| 16 |
package org.gprofng.mpmt.timeline.events; |
| 17 |
|
| 18 |
import org.gprofng.mpmt.AnInteger; |
| 19 |
import org.gprofng.mpmt.AnLocale; |
| 20 |
import org.gprofng.mpmt.AnLong; |
| 21 |
import org.gprofng.mpmt.statecolors.StackState; |
| 22 |
import org.gprofng.mpmt.timeline2.TimelineVariable; |
| 23 |
import java.awt.Color; |
| 24 |
import java.util.List; |
| 25 |
import javax.swing.ImageIcon; |
| 26 |
|
| 27 |
public class IOEvent extends ExtendedEvent implements DurationEvent, StateEvent { |
| 28 |
protected final String[] LABELS = { |
| 29 |
AnLocale.getString("IO Type:"), // NOI18N |
| 30 |
AnLocale.getString("IO File Descriptor:"), // NOI18N |
| 31 |
AnLocale.getString("IO Bytes:"), // NOI18N |
| 32 |
AnLocale.getString("Duration (msec.):") // NOI18N |
| 33 |
}; |
| 34 |
|
| 35 |
public final int type; // IO Type |
| 36 |
public final int fd; // File Descriptor |
| 37 |
public final long bytes; // Number of bytes |
| 38 |
public final long duration; // in nanosec |
| 39 |
private final String[] eventSpecificInfo; |
| 40 |
|
| 41 |
public IOEvent( |
| 42 |
int lwpid, |
| 43 |
int thrid, |
| 44 |
int cpuid, |
| 45 |
long ts, |
| 46 |
long stack, |
| 47 |
long func, |
| 48 |
List<StackState> stackStates, |
| 49 |
int type, |
| 50 |
int fd, |
| 51 |
long bytes, |
| 52 |
long duration, |
| 53 |
long time_adjust) { |
| 54 |
super(lwpid, thrid, cpuid, ts, stack, func, time_adjust, stackStates); |
| 55 |
|
| 56 |
this.type = type; |
| 57 |
this.fd = fd; |
| 58 |
this.bytes = bytes; |
| 59 |
this.duration = duration; |
| 60 |
this.eventSpecificInfo = initEventSpecificInfo(); |
| 61 |
} |
| 62 |
|
| 63 |
public String[] getEventSpecificInfo() { |
| 64 |
String[] rc = this.eventSpecificInfo.clone(); |
| 65 |
return rc; |
| 66 |
} |
| 67 |
|
| 68 |
private String[] initEventSpecificInfo() { |
| 69 |
String typename; |
| 70 |
typename = TimelineVariable.iotype_info.getNameByRawIdx(type); |
| 71 |
return new String[] { |
| 72 |
typename, |
| 73 |
new AnInteger(fd).toString(), |
| 74 |
new AnLong(bytes).toString(), |
| 75 |
new AnLong(duration).toTime(.000001) |
| 76 |
}; |
| 77 |
} |
| 78 |
|
| 79 |
public String[] getEventSpecificLabels() { |
| 80 |
return LABELS; |
| 81 |
} |
| 82 |
|
| 83 |
public long getDuration() { |
| 84 |
return duration; |
| 85 |
} |
| 86 |
|
| 87 |
public ImageIcon[] getEventSpecificIcons() { |
| 88 |
Color color = TimelineVariable.iotype_info.getColorByRawIdx(type); |
| 89 |
ImageIcon icon = new ImageIcon(StackState.createIcon(color)); |
| 90 |
return new ImageIcon[] { |
| 91 |
icon, null, null, null, |
| 92 |
}; |
| 93 |
} |
| 94 |
|
| 95 |
public int getState() { |
| 96 |
return type; |
| 97 |
} |
| 98 |
} |