Ejemplo n.º 1
0
        public static SactaMsg MsgToScv(Configuration.DependecyConfig cfg, MsgType type, int id, int seq, int version = 0, Dictionary <string, int> sectorUcs = null)
        {
            var msg = new SactaMsg(type, id, seq, sectorUcs, version)
            {
                DomainOrg = (byte)cfg.SactaProtocol.Sacta.Domain,
                CenterOrg = (byte)cfg.SactaProtocol.Sacta.Center,
                UserOrg   = type == MsgType.Init || type == MsgType.Presence ? (ushort)cfg.SactaProtocol.Sacta.SpvsList()[0] : (ushort)cfg.SactaProtocol.Sacta.PsisList()[0],
                DomainDst = (byte)cfg.SactaProtocol.Scv.Domain,
                CenterDst = (byte)cfg.SactaProtocol.Scv.Center,
                UserDst   = (ushort)cfg.SactaProtocol.Scv.Scv
            };

            if (type == MsgType.Presence)
            {
                (msg.Info as PresenceInfo).PresencePerioditySg = (ushort)cfg.SactaProtocol.TickAlive;
                (msg.Info as PresenceInfo).ActivityTimeOutSg   = (ushort)cfg.SactaProtocol.TimeoutAlive;
            }
            return(msg);
        }
Ejemplo n.º 2
0
        public PsiManager(int ProtocolVersion, Configuration.DependecyConfig cfg, Func <History> hist)
        {
            Cfg                  = cfg;
            Version              = ProtocolVersion;
            History              = hist;
            Locker               = new object();
            TxEnabled            = false;
            ScvActivity          = false;
            Sequence             = 0;
            SectorizationVersion = 0;
            LastActivityOnLan1   = DateTime.MinValue;
            LastActivityOnLan2   = DateTime.MinValue;
            LastPresenceSended   = DateTime.MinValue;

            Lan1Listen = new IPEndPoint(IPAddress.Parse(Cfg.Comm.If1.Ip), Cfg.Comm.ListenPort);
            Lan1Sendto = new IPEndPoint(IPAddress.Parse(Cfg.Comm.If1.IpTo), Cfg.Comm.SendingPort);
            Lan2Listen = new IPEndPoint(IPAddress.Parse(Cfg.Comm.If2.Ip), Cfg.Comm.ListenPort);
            Lan2Sendto = new IPEndPoint(IPAddress.Parse(Version == 0 ? Cfg.Comm.If2.IpTo : Cfg.Comm.If1.IpTo), Cfg.Comm.SendingPort);
        }
Ejemplo n.º 3
0
        public static SactaMsg MsgToSacta(Configuration.DependecyConfig cfg, MsgType type, int id, int seq, int version = 0, int result = 0)
        {
            var msg = new SactaMsg(type, id, seq, null, version, result)
            {
                DomainOrg = (byte)cfg.SactaProtocol.Scv.Domain,
                CenterOrg = (byte)cfg.SactaProtocol.Scv.Center,
                UserOrg   = (ushort)cfg.SactaProtocol.Scv.Scv,
                DomainDst = (byte)cfg.SactaProtocol.Sacta.Domain,
                CenterDst = (byte)cfg.SactaProtocol.Sacta.Center,
                UserDst   = (ushort)cfg.SactaProtocol.Sacta.PsiGroup
            };

            if (type == MsgType.Presence)
            {
                (msg.Info as PresenceInfo).PresencePerioditySg = (ushort)cfg.SactaProtocol.TickAlive;
                (msg.Info as PresenceInfo).ActivityTimeOutSg   = (ushort)cfg.SactaProtocol.TimeoutAlive;
            }
            return(msg);
        }
Ejemplo n.º 4
0
        public ScvManager(int Protocolversion, Configuration.DependecyConfig cfg, Func <History> hist)
        {
            Locker         = new object();
            Id             = cfg.Id;
            Cfg            = cfg;
            Version        = Protocolversion;
            History        = hist;
            SactaSPSIUsers = Cfg.SactaProtocol.Sacta.PsisList().Select(i => (ushort)i).ToDictionary(i => i, i => new PsiOrScvInfo());
            SactaSPVUsers  = Cfg.SactaProtocol.Sacta.SpvsList().Select(i => (ushort)i).ToDictionary(i => i, i => new PsiOrScvInfo());
            GlobalState    = SactaState.Stopped;
            TxEnabled      = false;

            LastActivityOnLan1 = DateTime.MinValue;
            LastActivityOnLan2 = DateTime.MinValue;
            LastPresenceSended = DateTime.MinValue;
            WhenSectorAsked    = DateTime.MinValue;

            Lan1Listen = new IPEndPoint(IPAddress.Parse(Cfg.Comm.If1.Ip), Cfg.Comm.ListenPort);
            Lan1Sendto = new IPEndPoint(IPAddress.Parse(Cfg.Comm.If1.McastGroup), Cfg.Comm.SendingPort);

            Lan2Listen = new IPEndPoint(IPAddress.Parse(Cfg.Comm.If2.Ip), Cfg.Comm.ListenPort);
            Lan2Sendto = new IPEndPoint(IPAddress.Parse(Cfg.Comm.If2.McastGroup), Cfg.Comm.SendingPort);
        }