<commit_before>///////////////////////////////////////////////////////////////////////////////
//FILE:          Devices.java
//PROJECT:       Micro-Manager 
//SUBSYSTEM:     ASIdiSPIM plugin
//-----------------------------------------------------------------------------
//
// AUTHOR:       <NAME>, <NAME>
//
// COPYRIGHT:    University of California, San Francisco, & ASI, 2013
//
// LICENSE:      This file is distributed under the BSD license.
//               License text is included with the source distribution.
//
//               This file is distributed in the hope that it will be useful,
//               but WITHOUT ANY WARRANTY; without even the implied warranty
//               of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
//
//               IN NO EVENT SHALL THE COPYRIGHT OWNER OR
//               CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
//               INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES.

package org.micromanager.asidispim.Data;

import java.util.ArrayList;
import java.util.Collections;
import java.util.EnumMap;
import java.util.EnumSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

import javax.swing.JOptionPane;

import mmcorej.CMMCore;
import mmcorej.DeviceType;
import mmcorej.StrVector;

import org.micromanager.api.ScriptInterface;
import org.micromanager.asidispim.Utils.DevicesListenerInterface;
import org.micromanager.asidispim.Utils.MyDialogUtils;
import org.micromanager.asidispim.api.ASIdiSPIMException;


/**
 * Class that holds information about the selected devices. This should always
 * be the only source of device information. The GUI should update this class
 * and use its information.
 * 
 * This could be implemented more elegantly using templates
 * 
 * @author nico
 * @author Jon
 */
public class Devices {

   // TODO would like to be able to use static methods on devices (e.g. to see whether a camera supports a particular triggering mode)
   //   but it isn't possible as presently implemented  => consider other architectures
   
   private final List<String> loadedDevices_;
   private final Prefs prefs_;
   private final CMMCore core_;
   private final List<DevicesListenerInterface> listeners_;
   private boolean listenersEnabled_;
   
   /**
    * A, B, or N for not associated with either side specifically. Now sides are
    * labeled as "paths" in GUI to avoid confusion, but code still has "sides"
    * nomenclature
    */
   public static enum Sides {
      A("A"), // side A
      B("B"), // side B
      NONE("N"); // not associated with either side specifically
      private final String text;

      Sides(String text) {
         this.text = text;
      }

      @Override
      public String toString() {
         return text;
      }
   }

   /**
    * Enum containing Device keys, representing role of each device (each key is
    * mapped to a particular Micro-manager device according to the ComboBoxes in
    * DevicesPanel).
    */
   public static enum Keys {
      NONE, CORE, PLUGIN,
      CAMERAA, CAMERAB, MULTICAMERA, CAMERALOWER, CAMERAPREVIOUS, 
      PIEZOA, PIEZOB, GALVOA, GALVOB, XYSTAGE, LOWERZDRIVE, UPPERZDRIVE,
      // SOURCE_SPIM, SOURCE_LOWER,
      PLOGIC,
      TIGERCOMM,
      UPPERHDRIVE, // horizontal drive for oSPIM head
      SHUTTERLOWER,  // shutter to be used with lower camera
      // ASGALVOA, ASGALVOB,
      // when adding new devices update Devices constructor, 
      // getDefaultDeviceData(), and Libraries enum
   };
   
   public final static Set<Devices.Keys> STAGES1D = EnumSet.of(
         Devices.Keys.LOWERZDRIVE, Devices.Keys.UPPERZDRIVE, Devices.Keys.UPPERHDRIVE,
         Devices.Keys.PIEZOA, Devices.Keys.PIEZOB);
   public final static Set<Devices.Keys> PIEZOS = EnumSet.of(
         Devices.Keys.PIEZOA, Devices.Keys.PIEZOB);
   public final static Set<Devices.Keys> STAGES2D = EnumSet.of(
         Devices.Keys.XYSTAGE, Devices.Keys.GALVOA, Devices.Keys.GALVOB);
   public final static Set<Devices.Keys> GALVOS = EnumSet.of(
         Devices.Keys.GALVOA, Devices.Keys.GALVOB);
   public final static Set<Devices.Keys> CAMERAS = EnumSet.of(
         Devices.Keys.CAMERAA, Devices.Keys.CAMERAB, Devices.Keys.MULTICAMERA,
         Devices.Keys.CAMERALOWER);
   public final static Set<Devices.Keys> SPIM_CAMERAS = EnumSet.of(
         Devices.Keys.CAMERAA, Devices.Keys.CAMERAB);


   public static enum Libraries {
      NODEVICE("NoDevice"), // if the device doesn't exist in Micro-manager
                            // (e.g. no camera has been selected)
      ASITIGER("ASITiger"), // ASI TG-1000 controller
      HAMCAM("HamamatsuHam"), 
      PCOCAM("PCO_Camera"), 
      ANDORCAM("AndorSDK3"),
      PVCAM("PVCAM"),
      DEMOCAM("DemoCamera"),
      UTILITIES("Utilities"),
      UNKNOWN("Unknown") // if the device is valid but not one we know about
      ;
      private final String text;

