Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

REL-4619 Use the gemini id to identify grating changes #2316

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
package edu.gemini.ictd

import edu.gemini.spModel.core.Site
import edu.gemini.spModel.ictd.{ Availability, CustomMaskKey }

import edu.gemini.spModel.ictd.{Availability, CustomMaskKey}
import doobie.imports._
import edu.gemini.ictd.service.osgi.IctdServiceImpl

import scala.collection.JavaConverters._
import scala.collection.immutable.TreeMap

import scalaz.effect.IO


/** Entry point for clients. Two categories of availability information are
* obtainable. One is the availability of custom masks and the other is the
* availability of standard instrument features like filters, gratings, etc.
Expand Down Expand Up @@ -83,4 +81,12 @@ object IctdDatabase {
feature.unsafeSelect(c).availabilityMap(s).asJava

}

def main(args: Array[String]): Unit = {
val testConf = Configuration.forTesting

// Uncomment to print GS masks
//mask.unsafeSelect(testConf, Site.GS).foreach(println)
feature.unsafeSelect(testConf).gmosNorth.dispersers.foreach(println)
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package edu.gemini.ictd.dao

import edu.gemini.ictd._
import shapeless.tag
import shapeless.tag.@@

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
package edu.gemini.ictd.dao

import edu.gemini.ictd._
import edu.gemini.pot.sp.Instrument
import edu.gemini.spModel.ictd.Availability

import doobie.imports._

import scala.collection.immutable.TreeMap

import scalaz._
import scalaz.Scalaz._

import shapeless.tag.@@
Expand All @@ -19,6 +14,7 @@ object FeatureTablesDao {

final case class Feature(
name: String,
id: Option[String],
instrument: Instrument,
location: Location
)
Expand Down Expand Up @@ -52,7 +48,7 @@ object FeatureTablesDao {
): Map[Instrument, FeatureTables] = {

def toAvailabilityTable[T](features: List[Feature @@ T]): AvailabilityTable @@ T =
tag[T][AvailabilityTable](features.map(f => (f.name, f.location.availability)).toMap)
tag[T][AvailabilityTable](features.map(f => s"${f.id.fold(f.name)(id => s"${f.name}_$id")}" -> f.location.availability).toMap)

def group[T](features: List[Feature @@ T]): Instrument => AvailabilityTable @@ T =
features.groupBy(_.instrument)
Expand All @@ -77,10 +73,23 @@ object FeatureTablesDao {
import InstrumentMeta._
import LocationMeta._

def selectFeatureWithId[T](tableName: String): Query0[Feature @@ T] =
Query[HNil, Feature](
s"""
SELECT f.Name,
f.GeminiID,
c.Instrument,
c.Location
FROM $tableName f
LEFT OUTER JOIN Component c
ON c.ComponentID = f.ComponentID
""").toQuery0(HNil).map(tag[T][Feature])

def selectFeature[T](tableName: String): Query0[Feature @@ T] =
Query[HNil, Feature](
s"""
SELECT f.Name,
null as GeminiID,
c.Instrument,
c.Location
FROM $tableName f
Expand All @@ -95,7 +104,7 @@ object FeatureTablesDao {
selectFeature[FilterTag]("Filter")

val selectGrating: Query0[Grating] =
selectFeature[GratingTag]("Grating")
selectFeatureWithId[GratingTag]("Grating")

val selectIfu: Query0[Ifu] =
selectFeature[IfuTag]("IFU")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
package edu.gemini.ictd.service.osgi

import java.security.{AccessControlException, Permission, Principal}

import edu.gemini.ictd.IctdDatabase
import edu.gemini.ictd.IctdDatabase.Configuration
import edu.gemini.pot.spdb.IDBDatabaseService
import edu.gemini.spModel.core.Site
import edu.gemini.spModel.ictd.{IctdService, IctdSummary}
import edu.gemini.util.security.permission.StaffPermission
import edu.gemini.util.security.policy.ImplicitPolicy

import scalaz.effect.IO

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,21 +70,21 @@ public StageModeNorth parse(String name, StageModeNorth defaultValue) {

public enum DisperserNorth implements GmosCommonType.Disperser, ObsoletableSpType, IctdType {
// Mirror isn't tracked but is always installed.
MIRROR( "Mirror", "mirror", 0, Ictd.installed()),
B1200_G5301("B1200_G5301", "B1200", 1200, Ictd.track("B1200")),
R831_G5302( "R831_G5302", "R831", 831, Ictd.track("R831")),
B600_G5303( "B600_G5303", "B600", 600, Ictd.unavailable()) {
MIRROR( "Mirror", "mirror", 0, Ictd.installed()),
B1200_G5301("B1200", "B1200", "G5301", 1200),
R831_G5302( "R831", "R831", "G5302", 831),
B600_G5303( "B600_G5303", "B600", 600, Ictd.unavailable()) {
@Override public boolean isObsolete() { return true; }
},
B600_G5307( "B600_G5307", "B600", 600, Ictd.track("B600")),
R600_G5304( "R600_G5304", "R600", 600, Ictd.track("R600")),
B480_G5309( "B480_G5309", "B480", 480, Ictd.track("B480")),
R400_G5305( "R400_G5305", "R400", 400, Ictd.track("R400")),
R400_G5310( "R400_G5310", "R400", 400, Ictd.track("R400")),
R150_G5306( "R150_G5306", "R150", 150, Ictd.unavailable()) {
B600_G5307( "B600", "B600", "G5307", 600),
R600_G5304( "R600", "R600", "G5304", 600),
B480_G5309( "B480", "B480", "G5309", 480),
R400_G5305( "R400", "R400", "G5305", 400),
R400_G5310( "R400", "R400", "G5310", 400),
R150_G5306( "R150_G5306", "R150", 150, Ictd.unavailable()) {
@Override public boolean isObsolete() { return true; }
},
R150_G5308( "R150_G5308", "R150", 150, Ictd.track("R150")),
R150_G5308( "R150", "R150", "G5308", 150),
;

/** The default Disperser value **/
Expand All @@ -102,6 +102,13 @@ public enum DisperserNorth implements GmosCommonType.Disperser, ObsoletableSpTyp
this.ictd = ictd;
}

