Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-20 07:58:58

0001 """
0002 Event spec class
0003 
0004 """
0005 
0006 from .spec_base import SpecBase
0007 
0008 
0009 class EventSpec(SpecBase):
0010     # attributes
0011     attributesWithTypes = (
0012         "eventRangeID:text / index",
0013         "PandaID:integer / index",
0014         "eventStatus:text",
0015         "coreCount:integer",
0016         "cpuConsumptionTime:integer",
0017         "subStatus:text / index",
0018         "fileID:integer",
0019         "loss:text",
0020     )
0021 
0022     # constructor
0023     def __init__(self):
0024         SpecBase.__init__(self)
0025 
0026     # convert to data
0027     def to_data(self):
0028         data = {}
0029         for attr in self.attributes:
0030             # ignore some attributes
0031             if attr not in ["eventRangeID", "eventStatus", "coreCount", "cpuConsumptionTime", "loss"]:
0032                 continue
0033             val = getattr(self, attr)
0034             # don't propagate finished until subStatus is finished
0035             if attr == "eventStatus":
0036                 if val == "finished" and not self.is_final_status():
0037                     val = "running"
0038             if val is not None:
0039                 data[attr] = val
0040         return data
0041 
0042     # convert from data
0043     def from_data(self, data, panda_id):
0044         for attr, val in data.items():
0045             # skip non attributes
0046             if attr not in self.attributes:
0047                 continue
0048             setattr(self, attr, val)
0049         self.PandaID = int(panda_id)
0050 
0051     # final status
0052     def is_final_status(self):
0053         return self.subStatus in ["finished", "done", "failed"]