Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
10/05/10 01:14:31 (14 years ago)
Author:
swagner
Message:

Worked on OKB (#1174)

Location:
branches/OKB/HeuristicLab.Clients.OKB-3.3
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/OKB/HeuristicLab.Clients.OKB-3.3/HeuristicLab.Clients.OKB-3.3.csproj

    r4549 r4553  
    204204    <None Include="HeuristicLabClientsOKBPlugin.cs.frame" />
    205205  </ItemGroup>
    206   <ItemGroup>
    207     <EmbeddedResource Include="Views\OKBExperimentView.resx">
    208       <DependentUpon>OKBExperimentView.cs</DependentUpon>
    209     </EmbeddedResource>
    210   </ItemGroup>
    211206  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
    212207  <PropertyGroup>
  • branches/OKB/HeuristicLab.Clients.OKB-3.3/OKBExperiment.cs

    r4549 r4553  
    5353        algorithm = value;
    5454        RegisterAlgorithmEvents();
    55         algorithm.Problem = Problem;
     55        if (algorithm != null) algorithm.Problem = Problem;
    5656        OnChanged();
    5757      }
    5858    }
     59    [Storable]
    5960    private long ProblemId { get; set; }
     61    [Storable]
    6062    private IProblem problem;
    6163    public IProblem Problem {
     
    6870    }
    6971
     72    public ExecutionState ExecutionState {
     73      get {
     74        if (Algorithm != null) return Algorithm.ExecutionState;
     75        else return ExecutionState.Stopped;
     76      }
     77    }
     78    public TimeSpan ExecutionTime {
     79      get {
     80        if (Algorithm != null) return Algorithm.ExecutionTime;
     81        else return TimeSpan.Zero;
     82      }
     83    }
    7084    public IKeyedItemCollection<string, IParameter> Parameters {
    7185      get {
     
    8498        if (Algorithm != null) return Algorithm.Runs;
    8599        else return null;
    86       }
    87     }
    88     public ExecutionState ExecutionState {
    89       get {
    90         if (Algorithm != null) return Algorithm.ExecutionState;
    91         else return ExecutionState.Stopped;
    92       }
    93     }
    94     public TimeSpan ExecutionTime {
    95       get {
    96         if (Algorithm != null) return Algorithm.ExecutionTime;
    97         else return TimeSpan.Zero;
    98100      }
    99101    }
     
    105107    }
    106108    [StorableConstructor]
    107     private OKBExperiment(bool deserializing) : base(deserializing) { }
    108 
    109     public void LoadAlgorithm(long id) {
    110       AlgorithmId = id;
    111       AlgorithmData algorithmData = OKBClient.Instance.GetAlgorithmData(id);
    112 
    113       using (MemoryStream stream = new MemoryStream(algorithmData.Data)) {
    114         Algorithm = XmlParser.Deserialize<IAlgorithm>(stream);
    115       }
    116     }
    117     public void LoadProblem(long id) {
    118       ProblemId = id;
    119       ProblemData problemData = OKBClient.Instance.GetProblemData(id);
    120 
    121       using (MemoryStream stream = new MemoryStream(problemData.Data)) {
    122         Problem = XmlParser.Deserialize<IProblem>(stream);
    123       }
    124     }
    125 
    126     public void Pause() {
    127       Algorithm.Pause();
    128     }
     109    private OKBExperiment(bool deserializing)
     110      : base(deserializing) {
     111      RegisterAlgorithmEvents();
     112    }
     113
     114    public void Load(Algorithm algorithm) {
     115      if (algorithm == null) {
     116        AlgorithmId = 0;
     117        Algorithm = null;
     118      } else {
     119        AlgorithmId = algorithm.Id;
     120        AlgorithmData algorithmData = OKBClient.Instance.GetAlgorithmData(algorithm.Id);
     121
     122        using (MemoryStream stream = new MemoryStream(algorithmData.Data)) {
     123          Algorithm = XmlParser.Deserialize<IAlgorithm>(stream);
     124        }
     125      }
     126    }
     127    public void Load(Problem problem) {
     128      if (problem == null) {
     129        ProblemId = 0;
     130        Problem = null;
     131      } else {
     132        ProblemId = problem.Id;
     133        ProblemData problemData = OKBClient.Instance.GetProblemData(problem.Id);
     134
     135        using (MemoryStream stream = new MemoryStream(problemData.Data)) {
     136          Problem = XmlParser.Deserialize<IProblem>(stream);
     137        }
     138      }
     139    }
     140
    129141    public void Prepare(bool clearRuns) {
    130142      if (Algorithm != null) Algorithm.Prepare(clearRuns);
    131143    }
    132144    public void Prepare() {
    133       Algorithm.Prepare();
     145      if (Algorithm != null) Algorithm.Prepare();
    134146    }
    135147    public void Start() {
    136       Algorithm.Start();
     148      if (Algorithm != null) Algorithm.Start();
     149    }
     150    public void Pause() {
     151      if (Algorithm != null) Algorithm.Pause();
    137152    }
    138153    public void Stop() {
    139       Algorithm.Stop();
     154      if (Algorithm != null) Algorithm.Stop();
    140155    }
    141156
  • branches/OKB/HeuristicLab.Clients.OKB-3.3/Views/OKBExperimentView.cs

    r4549 r4553  
    9191    protected override void SetEnabledStateOfControls() {
    9292      base.SetEnabledStateOfControls();
     93      algorithmComboBox.Enabled = (Content != null) && !ReadOnly && !Locked && (algorithmComboBox.Items.Count > 0);
     94      problemComboBox.Enabled = (Content != null) && !ReadOnly && !Locked && (problemComboBox.Items.Count > 0);
     95      tabControl.Enabled = Content != null;
    9396      executionTimeTextBox.Enabled = Content != null;
    9497      SetEnabledStateOfExecutableButtons();
     
    100103        algorithmComboBox.DataSource = OKBClient.Instance.Algorithms.Where(x => x.PlatformId == platform.Id).ToList();
    101104        algorithmComboBox.DisplayMember = "Name";
     105        algorithmComboBox.SelectedIndex = -1;
    102106        problemComboBox.DataSource = OKBClient.Instance.Problems.Where(x => x.PlatformId == platform.Id).ToList();
    103107        problemComboBox.DisplayMember = "Name";
     108        problemComboBox.SelectedIndex = -1;
    104109      }
    105110    }
     
    155160        Invoke(new EventHandler(Content_Prepared), sender, e);
    156161      else {
     162        resultsViewHost.Content = Content.Results;
    157163        ReadOnly = Locked = false;
    158164        SetEnabledStateOfExecutableButtons();
     
    191197    private void algorithmComboBox_SelectedValueChanged(object sender, System.EventArgs e) {
    192198      Algorithm algorithm = algorithmComboBox.SelectedValue as Algorithm;
    193       if ((algorithm != null) && (Content != null)) {
    194         Content.LoadAlgorithm(algorithm.Id);
    195       }
     199      if (Content != null) Content.Load(algorithm);
    196200    }
    197201    private void problemComboBox_SelectedValueChanged(object sender, System.EventArgs e) {
    198202      Problem problem = problemComboBox.SelectedValue as Problem;
    199       if ((problem != null) && (Content != null)) {
    200         Content.LoadProblem(problem.Id);
    201       }
     203      if (Content != null) Content.Load(problem);
    202204    }
    203205    private void prepareButton_Click(object sender, EventArgs e) {
Note: See TracChangeset for help on using the changeset viewer.