DisperserNorth(final String name, final String logValue, final String geminiID, final int rulingDensity) {
this.displayValue = name + "_" + geminiID;
this.logValue = logValue;
this.rulingDensity = rulingDensity; // [lines/mm]
this.ictd = Ictd.trackWithID(name, geminiID);
}

public String displayValue() {
return displayValue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,13 @@ public StageModeSouth parse(String name, StageModeSouth defaultValue) {
public enum DisperserSouth implements GmosCommonType.Disperser, IctdType {
// Mirror isn't tracked but is always installed.
MIRROR( "Mirror", "mirror", 0, Ictd.installed()),
B1200_G5321("B1200_G5321", "B1200", 1200, Ictd.track("B1200")),
R831_G5322( "R831_G5322", "R831", 831, Ictd.track( "R831")),
B600_G5323( "B600_G5323", "B600", 600, Ictd.track( "B600")),
R600_G5324( "R600_G5324", "R600", 600, Ictd.track( "R600")),
B480_G5327( "B480_G5327", "B480", 480, Ictd.track( "B480")),
R400_G5325( "R400_G5325", "R400", 400, Ictd.track( "R400")),
R150_G5326( "R150_G5326", "R150", 150, Ictd.track( "R150")),
B1200_G5321("B1200", "B1200", "G5321", 1200),
R831_G5322( "R831", "R831", "G5322", 831),
B600_G5323( "B600", "B600", "G5323", 600),
R600_G5324( "R600", "R600", "G5324", 600),
B480_G5327( "B480", "B480", "G5327", 480),
R400_G5325( "R400", "R400", "G5325", 400),
R150_G5326( "R150", "R150", "G5326", 150),
;

/** The default Disperser value **/
Expand All @@ -96,6 +96,13 @@ public enum DisperserSouth implements GmosCommonType.Disperser, IctdType {
this.ictd = ictd;
}

DisperserSouth(final String name, final String logValue, final String geminiID, final int rulingDensity) {
this.displayValue = name + "_" + geminiID;
this.logValue = logValue;
this.rulingDensity = rulingDensity; // [lines/mm]
this.ictd = Ictd.trackWithID(name, geminiID);
}

public String displayValue() {
return displayValue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
public interface IctdType {

/**
* Describes how to termine the availability of the associated instrument
* Describes how to determine the availability of the associated instrument
* feature.
*/
IctdTracking ictdTracking();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ object Ictd {
def track(name: String): IctdTracking =
IctdTracking.track(name)

def trackWithID(name: String, id: String): IctdTracking =
IctdTracking.track(s"${name}_$id")

@annotation.varargs
def trackAll(name: String, names: String*): IctdTracking =
IctdTracking.trackAll(name, names: _*)
Expand Down
Loading