Hide
Bored? Check out the Recent Activity on Siafoo Join Siafoo Now or Learn More

Sessions and Subsessions

over 7 years ago

With this post I'm going to figure out how the session object works - what its methods are and how to create and manipulate it properly.

What is the session object? As per a previous entry, it is an object that has an array of subsession objects which have arrays of the data from the lines in the log.

The Session itself is the root object. There are not multiple sessions, but there are multiple subsessions within the containing array.

Session.subsessions[0] contains a subsession Session.subsessions[1] contains a subsession and so on...

Session.subsession[n].line[n] to access lines.

Should a line be an object? I'm not sure what the overhead of objects is. But, there are objects for simple ints and strings, so I guess it can be an object.

Quick outline of how the classes are...

# 's
 1class Session:
2 def __init__(self):
3 self.cursub = IntVar() # currently active subsession
4 self.subsessions = Array() # array of subsession objects
5
6class Subsession:
7 def __init__(self):
8 self.curline = IntVar() # current line
9 self.startpos = IntVar() # where this subsession starts
10 self.endpos = IntVar() # where this subsession ends
11 self.lines = Array() # the array of line objects
12
13class LogLine:
14 def __init__(self):
15 self.linenum = IntVar() # the index of this line - may not be needed
16 self.stamp = DoubleVar() # epoch timestamp of this line
17 self.actor = StringVar() # the person doing the action, whether an
18 # attack or heal
19 self.target = StringVar() # the target of that action
20 self.value = IntVar() # how much damage or healing was done
21 self.crit = BooleanVar() # whether it was a crit or not
22 self.dot = BooleanVar() # whether it was a damage over time or not
23 self.damtype = StringVar() # the damage type if applicable
24 self.skill = StringVar() # the skill used if applicable

When initializing the GUI, the Session is created, and then as fights start and end, subsessions are automatically created and added to the Session.subsessions array. Each time a line is read in, its data is entered into the Subsession.subsessions.lines[n] object. That line can then be accessed at any time to use its values in doing calculations on the fly.

The main thing to do right now is make the regexps that will pull the needed values out of the raw log line, and then figure out the best way to first process and THEN display the data. Originally the strings that came out of readlines() were pushed directly into the logbox text area. I guess I'll need to have three different .after methods - one to get the lines from the file and plug the data into logline, one to change the variables in the analysis panel based on info in the lines, and one to actually display modified log lines in the output box.

I am wondering whether this is better solved with three .afters or separate threads altogether. These .afters are too 'isolated' to really be part of the GUI's instructions - they can run independently of it as long as they know the filehandle and the analysis panel variables.