public virtual void Update(IMessageNotifier notifier)
 {
     if (!string.IsNullOrEmpty(HistorySchemaName) && !string.IsNullOrEmpty(HistorySchemaReferenceColumnName) &&
         ListenerSchemaUId != Guid.Empty)
     {
         if (notifier == null)
         {
             string errorMessage = string.Format("Message notifier should be initialized.");
             throw new NullReferenceException(errorMessage);
         }
         _notifier = notifier;
         if (_notifier.MessageInfo.ListenersData.ContainsKey(ListenerSchemaUId))
         {
             if (_userConnection.GetIsFeatureEnabled("CanUpdateHistoryMessage"))
             {
                 ModifyMessage();
             }
             else
             {
                 if (InsertMessage())
                 {
                     NotifyClient();
                 }
             }
         }
     }
 }
Example #2
0
            public async Task GetTheSameMessageAsSendAsync()
            {
                HeartbeatMessage     receivedHeartbeat   = default(HeartbeatMessage);
                IMavlinkCommunicator mavlinkCommunicator = MavlinkCommunicatorFactory.Create(Stream);
                IMessageNotifier     messageNotifier     = mavlinkCommunicator.SubscribeForReceive(m => m.Id == MessageId.Heartbeat);

                messageNotifier.MessageReceived += (s, e) =>
                {
                    receivedHeartbeat = (HeartbeatMessage)e.Message;
                };

                HeartbeatMessage sentHeartbetat = new HeartbeatMessage
                {
                    Autopilot = MavAutopilot.Ardupilotmega,
                    BaseMode  =
                        MavModeFlag.CustomModeEnabled | MavModeFlag.StabilizeEnabled | MavModeFlag.ManualInputEnabled,
                    MavlinkVersion = 3,
                    Type           = MavType.Quadrotor,
                    SystemStatus   = MavState.Active,
                    CustomMode     = 0
                };
                await mavlinkCommunicator.SendMessageAsync(sentHeartbetat, 1, 1);

                Stream.Seek(0, SeekOrigin.Begin);

                Thread.Sleep(3000);
                Assert.AreEqual(sentHeartbetat.Autopilot, receivedHeartbeat.Autopilot);
                Assert.AreEqual(sentHeartbetat.Type, receivedHeartbeat.Type);
                Assert.AreEqual(sentHeartbetat.CustomMode, receivedHeartbeat.CustomMode);
                Assert.AreEqual(sentHeartbetat.BaseMode, receivedHeartbeat.BaseMode);
                Assert.AreEqual(sentHeartbetat.SystemStatus, receivedHeartbeat.SystemStatus);
                Assert.AreEqual(sentHeartbetat.MavlinkVersion, receivedHeartbeat.MavlinkVersion);
                mavlinkCommunicator.Dispose();
                Thread.Sleep(1000);
            }
Example #3
0
 public HttpRequestHandler(ISendMessages sender, IMessageNotifier notifier, string inputQueue, string queue, string connectionString)
 {
     this.inputQueue  = inputQueue;
     this.notifier    = notifier;
     messageSender    = sender;
     destinationQueue = queue;
     connString       = connectionString;
 }
Example #4
0
 public ConversationController(IConversationDTOManager conversationDTOManager,
                               IMessageNotifier messageNotifier,
                               IUserFinder userFinder)
 {
     conversationManager  = conversationDTOManager;
     this.messageNotifier = messageNotifier;
     this.userFinder      = userFinder;
 }
 public HttpRequestHandler(ISendMessages sender, IMessageNotifier notifier, string inputQueue, string queue, string connectionString)
 {
     this.inputQueue = inputQueue;
     this.notifier = notifier;
     messageSender = sender;
     destinationQueue = queue;
     connString = connectionString;
 }
Example #6
0
        public MessageConfig(IMessageNotifier messageNotifier)
        {
            InitializeComponent();
            _messageNotifier = messageNotifier;
            ContentTextBox.Text = messageNotifier.Content;
            TitleTextBox.Text = messageNotifier.Title;

            _initComplete = true;
        }
Example #7
0
        public MessageConfig(IMessageNotifier messageNotifier)
        {
            InitializeComponent();
            this.messageNotifier = messageNotifier;
            ContentTextBox.Text  = messageNotifier.Content;
            TitleTextBox.Text    = messageNotifier.Title;

            initComplete = true;
        }
Example #8
0
 public ChatHub(IMessageService messageService,
                IMessageNotifier messageNotifier,
                IMapper mapper,
                IRealtimeHubProvider hubProvider)
 {
     MessageService  = messageService;
     MessageNotifier = messageNotifier;
     Mapper          = mapper;
     HubProvider     = hubProvider;
 }
 public TransactionalChannelDispatcher(IChannelFactory channelFactory,
                                         IMessageNotifier notifier,
                                         ISendMessages messageSender,
                                         IRouteMessages routeMessages)
 {
     this.routeMessages = routeMessages;
     this.channelFactory = channelFactory;
     this.notifier = notifier;
     this.messageSender = messageSender;
 }
 public TransactionalChannelDispatcher(IChannelFactory channelFactory,
                                       IMessageNotifier notifier,
                                       ISendMessages messageSender,
                                       IRouteMessages routeMessages)
 {
     this.routeMessages  = routeMessages;
     this.channelFactory = channelFactory;
     this.notifier       = notifier;
     this.messageSender  = messageSender;
 }
Example #11
0
 public GatewaySender(   IBuilder builder,
                                          IMangageReceiveChannels channelManager,
                                          IMessageNotifier notifier,
                                          ISendMessages messageSender,
                                          IMainEndpointSettings settings)
 {
     this.settings = settings;
     this.builder = builder;
     this.channelManager = channelManager;
     this.notifier = notifier;
     this.messageSender = messageSender;
 }
