示例#1
0
 private protected override void WachingStop()
 {
     OMG?.StopInformStream();
     OMG           = null;
     CurrentStatus = RigStatus.offline;
     ScanningStart();
     InformReceived?.Invoke(new RigInform {
         RigInactive = true
     });
     Waching = false;
 }
示例#2
0
 private void SetEvents()
 {
     OMG.StreamStart += () => Task.Run(() =>
     {
         ScanningStop();
         CurrentStatus = RigStatus.works;
     });
     OMG.StreamEnd += () => Task.Run(() =>
     {
         OMG?.ClearEvents();
         OMG           = null;
         CurrentStatus = RigStatus.offline;
         ScanningStart();
         InformReceived?.Invoke(new RigInform {
             RigInactive = true
         });
         Waching = false;
     });
     OMG.SentInform += RO =>
                       InformReceived.Invoke(RO);
 }
示例#3
0
                public void StartWach()
                {
                    if (!HiveWach)
                    {
                        HiveWach = true;

                        if (!HiveWachdog)
                        {
                            HiveWachdog = true;
                            Task.Run(() =>
                            {
                                Thread.Sleep(HiveOSWachdogDelay * 1000);
                                CurrentHiveStatus = HiveStatus.Normal;
                                UserInformer.SendMSG(Config.Name, "Start hive wach");
                                BackToLoop:
                                while (CurrentHiveStatus == HiveStatus.Normal && InternetConnection)
                                {
                                    Thread.Sleep(1000);
                                }
                                if (InternetConnection)
                                {
                                    //задержка
                                    for (int n = 0; n < 100; n++)
                                    {
                                        if (CurrentHiveStatus == HiveStatus.Normal)
                                        {
                                            goto BackToLoop;
                                        }
                                        Thread.Sleep(100);
                                    }

                                    string msg = "";
                                    switch (CurrentHiveStatus)
                                    {
                                    case HiveStatus.LowHashrate:
                                        {
                                            msg = "Hive: Low hashrate";
                                        }
                                        break;

                                    case HiveStatus.WorkerOffline:
                                        {
                                            msg = "Hive: Worker offline";
                                        }
                                        break;
                                    }
                                    UserInformer.SendMSG(Config.Name, msg);
                                    Rig.eWeReboot();
                                }
                                HiveWachdog = false;
                            });
                        }
                        Task.Run(() =>
                        {
                            while (!App.HiveConnection)
                            {
                                Thread.Sleep(100);
                            }

                            while (HiveWach && InternetConnection)
                            {
                                var mi = HiveClient.GetWorkerInfo(Config.HiveFarmID.Value,
                                                                  Config.HiveWorkerID.Value);

                                if (mi != null)
                                {
                                    InformReceived?.Invoke(new RigInform
                                    {
                                        Indication      = true,
                                        InfHashrates    = mi.Value.Hashrates,
                                        InfTemperatures = mi.Value.Temperatures
                                    });

                                    // low hashrate wachdog
                                    if (Config.WachdogMinHashrate != null)
                                    {
                                        if (mi.Value.Hashrates.Length > 0)
                                        {
                                            CurrentHiveStatus =
                                                mi.Value.Hashrates.Sum() < Config.WachdogMinHashrate.Value ?
                                                HiveStatus.LowHashrate : HiveStatus.Normal;
                                        }
                                        else
                                        {
                                            CurrentHiveStatus = HiveStatus.LowHashrate;
                                        }
                                    }
                                    else
                                    {
                                        CurrentHiveStatus = HiveStatus.Normal;
                                    }
                                }
                                else
                                {
                                    InformReceived?.Invoke(new RigInform {
                                        Indication = false
                                    });

                                    CurrentHiveStatus = HiveStatus.WorkerOffline;

                                    goto EndHiveWach;
                                }

                                Thread.Sleep(new TimeSpan(0, 0, HiveOSRequestDelay));
                            }
                            EndHiveWach:
                            HiveWach = false;
                        });
                    }
                }