Changeset 1773


Ignore:
Timestamp:
Aug 6, 2010, 9:09:21 PM (11 years ago)
Author:
Sven Rech
Message:

quadratic sieve fixes and button for status key

Location:
trunk/CrypPlugins/QuadraticSieve
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/CrypPlugins/QuadraticSieve/PeerToPeer.cs

    r1764 r1773  
    461461        }
    462462
    463         public string StatusIdentifier()
     463        public string StatusKey()
    464464        {
    465465            return channel + "#" + number + "-status";
  • trunk/CrypPlugins/QuadraticSieve/PeerToPeerStatusUpdater.cs

    r1763 r1773  
    2929                status = DistributedJobStatus.Status.Active;
    3030
    31             DistributedStatusUpdater.UpdateStatus(peerToPeer.StatusIdentifier(), status, peerToPeer.getActivePeers(), progress, new DateTime());
     31            DistributedStatusUpdater.UpdateStatus(peerToPeer.StatusKey(), status, peerToPeer.getActivePeers(), progress, new DateTime());
    3232        }
    3333    }
  • trunk/CrypPlugins/QuadraticSieve/QuadraticSieve.cs

    r1763 r1773  
    9696        public QuadraticSieve()
    9797        {
    98             Settings = new QuadraticSieveSettings();
     98            Settings = new QuadraticSieveSettings(this);
    9999
    100100            directoryName = Path.Combine(DirectoryHelper.DirectoryLocalTemp, "msieve");
     
    181181                    usePeer2Peer = false;
    182182                }
    183                 if (usePeer2Peer)
     183                if (settings.UsePeer2Peer)
    184184                {
    185185                    peerToPeer.SetChannel(settings.Channel);
     
    789789                conf_listMutex.ReleaseMutex();
    790790
    791                 if (usePeer2Peer)
     791                if (settings.UsePeer2Peer)
    792792                    peerToPeer.StopLoadStoreThread();
    793793
     
    824824                    quadraticSieveQuickWatchPresentation.factorList.Items.Add("Composite Factor: " + cf.ToString());
    825825            }, null);
    826         }
    827 
    828         /// <summary>
    829         /// Logs a message to the CrypTool gui
    830         /// </summary>
    831         /// <param name="p">p</param>
    832         /// <param name="notificationLevel">notificationLevel</param>
    833         private void GuiLogMessage(string p, NotificationLevel notificationLevel)
    834         {
    835             EventsHelper.GuiLogMessage(OnGuiLogNotificationOccured, this, new GuiLogEventArgs(p, this, notificationLevel));
    836826        }
    837827
     
    882872        #endregion
    883873
     874        #region internal
     875
     876        internal PeerToPeer PeerToPeer
     877        {
     878            get { return peerToPeer; }
     879        }
     880
     881        internal bool Running
     882        {
     883            get { return running; }
     884        }
     885
     886        /// <summary>
     887        /// Logs a message to the CrypTool gui
     888        /// </summary>
     889        /// <param name="p">p</param>
     890        /// <param name="notificationLevel">notificationLevel</param>
     891        internal void GuiLogMessage(string p, NotificationLevel notificationLevel)
     892        {
     893            EventsHelper.GuiLogMessage(OnGuiLogNotificationOccured, this, new GuiLogEventArgs(p, this, notificationLevel));
     894        }
     895
     896        #endregion
     897
    884898    }
    885899}
  • trunk/CrypPlugins/QuadraticSieve/QuadraticSieveSettings.cs

    r1529 r1773  
    3636        private bool usePeer2Peer;
    3737        private string channel;
     38        private QuadraticSieve quadraticSieve;
    3839        #endregion
    3940
     
    5051        /// Also calculates the amount of cores which can be used for the quadratic sieve
    5152        /// </summary>
    52         public QuadraticSieveSettings()
    53         {
     53        public QuadraticSieveSettings(QuadraticSieve quadraticSieve)
     54        {
     55            this.quadraticSieve = quadraticSieve;
    5456            CoresAvailable.Clear();
    5557            for (int i = 0; i < Environment.ProcessorCount; i++)
     
    167169        }
    168170
     171        [TaskPane("Copy status key", "Copy status key to clipboard. The key can than be used to upload it together with the job using the P2PEditor.", null, 5, true, DisplayLevel.Professional, ControlType.Button)]
     172        public void StatusKeyButton()
     173        {
     174            if (!quadraticSieve.Running)
     175            {
     176                quadraticSieve.GuiLogMessage("Quadratic sieve must be running to copy the status key.", NotificationLevel.Error);
     177                return;
     178            }
     179            if (!usePeer2Peer)
     180            {
     181                quadraticSieve.GuiLogMessage("You don't need the status key if you don't want to use peer2peer.", NotificationLevel.Error);
     182                return;
     183            }
     184
     185            var statusKey = quadraticSieve.PeerToPeer.StatusKey();
     186
     187            Clipboard.SetDataObject(statusKey, true);
     188            quadraticSieve.GuiLogMessage("Status key '" + statusKey + "' has been copied to clipboard.",
     189                                      NotificationLevel.Info);
     190        }
     191
    169192        /// <summary>
    170193        /// Called if the settings have changes
Note: See TracChangeset for help on using the changeset viewer.