Example #12
0
 public GatewaySender(IBuilder builder,
                      IMangageReceiveChannels channelManager,
                      IMessageNotifier notifier,
                      ISendMessages messageSender,
                      IMainEndpointSettings settings)
 {
     this.settings       = settings;
     this.builder        = builder;
     this.channelManager = channelManager;
     this.notifier       = notifier;
     this.messageSender  = messageSender;
 }
Example #13
0
        public void Init()
        {
            NServiceBus.Configure.With().Log4Net().DefaultBuilder().UnicastBus();

            string errorQueue = ConfigurationManager.AppSettings["ErrorQueue"];
            string audit = ConfigurationManager.AppSettings["ForwardReceivedMessageTo"];
            string listenUrl = ConfigurationManager.AppSettings["ListenUrl"];
            string n = ConfigurationManager.AppSettings["NumberOfWorkerThreads"];
            string remoteUrl = ConfigurationManager.AppSettings["RemoteUrl"];

            connectionString = ConfigurationManager.AppSettings["ConnectionString"];
            inputQueue = ConfigurationManager.AppSettings["InputQueue"];
            outputQueue = ConfigurationManager.AppSettings["OutputQueue"];

            int numberOfWorkerThreads = 10;
            int.TryParse(n, out numberOfWorkerThreads);

            ThreadPool.SetMaxThreads(numberOfWorkerThreads, numberOfWorkerThreads);

            messageSender = new MsmqMessageSender {UseDeadLetterQueue = true, UseJournalQueue = true};

            transport = new TransactionalTransport
            {
                MessageReceiver = new MsmqMessageReceiver(),
                IsTransactional = true,
                NumberOfWorkerThreads = numberOfWorkerThreads
            };

            notifier = new MessageNotifier();

            NServiceBus.Configure.Instance.Configurer.RegisterSingleton<ISendMessages>(messageSender);
            NServiceBus.Configure.Instance.Configurer.RegisterSingleton<ITransport>(transport);
            NServiceBus.Configure.Instance.Configurer.RegisterSingleton<INotifyAboutMessages>(notifier);

            transport.TransportMessageReceived += (s, e) =>
            {
                new MsmqHandler(notifier, listenUrl).Handle(e.Message, remoteUrl);

                if (!string.IsNullOrEmpty(audit))
                    messageSender.Send(e.Message, audit);
            };

            listener = new HttpListener();
            listener.Prefixes.Add(listenUrl);
        }
Example #14
0
        private static void Main(string[] args)
        {
            var serialPort = new SerialPort("COM7", 115200);

            serialPort.Open();

            MavlinkCommunicatorFactory mavlinkCommunicatorFactory = new MavlinkCommunicatorFactory();
            IMavlinkCommunicator       mavlinkCommunicator        = mavlinkCommunicatorFactory.Create(serialPort.BaseStream);
            IMessageNotifier           heartbeatNotifier          =
                mavlinkCommunicator.SubscribeForReceive(m => m.Id == MessageId.Heartbeat);

            //            IMessageNotifier systemTimeNotifier =
            //               mavlinkCommunicator.SubscribeForReceive(m => m.Id == MessageId.SystemTime);
            //
            //            IMessageNotifier sysStatusNotifier =
            //               mavlinkCommunicator.SubscribeForReceive(m => m.Id == MessageId.SysStatus);

            heartbeatNotifier.MessageReceived += (sender, eventArgs) =>
            {
                HeartbeatMessage heartbeatMessage = (HeartbeatMessage)eventArgs.Message;
                Console.WriteLine($"Autopilot type: {heartbeatMessage.Autopilot}");
                Console.WriteLine($"Vehicle type: {heartbeatMessage.Type}");
                Console.WriteLine($"Base mode type: {heartbeatMessage.BaseMode}");
            };

            //            systemTimeNotifier.MessageReceived += (sender, eventArgs) =>
            //            {
            //                SystemTimeMessage heartbeatMessage = (SystemTimeMessage)eventArgs.Message;
            //                Console.WriteLine($"TimeBootMs: {heartbeatMessage.TimeBootMs}");
            //                Console.WriteLine($"Time Unix uSec: {heartbeatMessage.TimeUnixUsec}");
            //            };
            //
            //            sysStatusNotifier.MessageReceived += (sender, eventArgs) =>
            //            {
            //                SysStatusMessage heartbeatMessage = (SysStatusMessage)eventArgs.Message;
            //                Console.WriteLine($"Sensors enabled: {heartbeatMessage.SensorsEnabled}");
            //            };

            while (true)
            {
                ;
            }
        }
Example #15
0
            public async Task GetTheSameMessageCountAsSendAsync()
            {
                int messagesToSend                       = 20;
                int messagesReceived                     = 0;
                int messagesSuccessfullySent             = 0;
                IMavlinkCommunicator mavlinkCommunicator = MavlinkCommunicatorFactory.Create(Stream);
                IMessageNotifier     messageNotifier     = mavlinkCommunicator.SubscribeForReceive(m => m.Id == MessageId.Heartbeat);

                messageNotifier.MessageReceived += (s, e) =>
                {
                    Interlocked.Increment(ref messagesReceived);
                };

                HeartbeatMessage sentHeartbeat = new HeartbeatMessage
                {
                    Autopilot = MavAutopilot.Ardupilotmega,
                    BaseMode  =
                        MavModeFlag.CustomModeEnabled | MavModeFlag.StabilizeEnabled | MavModeFlag.ManualInputEnabled,
                    MavlinkVersion = 3,
                    Type           = MavType.Quadrotor,
                    SystemStatus   = MavState.Active,
                    CustomMode     = 0
                };

                for (int i = 0; i < messagesToSend; i++)
                {
                    bool result = await mavlinkCommunicator.SendMessageAsync(sentHeartbeat, 1, 1);

                    if (result)
                    {
                        messagesSuccessfullySent++;
                    }
                }

                Stream.Seek(0, SeekOrigin.Begin);

                Thread.Sleep(8000);
                Assert.AreEqual(messagesSuccessfullySent, messagesReceived, 0,
                                $"Successfully sent {messagesSuccessfullySent}. Successfully received {messagesReceived}");
                mavlinkCommunicator.Dispose();
                Thread.Sleep(1000);
            }
