コード例 #1
0
ファイル: session.py プロジェクト: KeithLatteri/awips2
class Sender:

  def __init__(self, session):
    self.session = session
    self.next_id = serial(0)
    self.commands = []
    self._completed = RangedSet()

  def send(self, cmd):
    ch = self.session.channel
    if ch is None:
      raise SessionDetached()
    cmd.id = self.next_id
    self.next_id += 1
    if self.session.send_id:
      self.session.send_id = False
      ch.session_command_point(cmd.id, 0)
    self.commands.append(cmd)
    ch.connection.write_op(cmd)

  def completed(self, commands):
    idx = 0
    while idx < len(self.commands):
      cmd = self.commands[idx]
      if cmd.id in commands:
        del self.commands[idx]
      else:
        idx += 1
    for range in commands.ranges:
      self._completed.add(range.lower, range.upper)
コード例 #2
0
ファイル: session.py プロジェクト: 571451370/devstack_mitaka
class Sender:
    def __init__(self, session):
        self.session = session
        self.next_id = serial(0)
        self.commands = []
        self._completed = RangedSet()

    def send(self, cmd):
        ch = self.session.channel
        if ch is None:
            raise SessionDetached()
        cmd.id = self.next_id
        self.next_id += 1
        if self.session.send_id:
            self.session.send_id = False
            ch.session_command_point(cmd.id, 0)
        self.commands.append(cmd)
        ch.connection.write_op(cmd)

    def completed(self, commands):
        idx = 0
        while idx < len(self.commands):
            cmd = self.commands[idx]
            if cmd.id in commands:
                del self.commands[idx]
            else:
                idx += 1
        for range in commands.ranges:
            self._completed.add(range.lower, range.upper)
コード例 #3
0
ファイル: session.py プロジェクト: KeithLatteri/awips2
class Receiver:

  def __init__(self, session):
    self.session = session
    self.next_id = None
    self._completed = RangedSet()

  def received(self, cmd):
    if self.next_id == None:
      raise Exception("todo")
    cmd.id = self.next_id
    self.next_id += 1

  def completed(self, cmd):
    if cmd.id == None:
      raise ValueError("cannot complete unidentified command")
    self._completed.add(cmd.id)

  def known_completed(self, commands):
    completed = RangedSet()
    for c in self._completed.ranges:
      for kc in commands.ranges:
        if c.lower in kc and c.upper in kc:
          break
      else:
        completed.add_range(c)
    self._completed = completed
コード例 #4
0
ファイル: session.py プロジェクト: 571451370/devstack_mitaka
class Receiver:
    def __init__(self, session):
        self.session = session
        self.next_id = None
        self._completed = RangedSet()

    def received(self, cmd):
        if self.next_id == None:
            raise Exception("todo")
        cmd.id = self.next_id
        self.next_id += 1

    def completed(self, cmd):
        if cmd.id == None:
            raise ValueError("cannot complete unidentified command")
        self._completed.add(cmd.id)

    def known_completed(self, commands):
        completed = RangedSet()
        for c in self._completed.ranges:
            for kc in commands.ranges:
                if c.lower in kc and c.upper in kc:
                    break
            else:
                completed.add_range(c)
        self._completed = completed
コード例 #5
0
ファイル: session.py プロジェクト: KeithLatteri/awips2
 def known_completed(self, commands):
   completed = RangedSet()
   for c in self._completed.ranges:
     for kc in commands.ranges:
       if c.lower in kc and c.upper in kc:
         break
     else:
       completed.add_range(c)
   self._completed = completed
コード例 #6
0
ファイル: session.py プロジェクト: 571451370/devstack_mitaka
 def known_completed(self, commands):
     completed = RangedSet()
     for c in self._completed.ranges:
         for kc in commands.ranges:
             if c.lower in kc and c.upper in kc:
                 break
         else:
             completed.add_range(c)
     self._completed = completed
コード例 #7
0
 def read_sequence_set(self):
     result = RangedSet()
     size = self.read_uint16()
     nranges = size / 8
     while nranges > 0:
         lower = self.read_sequence_no()
         upper = self.read_sequence_no()
         result.add(lower, upper)
         nranges -= 1
     return result
コード例 #8
0
ファイル: codec010.py プロジェクト: KeithLatteri/awips2
 def read_sequence_set(self):
   result = RangedSet()
   size = self.read_uint16()
   nranges = size/8
   while nranges > 0:
     lower = self.read_sequence_no()
     upper = self.read_sequence_no()
     result.add(lower, upper)
     nranges -= 1
   return result
コード例 #9
0
ファイル: driver.py プロジェクト: KeithLatteri/awips2
 def session_known_completed(self, kcmp):
   sst = self.get_sst(kcmp)
   executed = RangedSet()
   for e in sst.executed.ranges:
     for ke in kcmp.ranges:
       if e.lower in ke and e.upper in ke:
         break
     else:
       executed.add_range(e)
   sst.executed = completed
コード例 #10
0
 def session_flush(self, ch, f):
   rcv = ch.session.receiver
   if f.expected:
     if rcv.next_id == None:
       exp = None
     else:
       exp = RangedSet(rcv.next_id)
     ch.session_expected(exp)
   if f.confirmed:
     ch.session_confirmed(rcv._completed)
   if f.completed:
     ch.session_completed(rcv._completed)
コード例 #11
0
ファイル: session.py プロジェクト: KeithLatteri/awips2
 def __init__(self, session):
   self.session = session
   self.next_id = serial(0)
   self.commands = []
   self._completed = RangedSet()
コード例 #12
0
ファイル: session.py プロジェクト: KeithLatteri/awips2
 def __init__(self, session):
   self.session = session
   self.next_id = None
   self._completed = RangedSet()
コード例 #13
0
ファイル: session.py プロジェクト: 571451370/devstack_mitaka
 def __init__(self, session):
     self.session = session
     self.next_id = serial(0)
     self.commands = []
     self._completed = RangedSet()
コード例 #14
0
ファイル: session.py プロジェクト: 571451370/devstack_mitaka
 def __init__(self, session):
     self.session = session
     self.next_id = None
     self._completed = RangedSet()