示例#1
0
        private static void NeMessageToSendSignalHandler(SignalTypeEnum signalType)
        {
            ToConsole("Received new message signal!");

            _pollMessagesToSend = true;
            WaitHandle.Set();
        }
示例#2
0
        private static void NewPartialPacketsToMergeSignalHandler(SignalTypeEnum signalType)
        {
            ToConsole("Received signal to process new message!");

            _pollPartialPackets = true;
            WaitHandle.Set();
        }
示例#3
0
        private static void QuitSignalHandler(SignalTypeEnum signalType)
        {
            ToConsole($"Received quit signal as '{signalType}'!");

            _doQuit = true;
            WaitHandle.Set();
        }
示例#4
0
        public static void IncreaseSignal(MongoConnection connection, string option, SignalTypeEnum signalType, double strength)
        {
            IMongoCollection <Signal> signalsCollection = connection.Database.GetCollection <Signal>(typeof(Signal).Name);

            FilterDefinition <Signal> filter =
                Builders <Signal> .Filter.Eq(signal => signal.Option, option) &
                Builders <Signal> .Filter.Eq(signal => signal.SignalType, signalType);

            long signalCount = signalsCollection.CountAsync(filter).Result;

            if (signalCount == 0)
            {
                Signal signal = new Signal()
                {
                    Option     = option,
                    SignalType = signalType,
                    Strength   = strength,
                };

                Task insertTask = signalsCollection.InsertOneAsync(signal);

                insertTask.Wait();
            }
            else
            {
                UpdateDefinition <Signal> update = Builders <Signal> .Update.Inc(signal => signal.Strength, strength);

                Task updateTask = signalsCollection.UpdateOneAsync(filter, update);

                updateTask.Wait();
            }
        }
示例#5
0
 public Signal(Plugin plug, ushort join, string name, SignalTypeEnum signalType, SignalDirectionEnum signalDirection)
 {
     Plug            = plug;
     Join            = join;
     Name            = name;
     SignalType      = signalType;
     SignalDirection = signalDirection;
     Log             = new List <SignalLogItem>();
 }
示例#6
0
        public static void IncreaseSignal(MongoConnection connection, SignalTypeEnum signalType, double strength)
        {
            IMongoCollection <Signal> signalsCollection = connection.Database.GetCollection <Signal>(typeof(Signal).Name);

            FilterDefinition <Signal> filter = Builders <Signal> .Filter.Eq(signal => signal.SignalType, signalType);

            UpdateDefinition <Signal> update = Builders <Signal> .Update.Inc(signal => signal.Strength, strength);

            Task updateTask = signalsCollection.UpdateManyAsync(filter, update);

            updateTask.Wait();
        }
示例#7
0
        public static Signal ReadSignal(MongoConnection connection, string option, SignalTypeEnum signalType)
        {
            IMongoCollection <Signal>    collection = connection.Database.GetCollection <Signal>(typeof(Signal).Name);
            IFindFluent <Signal, Signal> signalFind = collection.Find(lSignal =>
                                                                      lSignal.Option == option &&
                                                                      lSignal.SignalType == signalType);

            Task <Signal> signals = signalFind.SingleOrDefaultAsync();

            Signal signal = signals.Result;

            if (signal == null)
            {
                signal = new Signal()
                {
                    Option     = option,
                    SignalType = SignalTypeEnum.Fail,
                    Strength   = 0d,
                };
            }

            return(signal);
        }
示例#8
0
        public static bool Raise(SignalTypeEnum signal)
        {
            var result = raiseSignal((int)signal);

            return(result == 0);
        }
示例#9
0
        public static bool Send(int processID, SignalTypeEnum signal)
        {
            var result = sendSignal(processID, (int)signal);

            return(result == 0);
        }
示例#10
0
        private static void RedoCacheSignalHandler(SignalTypeEnum signalType)
        {
            ToConsole("Received signal to redo cache!");

            BuildCache();
        }