Example #16
0
 public MsmqHandler(IMessageNotifier notifier, string listenUrl)
 {
     this.notifier = notifier;
     from = listenUrl;
 }
Example #17
0
 public MsmqHandler(IMessageNotifier notifier, string listenUrl)
 {
     this.notifier = notifier;
     from          = listenUrl;
 }
Example #18
0
 public NotifyMessageHandler(IMessageNotifier notifier)
 {
     this.notifier = notifier;
 }
Example #19
0
            public static void QueryDevices(IMessageNotifier messageNotifier)
            {
                MessageNotifier = messageNotifier;
                // #0 get video controllers, used for cross checking
                WindowsDisplayAdapters.QueryVideoControllers();
                // Order important CPU Query must be first
                // #1 CPU
                Cpu.QueryCpus();
                // #2 CUDA
                if (Nvidia.IsSkipNvidia())
                {
                    Helpers.ConsolePrint(Tag, "Skipping NVIDIA device detection, settings are set to disabled");
                }
                else
                {
                    ShowMessageAndStep(Tr("Querying CUDA devices"));
                    Nvidia.QueryCudaDevices();
                }
                // OpenCL and AMD
                if (ConfigManager.GeneralConfig.DeviceDetection.DisableDetectionAMD)
                {
                    Helpers.ConsolePrint(Tag, "Skipping AMD device detection, settings set to disabled");
                    ShowMessageAndStep(Tr("Skip check for AMD OpenCL GPUs"));
                }
                else
                {
                    // #3 OpenCL
                    ShowMessageAndStep(Tr("Querying OpenCL devices"));
                    OpenCL.QueryOpenCLDevices();
                    // #4 AMD query AMD from OpenCL devices, get serial and add devices
                    ShowMessageAndStep(Tr("Checking AMD OpenCL GPUs"));
                    var amd = new AmdQuery(AvaliableVideoControllers);
                    AmdDevices = amd.QueryAmd(_isOpenCLQuerySuccess, _openCLJsonData);
                }
                // #5 uncheck CPU if GPUs present, call it after we Query all devices
                Group.UncheckedCpu();

                // TODO update this to report undetected hardware
                // #6 check NVIDIA, AMD devices count
                var nvidiaCount = 0;

                {
                    var amdCount = 0;
                    foreach (var vidCtrl in AvaliableVideoControllers)
                    {
                        if (vidCtrl.Name.ToLower().Contains("nvidia") && CudaUnsupported.IsSupported(vidCtrl.Name))
                        {
                            nvidiaCount += 1;
                        }
                        else if (vidCtrl.Name.ToLower().Contains("nvidia"))
                        {
                            Helpers.ConsolePrint(Tag,
                                                 "Device not supported NVIDIA/CUDA device not supported " + vidCtrl.Name);
                        }
                        amdCount += (vidCtrl.Name.ToLower().Contains("amd")) ? 1 : 0;
                    }
                    Helpers.ConsolePrint(Tag,
                                         nvidiaCount == _cudaDevices.Count
                            ? "Cuda NVIDIA/CUDA device count GOOD"
                            : "Cuda NVIDIA/CUDA device count BAD!!!");
                    Helpers.ConsolePrint(Tag,
                                         amdCount == AmdDevices.Count ? "AMD GPU device count GOOD" : "AMD GPU device count BAD!!!");
                }
                // allerts
                _currentNvidiaSmiDriver = GetNvidiaSmiDriver();
                // if we have nvidia cards but no CUDA devices tell the user to upgrade driver
                var isNvidiaErrorShown = false; // to prevent showing twice
                var showWarning        = ConfigManager.GeneralConfig.ShowDriverVersionWarning &&
                                         WindowsDisplayAdapters.HasNvidiaVideoController();

                if (showWarning && _cudaDevices.Count != nvidiaCount &&
                    _currentNvidiaSmiDriver.IsLesserVersionThan(NvidiaMinDetectionDriver))
                {
                    isNvidiaErrorShown = true;
                    var minDriver      = NvidiaMinDetectionDriver.ToString();
                    var recomendDriver = NvidiaRecomendedDriver.ToString();
                    MessageBox.Show(string.Format(
                                        Tr("We have detected that your system has Nvidia GPUs, but your driver is older than {0}. In order for NiceHash Miner Legacy to work correctly you should upgrade your drivers to recommended {1} or newer. If you still see this warning after updating the driver please uninstall all your Nvidia drivers and make a clean install of the latest official driver from http://www.nvidia.com."),
                                        minDriver, recomendDriver),
                                    Tr("Nvidia Recomended driver"),
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                // recomended driver
                if (showWarning && _currentNvidiaSmiDriver.IsLesserVersionThan(NvidiaRecomendedDriver) &&
                    !isNvidiaErrorShown && _currentNvidiaSmiDriver.LeftPart > -1)
                {
                    var recomendDrvier = NvidiaRecomendedDriver.ToString();
                    var nvdriverString = _currentNvidiaSmiDriver.LeftPart > -1
                        ? string.Format(
                        Tr(" (current {0})"),
                        _currentNvidiaSmiDriver)
                        : "";
                    MessageBox.Show(string.Format(
                                        Tr("We have detected that your Nvidia Driver is older than {0}{1}. We recommend you to update to {2} or newer."),
                                        recomendDrvier, nvdriverString, recomendDrvier),
                                    Tr("Nvidia Recomended driver"),
                                    MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }

                // no devices found
                if (Available.Devices.Count <= 0)
                {
                    var result = MessageBox.Show(Tr("No supported devices are found. Select the OK button for help or cancel to continue."),
                                                 Tr("No Supported Devices"),
                                                 MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
                    if (result == DialogResult.OK)
                    {
                        Process.Start(Links.NhmNoDevHelp);
                    }
                }

                // create AMD bus ordering for Claymore
                var amdDevices = Available.Devices.FindAll((a) => a.DeviceType == DeviceType.AMD);

                amdDevices.Sort((a, b) => a.BusID.CompareTo(b.BusID));
                for (var i = 0; i < amdDevices.Count; i++)
                {
                    amdDevices[i].IDByBus = i;
                }
                //create NV bus ordering for Claymore
                var nvDevices = Available.Devices.FindAll((a) => a.DeviceType == DeviceType.NVIDIA);

                nvDevices.Sort((a, b) => a.BusID.CompareTo(b.BusID));
                for (var i = 0; i < nvDevices.Count; i++)
                {
                    nvDevices[i].IDByBus = i;
                }

                // get GPUs RAM sum
                // bytes
                Available.NvidiaRamSum = 0;
                Available.AmdRamSum    = 0;
                foreach (var dev in Available.Devices)
                {
                    if (dev.DeviceType == DeviceType.NVIDIA)
                    {
                        Available.NvidiaRamSum += dev.GpuRam;
                    }
                    else if (dev.DeviceType == DeviceType.AMD)
                    {
                        Available.AmdRamSum += dev.GpuRam;
                    }
                }
                // Make gpu ram needed not larger than 4GB per GPU
                var totalGpuRam = Math.Min((Available.NvidiaRamSum + Available.AmdRamSum) * 0.6 / 1024,
                                           (double)Available.AvailGpUs * 4 * 1024 * 1024);
                double totalSysRam = SystemSpecs.FreePhysicalMemory + SystemSpecs.FreeVirtualMemory;

                // check
                if (ConfigManager.GeneralConfig.ShowDriverVersionWarning && totalSysRam < totalGpuRam)
                {
                    Helpers.ConsolePrint(Tag, "virtual memory size BAD");
                    MessageBox.Show(Tr("NiceHash Miner Legacy recommends increasing virtual memory size so that all algorithms would work fine."),
                                    Tr("Warning!"),
                                    MessageBoxButtons.OK);
                }
                else
                {
                    Helpers.ConsolePrint(Tag, "virtual memory size GOOD");
                }

                // #x remove reference
                MessageNotifier = null;
            }
Example #20
0
        public void QueryDevices(IMessageNotifier messageNotifier)
        {
            MessageNotifier = messageNotifier;
            // #0 get video controllers, used for cross checking
            QueryVideoControllers();
            // Order important CPU Query must be first
            // #1 CPU
            QueryCPUs();
            // #2 CUDA
            showMessageAndStep(International.GetText("Compute_Device_Query_Manager_CUDA_Query"));
            QueryCudaDevices();
            // #3 OpenCL
            showMessageAndStep(International.GetText("Compute_Device_Query_Manager_OpenCL_Query"));
            QueryOpenCLDevices();
            // #4 AMD query AMD from OpenCL devices, get serial and add devices
            QueryAMD();
            // #5 uncheck CPU if GPUs present, call it after we Query all devices
            UncheckedCPU();
            // add numberings to same devices
            if (ComputeDevice.AllAvaliableDevices.Count != ComputeDevice.UniqueAvaliableDevices.Count)
            {
                // name count
                Dictionary <string, int> namesCount = new Dictionary <string, int>();
                // init keys and counters
                foreach (var uniqueCdev in ComputeDevice.UniqueAvaliableDevices)
                {
                    namesCount.Add(uniqueCdev.Name, 0);
                }
                // count
                foreach (var cDev in ComputeDevice.AllAvaliableDevices)
                {
                    namesCount[cDev.Name]++;
                }
                foreach (var nameCount in namesCount)
                {
                    string name        = nameCount.Key;
                    int    deviceCount = nameCount.Value;
                    if (deviceCount > 1)
                    {
                        int numID = 1;
                        foreach (var cDev in ComputeDevice.AllAvaliableDevices)
                        {
                            if (cDev.Name == name)
                            {
                                cDev.Name = cDev.Name + " #" + numID.ToString();
                                ++numID;
                            }
                        }
                    }
                }
            }


            // TODO update this to report undetected hardware
            // #6 check NVIDIA, AMD devices count
            {
                int NVIDIA_count = 0;
                int AMD_count    = 0;
                foreach (var vidCtrl in AvaliableVideoControllers)
                {
                    NVIDIA_count += (vidCtrl.Name.ToLower().Contains("nvidia")) ? 1 : 0;
                    AMD_count    += (vidCtrl.Name.ToLower().Contains("amd")) ? 1 : 0;
                }
                if (NVIDIA_count == CudaDevices.Count)
                {
                    Helpers.ConsolePrint(TAG, "Cuda NVIDIA/CUDA device count GOOD");
                }
                else
                {
                    Helpers.ConsolePrint(TAG, "Cuda NVIDIA/CUDA device count BAD!!!");
                }
                if (AMD_count == amdGpus.Count)
                {
                    Helpers.ConsolePrint(TAG, "AMD GPU device count GOOD");
                }
                else
                {
                    Helpers.ConsolePrint(TAG, "AMD GPU device count BAD!!!");
                }
            }
            // allerts
            _currentNvidiaOpenCLDriver = GetNvidiaOpenCLDriver();
            // if we have nvidia cards but no CUDA devices tell the user to upgrade driver
            bool isNvidiaErrorShown = false; // to prevent showing twice

            if (ConfigManager.Instance.GeneralConfig.ShowDriverVersionWarning && HasNvidiaVideoController() && CudaDevices.Count == 0)
            {
                isNvidiaErrorShown = true;
                var minDriver      = NVIDIA_MIN_DETECTION_DRIVER.ToString();
                var recomendDrvier = NVIDIA_RECOMENDED_DRIVER.ToString();
                MessageBox.Show(String.Format(International.GetText("Compute_Device_Query_Manager_NVIDIA_Driver_Detection"),
                                              minDriver, recomendDrvier),
                                International.GetText("Compute_Device_Query_Manager_NVIDIA_RecomendedDriver_Title"),
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            // recomended driver
            if (ConfigManager.Instance.GeneralConfig.ShowDriverVersionWarning && HasNvidiaVideoController() && _currentNvidiaOpenCLDriver < NVIDIA_RECOMENDED_DRIVER && !isNvidiaErrorShown && _currentNvidiaOpenCLDriver > -1)
            {
                var recomendDrvier = NVIDIA_RECOMENDED_DRIVER.ToString();
                var nvdriverString = _currentNvidiaOpenCLDriver > -1 ? String.Format(International.GetText("Compute_Device_Query_Manager_NVIDIA_Driver_Recomended_PART"), _currentNvidiaOpenCLDriver.ToString())
                : "";
                MessageBox.Show(String.Format(International.GetText("Compute_Device_Query_Manager_NVIDIA_Driver_Recomended"),
                                              recomendDrvier, nvdriverString, recomendDrvier),
                                International.GetText("Compute_Device_Query_Manager_NVIDIA_RecomendedDriver_Title"),
                                MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }

            // #x remove reference
            MessageNotifier = null;
        }
 public MsmqChannelDispatcher(IChannelSender channelSender, IMessageNotifier notifier)
 {
     this.channelSender = channelSender;
     this.notifier = notifier;
 }
Example #22
0
 public FacebookDecorator(IMessageNotifier messageNotifier) : base(messageNotifier)
 {
     plateform = "Facebook";
 }
Example #23
0
 public SendMessage(
     IMessageNotifier messageNotifier)
 {
     this.messageNotifier = messageNotifier;
 }
Example #24
0
 public MessageDecorator(IMessageNotifier messageNotifier)
 {
     this.messageNotifier = messageNotifier;
 }
Example #25
0
 public SlackDecorator(IMessageNotifier messageNotifier) : base(messageNotifier)
 {
     plateform = "Slack";
 }
 public MsmqInputDispatcher(IChannel channel, IMessageNotifier notifier)
 {
     this.channel = channel;
     this.notifier = notifier;
 }
Example #27
0
 public SmsDecorator(IMessageNotifier messageNotifier) : base(messageNotifier)
 {
     plateform = "SMS";
 }
Example #28
0
 public MsmqChannelDispatcher(IChannelSender channelSender, IMessageNotifier notifier)
 {
     this.channelSender = channelSender;
     this.notifier      = notifier;
 }
            public static void QueryDevices(IMessageNotifier messageNotifier)
            {
                MessageNotifier = messageNotifier;
                // #0 get video controllers, used for cross checking
                WindowsDisplayAdapters.QueryVideoControllers();
                // Order important CPU Query must be first
                // #1 CPU
                CPU.QueryCPUs();
                // #2 CUDA
                if (NVIDIA.IsSkipNVIDIA()) {
                    Helpers.ConsolePrint(TAG, "Skipping NVIDIA device detection, settings are set to disabled");
                } else {
                    showMessageAndStep(International.GetText("Compute_Device_Query_Manager_CUDA_Query"));
                    NVIDIA.QueryCudaDevices();
                }
                // OpenCL and AMD
                if (ConfigManager.GeneralConfig.DeviceDetection.DisableDetectionAMD) {
                    Helpers.ConsolePrint(TAG, "Skipping AMD device detection, settings set to disabled");
                    showMessageAndStep(International.GetText("Compute_Device_Query_Manager_AMD_Query_Skip"));
                } else {
                    // #3 OpenCL
                    showMessageAndStep(International.GetText("Compute_Device_Query_Manager_OpenCL_Query"));
                    OpenCL.QueryOpenCLDevices();
                    // #4 AMD query AMD from OpenCL devices, get serial and add devices
                    AMD.QueryAMD();
                }
                // #5 uncheck CPU if GPUs present, call it after we Query all devices
                Group.UncheckedCPU();

                // TODO update this to report undetected hardware
                // #6 check NVIDIA, AMD devices count
                int NVIDIA_count = 0;
                {
                    int AMD_count = 0;
                    foreach (var vidCtrl in AvaliableVideoControllers) {
                        if(vidCtrl.Name.ToLower().Contains("nvidia") && CUDA_Unsupported.IsSupported(vidCtrl.Name)) {
                            NVIDIA_count += 1;
                        } else if (vidCtrl.Name.ToLower().Contains("nvidia")) {
                            Helpers.ConsolePrint(TAG, "Device not supported NVIDIA/CUDA device not supported " + vidCtrl.Name);
                        }
                        AMD_count += (vidCtrl.Name.ToLower().Contains("amd")) ? 1 : 0;
                    }
                    if (NVIDIA_count == CudaDevices.Count) {
                        Helpers.ConsolePrint(TAG, "Cuda NVIDIA/CUDA device count GOOD");
                    } else {
                        Helpers.ConsolePrint(TAG, "Cuda NVIDIA/CUDA device count BAD!!!");
                    }
                    if (AMD_count == amdGpus.Count) {
                        Helpers.ConsolePrint(TAG, "AMD GPU device count GOOD");
                    } else {
                        Helpers.ConsolePrint(TAG, "AMD GPU device count BAD!!!");
                    }
                }
                // allerts
                _currentNvidiaSMIDriver = GetNvidiaSMIDriver();
                // if we have nvidia cards but no CUDA devices tell the user to upgrade driver
                bool isNvidiaErrorShown = false; // to prevent showing twice
                bool showWarning = ConfigManager.GeneralConfig.ShowDriverVersionWarning && WindowsDisplayAdapters.HasNvidiaVideoController();
                if (showWarning && CudaDevices.Count != NVIDIA_count && _currentNvidiaSMIDriver.IsLesserVersionThan(NVIDIA_MIN_DETECTION_DRIVER)) {
                    isNvidiaErrorShown = true;
                    var minDriver = NVIDIA_MIN_DETECTION_DRIVER.ToString();
                    var recomendDrvier = NVIDIA_RECOMENDED_DRIVER.ToString();
                    MessageBox.Show(String.Format(International.GetText("Compute_Device_Query_Manager_NVIDIA_Driver_Detection"),
                        minDriver, recomendDrvier),
                                                          International.GetText("Compute_Device_Query_Manager_NVIDIA_RecomendedDriver_Title"),
                                                          MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                // recomended driver
                if (showWarning && _currentNvidiaSMIDriver.IsLesserVersionThan(NVIDIA_RECOMENDED_DRIVER) && !isNvidiaErrorShown && _currentNvidiaSMIDriver.leftPart > -1) {
                    var recomendDrvier = NVIDIA_RECOMENDED_DRIVER.ToString();
                    var nvdriverString = _currentNvidiaSMIDriver.leftPart > -1 ? String.Format(International.GetText("Compute_Device_Query_Manager_NVIDIA_Driver_Recomended_PART"), _currentNvidiaSMIDriver.ToString())
                    : "";
                    MessageBox.Show(String.Format(International.GetText("Compute_Device_Query_Manager_NVIDIA_Driver_Recomended"),
                        recomendDrvier, nvdriverString, recomendDrvier),
                                                          International.GetText("Compute_Device_Query_Manager_NVIDIA_RecomendedDriver_Title"),
                                                          MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }

                // #x remove reference
                MessageNotifier = null;
            }
Example #30
0
            public static void QueryDevices(IMessageNotifier messageNotifier)
            {
                // check NVIDIA nvml.dll and copy over scope
                {
                    var nvmlPath = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) +
                                   "\\NVIDIA Corporation\\NVSMI\\nvml.dll";
                    if (nvmlPath.Contains(" (x86)"))
                    {
                        nvmlPath = nvmlPath.Replace(" (x86)", "");
                    }
                    if (File.Exists(nvmlPath))
                    {
                        var copyToPath = Directory.GetCurrentDirectory() + "\\nvml.dll";
                        try
                        {
                            File.Copy(nvmlPath, copyToPath, true);
                            Helpers.ConsolePrint(Tag, $"Copy from {nvmlPath} to {copyToPath} done");
                        }
                        catch (Exception e)
                        {
                            Helpers.ConsolePrint(Tag, "Copy nvml.dll failed: " + e.Message);
                        }
                    }
                }


                MessageNotifier = messageNotifier;
                // #0 get video controllers, used for cross checking
                WindowsDisplayAdapters.QueryVideoControllers();
                // Order important CPU Query must be first
                // #1 CPU
                Cpu.QueryCpus();
                // #2 CUDA
                if (Nvidia.IsSkipNvidia())
                {
                    Helpers.ConsolePrint(Tag, "Skipping NVIDIA device detection, settings are set to disabled");
                }
                else
                {
                    ShowMessageAndStep(International.GetText("Compute_Device_Query_Manager_CUDA_Query"));
                    Nvidia.QueryCudaDevices();
                }
                // OpenCL and AMD
                if (ConfigManager.GeneralConfig.DeviceDetection.DisableDetectionAMD)
                {
                    Helpers.ConsolePrint(Tag, "Skipping AMD device detection, settings set to disabled");
                    ShowMessageAndStep(International.GetText("Compute_Device_Query_Manager_AMD_Query_Skip"));
                }
                else
                {
                    // #3 OpenCL
                    ShowMessageAndStep(International.GetText("Compute_Device_Query_Manager_OpenCL_Query"));
                    OpenCL.QueryOpenCLDevices();
                    // #4 AMD query AMD from OpenCL devices, get serial and add devices
                    ShowMessageAndStep(International.GetText("Compute_Device_Query_Manager_AMD_Query"));
                    var amd = new AmdQuery(AvaliableVideoControllers);
                    AmdDevices = amd.QueryAmd(_isOpenCLQuerySuccess, _openCLJsonData);
                }
                // #5 uncheck CPU if GPUs present, call it after we Query all devices
                Group.UncheckedCpu();

                // TODO update this to report undetected hardware
                // #6 check NVIDIA, AMD devices count
                var nvidiaCount = 0;

                {
                    var amdCount = 0;
                    foreach (var vidCtrl in AvaliableVideoControllers)
                    {
                        if (vidCtrl.Name.ToLower().Contains("nvidia") && CudaUnsupported.IsSupported(vidCtrl.Name))
                        {
                            nvidiaCount += 1;
                        }
                        else if (vidCtrl.Name.ToLower().Contains("nvidia"))
                        {
                            Helpers.ConsolePrint(Tag,
                                                 "Device not supported NVIDIA/CUDA device not supported " + vidCtrl.Name);
                        }
                        amdCount += (vidCtrl.Name.ToLower().Contains("amd")) ? 1 : 0;
                    }
                    Helpers.ConsolePrint(Tag,
                                         nvidiaCount == _cudaDevices.Count
                            ? "Cuda NVIDIA/CUDA device count GOOD"
                            : "Cuda NVIDIA/CUDA device count BAD!!!");
                    Helpers.ConsolePrint(Tag,
                                         amdCount == AmdDevices.Count ? "AMD GPU device count GOOD" : "AMD GPU device count BAD!!!");
                }
                // allerts
                _currentNvidiaSmiDriver = GetNvidiaSmiDriver();
                // if we have nvidia cards but no CUDA devices tell the user to upgrade driver
                var isNvidiaErrorShown = false; // to prevent showing twice
                var showWarning        = ConfigManager.GeneralConfig.ShowDriverVersionWarning &&
                                         WindowsDisplayAdapters.HasNvidiaVideoController();

                if (showWarning && _cudaDevices.Count != nvidiaCount &&
                    _currentNvidiaSmiDriver.IsLesserVersionThan(NvidiaMinDetectionDriver))
                {
                    isNvidiaErrorShown = true;
                    var minDriver      = NvidiaMinDetectionDriver.ToString();
                    var recomendDrvier = NvidiaRecomendedDriver.ToString();
                    MessageBox.Show(string.Format(
                                        International.GetText("Compute_Device_Query_Manager_NVIDIA_Driver_Detection"),
                                        minDriver, recomendDrvier),
                                    International.GetText("Compute_Device_Query_Manager_NVIDIA_RecomendedDriver_Title"),
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                // recomended driver
                if (showWarning && _currentNvidiaSmiDriver.IsLesserVersionThan(NvidiaRecomendedDriver) &&
                    !isNvidiaErrorShown && _currentNvidiaSmiDriver.LeftPart > -1)
                {
                    var recomendDrvier = NvidiaRecomendedDriver.ToString();
                    var nvdriverString = _currentNvidiaSmiDriver.LeftPart > -1
                        ? string.Format(
                        International.GetText("Compute_Device_Query_Manager_NVIDIA_Driver_Recomended_PART"),
                        _currentNvidiaSmiDriver)
                        : "";
                    MessageBox.Show(string.Format(
                                        International.GetText("Compute_Device_Query_Manager_NVIDIA_Driver_Recomended"),
                                        recomendDrvier, nvdriverString, recomendDrvier),
                                    International.GetText("Compute_Device_Query_Manager_NVIDIA_RecomendedDriver_Title"),
                                    MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }

                // no devices found
                if (Available.Devices.Count <= 0)
                {
                    var result = MessageBox.Show(International.GetText("Compute_Device_Query_Manager_No_Devices"),
                                                 International.GetText("Compute_Device_Query_Manager_No_Devices_Title"),
                                                 MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
                    if (result == DialogResult.OK)
                    {
                        Process.Start(Links.NhmNoDevHelp);
                    }
                }

                // create AMD bus ordering for Claymore
                var amdDevices = Available.Devices.FindAll((a) => a.DeviceType == DeviceType.AMD);

                amdDevices.Sort((a, b) => a.BusID.CompareTo(b.BusID));
                for (var i = 0; i < amdDevices.Count; i++)
                {
                    amdDevices[i].IDByBus = i;
                }
                //create NV bus ordering for Claymore
                var nvDevices = Available.Devices.FindAll((a) => a.DeviceType == DeviceType.NVIDIA);

                nvDevices.Sort((a, b) => a.BusID.CompareTo(b.BusID));
                for (var i = 0; i < nvDevices.Count; i++)
                {
                    nvDevices[i].IDByBus = i;
                }

                // get GPUs RAM sum
                // bytes
                Available.NvidiaRamSum = 0;
                Available.AmdRamSum    = 0;
                foreach (var dev in Available.Devices)
                {
                    if (dev.DeviceType == DeviceType.NVIDIA)
                    {
                        Available.NvidiaRamSum += dev.GpuRam;
                    }
                    else if (dev.DeviceType == DeviceType.AMD)
                    {
                        Available.AmdRamSum += dev.GpuRam;
                    }
                }
                // Make gpu ram needed not larger than 4GB per GPU
                var totalGpuRam = Math.Min((Available.NvidiaRamSum + Available.AmdRamSum) * 0.6 / 1024,
                                           (double)Available.AvailGpUs * 4 * 1024 * 1024);
                double totalSysRam = SystemSpecs.FreePhysicalMemory + SystemSpecs.FreeVirtualMemory;

                // check
                if (ConfigManager.GeneralConfig.ShowDriverVersionWarning && totalSysRam < totalGpuRam)
                {
                    Helpers.ConsolePrint(Tag, "virtual memory size BAD");
                    MessageBox.Show(International.GetText("VirtualMemorySize_BAD"),
                                    International.GetText("Warning_with_Exclamation"),
                                    MessageBoxButtons.OK);
                }
                else
                {
                    Helpers.ConsolePrint(Tag, "virtual memory size GOOD");
                }

                // #x remove reference
                MessageNotifier = null;
            }
Example #31
0
 public MessageHistoryManager(UserConnection userConnection, IMessageNotifier notifier)
 {
     _userConnection = userConnection;
     _notifier       = notifier;
     _listeners      = GetListeners();
 }
        public void QueryDevices(IMessageNotifier messageNotifier)
        {
            MessageNotifier = messageNotifier;
            // #0 get video controllers, used for cross checking
            QueryVideoControllers();
            // Order important CPU Query must be first
            // #1 CPU
            QueryCPUs();
            // #2 CUDA
            showMessageAndStep(International.GetText("Compute_Device_Query_Manager_CUDA_Query"));
            QueryCudaDevices();
            // #3 OpenCL
            showMessageAndStep(International.GetText("Compute_Device_Query_Manager_OpenCL_Query"));
            QueryOpenCLDevices();
            // #4 AMD query AMD from OpenCL devices, get serial and add devices
            QueryAMD();
            // #5 uncheck CPU if GPUs present, call it after we Query all devices
            UncheckedCPU();
            // add numberings to same devices
            if (ComputeDevice.AllAvaliableDevices.Count != ComputeDevice.UniqueAvaliableDevices.Count)
            {
                // name count
                Dictionary <string, int> namesCount = new Dictionary <string, int>();
                // init keys and counters
                foreach (var uniqueCdev in ComputeDevice.UniqueAvaliableDevices)
                {
                    namesCount.Add(uniqueCdev.Name, 0);
                }
                // count
                foreach (var cDev in ComputeDevice.AllAvaliableDevices)
                {
                    namesCount[cDev.Name]++;
                }
                foreach (var nameCount in namesCount)
                {
                    string name        = nameCount.Key;
                    int    deviceCount = nameCount.Value;
                    if (deviceCount > 1)
                    {
                        int numID = 1;
                        foreach (var cDev in ComputeDevice.AllAvaliableDevices)
                        {
                            if (cDev.Name == name)
                            {
                                cDev.Name = cDev.Name + " #" + numID.ToString();
                                ++numID;
                            }
                        }
                    }
                }
            }


            // TODO update this to report undetected hardware
            // #6 check NVIDIA, AMD devices count
            {
                int NVIDIA_count = 0;
                int AMD_count    = 0;
                foreach (var vidCtrl in AvaliableVideoControllers)
                {
                    NVIDIA_count += (vidCtrl.Name.ToLower().Contains("nvidia")) ? 1 : 0;
                    AMD_count    += (vidCtrl.Name.ToLower().Contains("amd")) ? 1 : 0;
                }
                if (NVIDIA_count == CudaDevices.Count)
                {
                    Helpers.ConsolePrint(TAG, "Cuda NVIDIA/CUDA device count GOOD");
                }
                else
                {
                    Helpers.ConsolePrint(TAG, "Cuda NVIDIA/CUDA device count BAD!!!");
                }
                if (AMD_count == amdGpus.Count)
                {
                    Helpers.ConsolePrint(TAG, "AMD GPU device count GOOD");
                }
                else
                {
                    Helpers.ConsolePrint(TAG, "AMD GPU device count BAD!!!");
                }
            }
            // #7 init ethminer ID mappings offset
            if (OpenCLJSONData != null)
            {
                // helper vars
                Dictionary <ComputePlatformType, int> openCLGpuCount    = new Dictionary <ComputePlatformType, int>();
                Dictionary <ComputePlatformType, int> openCLPlatformIds = new Dictionary <ComputePlatformType, int>();
                foreach (var oclPlatform in OpenCLJSONData.OCLPlatforms)
                {
                    ComputePlatformType current = GetPlatformType(oclPlatform.Key);
                    if (current != ComputePlatformType.NONE)
                    {
                        openCLPlatformIds[current] = oclPlatform.Value;
                    }
                    else
                    {
                        Helpers.ConsolePrint(TAG, "ethminer platforms mapping NONE");
                    }
                }
                foreach (var oclDevs in OpenCLJSONData.OCLPlatformDevices)
                {
                    ComputePlatformType current = GetPlatformType(oclDevs.Key);
                    if (current != ComputePlatformType.NONE)
                    {
                        foreach (var oclDev in oclDevs.Value)
                        {
                            if (oclDev._CL_DEVICE_TYPE.Contains("GPU"))
                            {
                                if (openCLGpuCount.ContainsKey(current))
                                {
                                    openCLGpuCount[current]++;
                                }
                                else
                                {
                                    openCLGpuCount[current] = 1;
                                }
                            }
                        }
                    }
                    else
                    {
                        Helpers.ConsolePrint(TAG, "ethminer platforms mapping NONE");
                    }
                }
                // sort platforms by platform values
                Dictionary <int, ComputePlatformType> openCLPlatformIdsRev = new Dictionary <int, ComputePlatformType>();
                List <int> platformIds = new List <int>();
                foreach (var platId in openCLPlatformIds)
                {
                    openCLPlatformIdsRev[platId.Value] = platId.Key;
                    platformIds.Add(platId.Value);
                }
                platformIds.Sort();
                // set mappings
                int cumulativeCount = 0;
                foreach (var curId in platformIds)
                {
                    var key = openCLPlatformIdsRev[curId];
                    if (openCLGpuCount.ContainsKey(key))
                    {
                        _ethminerIdsOffet[key] = cumulativeCount;
                        cumulativeCount       += openCLGpuCount[key];
                    }
                }
            }
            // allerts
            _currentNvidiaOpenCLDriver = GetNvidiaOpenCLDriver();
            // if we have nvidia cards but no CUDA devices tell the user to upgrade driver
            bool isNvidiaErrorShown = false; // to prevent showing twice

            if (ConfigManager.Instance.GeneralConfig.ShowDriverVersionWarning && HasNvidiaVideoController() && CudaDevices.Count == 0)
            {
                isNvidiaErrorShown = true;
                var minDriver      = NVIDIA_MIN_DETECTION_DRIVER.ToString();
                var recomendDrvier = NVIDIA_RECOMENDED_DRIVER.ToString();
                MessageBox.Show(String.Format(International.GetText("Compute_Device_Query_Manager_NVIDIA_Driver_Detection"),
                                              minDriver, recomendDrvier),
                                International.GetText("Compute_Device_Query_Manager_NVIDIA_RecomendedDriver_Title"),
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            // recomended driver
            if (ConfigManager.Instance.GeneralConfig.ShowDriverVersionWarning && HasNvidiaVideoController() && _currentNvidiaOpenCLDriver < NVIDIA_RECOMENDED_DRIVER && !isNvidiaErrorShown && _currentNvidiaOpenCLDriver > -1)
            {
                var recomendDrvier = NVIDIA_RECOMENDED_DRIVER.ToString();
                var nvdriverString = _currentNvidiaOpenCLDriver > -1 ? String.Format(International.GetText("Compute_Device_Query_Manager_NVIDIA_Driver_Recomended_PART"), _currentNvidiaOpenCLDriver.ToString())
                : "";
                MessageBox.Show(String.Format(International.GetText("Compute_Device_Query_Manager_NVIDIA_Driver_Recomended"),
                                              recomendDrvier, nvdriverString, recomendDrvier),
                                International.GetText("Compute_Device_Query_Manager_NVIDIA_RecomendedDriver_Title"),
                                MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }

            // #x remove reference
            MessageNotifier = null;
        }