123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- package rpcore
- import (
- "fmt"
- "strconv"
- "time"
- )
- type ProcStatus int8
- const (
- PROCSTAT_PendingToRun ProcStatus = iota
- PROCSTAT_Running ProcStatus = iota
- PROCSTAT_Exited ProcStatus = iota
- PROCSTAT_PendingToStop ProcStatus = iota
- PROCSTAT_PendingToDelete ProcStatus = iota
- PROCSTAT_ManuallyStopped
- )
- func (ps ProcStatus) ToString() string {
- switch ps {
- case PROCSTAT_PendingToRun:
- return "PendingR"
- case PROCSTAT_Running:
- return "Running"
- case PROCSTAT_Exited:
- return "Exited"
- case PROCSTAT_PendingToStop:
- return "PendingS"
- case PROCSTAT_ManuallyStopped:
- return "Stopped"
- case PROCSTAT_PendingToDelete:
- return "PendingD"
- default:
- return "Unknown"
- }
- }
- func (ps ProcStatus) ToStringAbbr() string {
- switch ps {
- case PROCSTAT_PendingToRun:
- return "PDR"
- case PROCSTAT_Running:
- return "RUN"
- case PROCSTAT_Exited:
- return "END"
- case PROCSTAT_PendingToStop:
- return "PDS"
- case PROCSTAT_ManuallyStopped:
- return "OFF"
- case PROCSTAT_PendingToDelete:
- return "PDD"
- default:
- return "UKN"
- }
- }
- type DisplayStatusInfo struct {
- CPID int64 `json:"cpid"`
- Name string `json:"name"`
- Status ProcStatus `json:"status"`
- StatusText string `json:"statusText"`
- StatusAbbr string `json:"statusAbbr"`
- PID int `json:"pid"`
- LastStartTime time.Time `json:"lastStartTime"`
- }
- func (i DisplayStatusInfo) ToPrintableTableData() []string {
- tmstr := "-"
- if !i.LastStartTime.IsZero() {
- tmstr = i.LastStartTime.Format(time.RFC3339Nano)
- }
- pid := "-"
- if i.PID > 0 {
- pid = strconv.Itoa(i.PID)
- }
- return []string{
- fmt.Sprintf("%16X", i.CPID),
- i.Name,
- i.StatusAbbr,
- pid,
- tmstr,
- }
- }
|