Beispiel #1
0
        private void setVariable(bool inc, TrafficDirection direction, string address, string varName, int value)
        {
            if (!Running || address.IsNullOrWhiteSpace() || varName.IsNullOrWhiteSpace() || value == 0)
            {
                return;
            }

            var state = this[direction];
            var grp   = state.FindGroupForAddress(address);

            var key = grp == null ? address : grp.Key;

            var nstate = state.NetState.GetOrAdd(key, (k) => grp == null ? new NetSiteState(address) : new NetSiteState(grp));

            lock (nstate)
            {
                if (inc)
                {
                    NetSiteState._value vval;
                    if (!nstate.m_Variables.TryGetValue(varName, out vval))
                    {
                        nstate.m_Variables[varName] = vval = new NetSiteState._value();
                    }
                    vval.Value += value;
                }
                else
                {
                    nstate.m_Variables[varName] = new NetSiteState._value {
                        Value = value
                    }
                };
            }
        }

        #endregion
    }
Beispiel #2
0
        private void setVariable(bool inc, TrafficDirection direction, string address, string varName, int value)
        {
            if (!Running || address.IsNullOrWhiteSpace() || varName.IsNullOrWhiteSpace() || value==0) return;

            var state = this[direction];
            var grp = state.FindGroupForAddress(address);

            var key = grp==null ? address : grp.Key;

            var nstate = state.NetState.GetOrAdd(key, (k) => grp==null ? new NetSiteState(address) : new NetSiteState(grp));

            lock(nstate)
            {
              if (inc)
              {
               NetSiteState._value vval;
               if (!nstate.m_Variables.TryGetValue(varName, out vval))
               {
             nstate.m_Variables[varName] = vval = new NetSiteState._value();
               }
               vval.Value += value;
              }
              else
               nstate.m_Variables[varName] = new NetSiteState._value{Value = value};
            }
        }