Skip to content
Snippets Groups Projects
Select Git revision
  • c31a8f61f933fa3f7d91fe6c31cd086f1451dae3
  • master default
2 results

channel.py

Blame
  • channel.py 983 B
    import numpy as np
    import importlib
    import config
    importlib.reload(config)
    class Channel:
        def __init__(self, ChannelId, NumberNodes, Capacity, SlopeLin, SlopeSat):
            self.Capacity = Capacity
            self.SlopeLin = SlopeLin
            self.SlopeSat = SlopeSat
            self.ChannelId = ChannelId
            self.Linear = np.ones(config.SimulationTimeslots)
            self.NrUsers = np.zeros(config.SimulationTimeslots)
            self.AccessMatrix = np.zeros((NumberNodes,config.SimulationTimeslots))
        
        def channel_access(self,NodeId,Timestamp):
            if (Timestamp < config.SimulationTimeslots):
                self.AccessMatrix[NodeId,Timestamp] = 1
                self.NrUsers[Timestamp]+=1
                
        
        def update_state(self,Timestamp):
            if (Timestamp < config.SimulationTimeslots):
                if (self.NrUsers[Timestamp] < (self.Capacity / self.SlopeLin)):
                    self.Linear[Timestamp] = 1
                else:
                    self.Linear[Timestamp] = 0