      Libraries(String text) {
         this.text = text;<commit_msg>ASIdiSPIM: minor bugfix, for oSPIM only consider side A camera<commit_after>///////////////////////////////////////////////////////////////////////////////
//FILE:          Devices.java
//PROJECT:       Micro-Manager 
//SUBSYSTEM:     ASIdiSPIM plugin
//-----------------------------------------------------------------------------
//
// AUTHOR:       <NAME>, <NAME>
//
// COPYRIGHT:    University of California, San Francisco, & ASI, 2013
//
// LICENSE:      This file is distributed under the BSD license.
//               License text is included with the source distribution.
//
//               This file is distributed in the hope that it will be useful,
//               but WITHOUT ANY WARRANTY; without even the implied warranty
//               of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
//
//               IN NO EVENT SHALL THE COPYRIGHT OWNER OR
//               CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
//               INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES.

package org.micromanager.asidispim.Data;

import java.util.ArrayList;
import java.util.Collections;
import java.util.EnumMap;
import java.util.EnumSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

import javax.swing.JOptionPane;

import mmcorej.CMMCore;
import mmcorej.DeviceType;
import mmcorej.StrVector;

import org.micromanager.api.ScriptInterface;
import org.micromanager.asidispim.ASIdiSPIM;
import org.micromanager.asidispim.Utils.DevicesListenerInterface;
import org.micromanager.asidispim.Utils.MyDialogUtils;
import org.micromanager.asidispim.api.ASIdiSPIMException;


/**
 * Class that holds information about the selected devices. This should always
 * be the only source of device information. The GUI should update this class
 * and use its information.
 * 
 * This could be implemented more elegantly using templates
 * 
 * @author nico
 * @author Jon
 */
public class Devices {

   // TODO would like to be able to use static methods on devices (e.g. to see whether a camera supports a particular triggering mode)
   //   but it isn't possible as presently implemented  => consider other architectures
   
   private final List<String> loadedDevices_;
   private final Prefs prefs_;
   private final CMMCore core_;
   private final List<DevicesListenerInterface> listeners_;
   private boolean listenersEnabled_;
   
   /**
    * A, B, or N for not associated with either side specifically. Now sides are
    * labeled as "paths" in GUI to avoid confusion, but code still has "sides"
    * nomenclature
    */
   public static enum Sides {
      A("A"), // side A
      B("B"), // side B
      NONE("N"); // not associated with either side specifically
      private final String text;

      Sides(String text) {
         this.text = text;
      }

      @Override
      public String toString() {
         return text;
      }
   }

   /**
    * Enum containing Device keys, representing role of each device (each key is
    * mapped to a particular Micro-manager device according to the ComboBoxes in
    * DevicesPanel).
    */
   public static enum Keys {
      NONE, CORE, PLUGIN,
      CAMERAA, CAMERAB, MULTICAMERA, CAMERALOWER, CAMERAPREVIOUS, 
      PIEZOA, PIEZOB, GALVOA, GALVOB, XYSTAGE, LOWERZDRIVE, UPPERZDRIVE,
      // SOURCE_SPIM, SOURCE_LOWER,
      PLOGIC,
      TIGERCOMM,
      UPPERHDRIVE, // horizontal drive for oSPIM head
      SHUTTERLOWER,  // shutter to be used with lower camera
      // ASGALVOA, ASGALVOB,
      // when adding new devices update Devices constructor, 
      // getDefaultDeviceData(), and Libraries enum
   };
   
   public final static Set<Devices.Keys> STAGES1D = EnumSet.of(
         Devices.Keys.LOWERZDRIVE, Devices.Keys.UPPERZDRIVE, Devices.Keys.UPPERHDRIVE,
         Devices.Keys.PIEZOA, Devices.Keys.PIEZOB);
   public final static Set<Devices.Keys> PIEZOS = EnumSet.of(
         Devices.Keys.PIEZOA, Devices.Keys.PIEZOB);
   public final static Set<Devices.Keys> STAGES2D = EnumSet.of(
         Devices.Keys.XYSTAGE, Devices.Keys.GALVOA, Devices.Keys.GALVOB);
   public final static Set<Devices.Keys> GALVOS = EnumSet.of(
         Devices.Keys.GALVOA, Devices.Keys.GALVOB);
   public final static Set<Devices.Keys> CAMERAS = EnumSet.of(
         Devices.Keys.CAMERAA, Devices.Keys.CAMERAB, Devices.Keys.MULTICAMERA,
         Devices.Keys.CAMERALOWER);
   public final static Set<Devices.Keys> SPIM_CAMERAS = 
         ASIdiSPIM.oSPIM ? EnumSet.of(Devices.Keys.CAMERAA) :  
            EnumSet.of(Devices.Keys.CAMERAA, Devices.Keys.CAMERAB);


   public static enum Libraries {
      NODEVICE("NoDevice"), // if the device doesn't exist in Micro-manager
                            // (e.g. no camera has been selected)
      ASITIGER("ASITiger"), // ASI TG-1000 controller
      HAMCAM("HamamatsuHam"), 
      PCOCAM("PCO_Camera"), 
      ANDORCAM("AndorSDK3"),
      PVCAM("PVCAM"),
      DEMOCAM("DemoCamera"),
      UTILITIES("Utilities"),
      UNKNOWN("Unknown") // if the device is valid but not one we know about
      ;
      private final String text;

      Libraries(String text) {
         this.text = text;
{'fraction_non_alphanumeric': 0.11805486778250966, 'fraction_numerical': 0.0021788650094087354, 'mean_word_length': 2.454669859733151, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3750764', 'n_tokens_mistral': 3072, 'n_tokens_neox': 2900, 'n_words': 907}