Skip to content

Commit

Permalink
Merge pull request #441 from gemini-hlsw/update/scalafmt-core-3.7.15
Browse files Browse the repository at this point in the history
Update scalafmt-core to 3.7.15
  • Loading branch information
mergify[bot] authored Oct 24, 2023
2 parents 3d1faac + cc08fe0 commit 384539f
Show file tree
Hide file tree
Showing 11 changed files with 122 additions and 63 deletions.
3 changes: 3 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,6 @@

# Scala Steward: Reformat with scalafmt 3.7.5
f66d118cdc26ea2a75e5752226ea77ae30a128fe

# Scala Steward: Reformat with scalafmt 3.7.15
4af2cb2e3aa43fd584fed608c3b0cff6176ee5ca
2 changes: 1 addition & 1 deletion .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
version = "3.7.14"
version = "3.7.15"
include ".scalafmt-common.conf"
runner.dialect = scala3
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ object SchemaStitcher {
}

sealed trait Elements
case object AllElements extends Elements
case object AllElements extends Elements
case class ElementList(l: NonEmptySet[NonEmptyString]) extends Elements

extension (el: Elements) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class SchemaStitcherTest extends CatsEffectSuite {
SchemaStitcher[IO](Path.of("baseSchema.graphql"), schemaResolver).build.map { x =>
(x, expectedSchema) match {
case (Success(a), Success(b)) => assertEquals(a.toString, b.toString)
case _ => fail("Error creating schema")
case _ => fail("Error creating schema")
}
}
}
Expand Down
16 changes: 14 additions & 2 deletions modules/server/src/main/scala/navigate/server/NavigateEngine.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,19 @@ import cats.effect.{Async, Concurrent, Ref, Temporal}
import cats.effect.kernel.Sync
import cats.syntax.all.*
import org.typelevel.log4cats.Logger
import navigate.model.NavigateCommand.{CrcsFollow, CrcsMove, CrcsPark, CrcsStop, EcsCarouselMode, InstSpecifics, McsFollow, McsPark, OiwfsProbeTracking, OiwfsTarget, Slew}
import navigate.model.NavigateCommand.{
CrcsFollow,
CrcsMove,
CrcsPark,
CrcsStop,
EcsCarouselMode,
InstSpecifics,
McsFollow,
McsPark,
OiwfsProbeTracking,
OiwfsTarget,
Slew
}
import navigate.model.{NavigateCommand, NavigateEvent}
import navigate.model.NavigateEvent.{CommandFailure, CommandPaused, CommandStart, CommandSuccess}
import navigate.model.config.NavigateEngineConfiguration
Expand Down Expand Up @@ -43,7 +55,7 @@ trait NavigateEngine[F[_]] {
def slew(slewConfig: SlewConfig): F[Unit]
def instrumentSpecifics(instrumentSpecificsParams: InstrumentSpecifics): F[Unit]
def oiwfsTarget(target: Target): F[Unit]
def oiwfsProbeTracking(config: TrackingConfig): F[Unit]
def oiwfsProbeTracking(config: TrackingConfig): F[Unit]
}

object NavigateEngine {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

package navigate.server.tcs

case class GuiderConfig (
target: Target,
case class GuiderConfig(
target: Target,
tracking: TrackingConfig
)
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ trait TcsBaseController[F[_]] {
def instrumentSpecifics(config: InstrumentSpecifics): F[ApplyCommandResult]
def oiwfsTarget(target: Target): F[ApplyCommandResult]
def rotIaa(angle: Angle): F[ApplyCommandResult]
def oiwfsProbeTracking(config: TrackingConfig): F[ApplyCommandResult]
def oiwfsProbeTracking(config: TrackingConfig): F[ApplyCommandResult]
}

object TcsBaseController {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,17 @@ class TcsBaseControllerEpics[F[_]: Async: Parallel](
.compose(setOrigin(config.instrumentSpecifics.origin))
.compose(
config.oiwfs
.map( o =>
setTarget(Getter[TcsCommands[F], TargetCommand[F, TcsCommands[F]]](_.oiwfsTargetCmd), o.target)
.compose(setProbeTracking(Getter[TcsCommands[F], ProbeTrackingCommand[F, TcsCommands[F]]](_.oiwfsProbeTrackingCommand), o.tracking))
.map(o =>
setTarget(Getter[TcsCommands[F], TargetCommand[F, TcsCommands[F]]](_.oiwfsTargetCmd),
o.target
)
.compose(
setProbeTracking(Getter[TcsCommands[F], ProbeTrackingCommand[F, TcsCommands[F]]](
_.oiwfsProbeTrackingCommand
),
o.tracking
)
)
)
.getOrElse(identity[TcsCommands[F]])
)(
Expand Down Expand Up @@ -259,15 +267,21 @@ class TcsBaseControllerEpics[F[_]: Async: Parallel](
).post
.verifiedRun(ConnectionTimeout)


def setProbeTracking(l: Getter[TcsCommands[F], ProbeTrackingCommand[F, TcsCommands[F]]], config: TrackingConfig): TcsCommands[F] => TcsCommands[F] =
{ (x: TcsCommands[F]) => l.get(x).nodAchopA(config.nodAchopA) }
.compose[TcsCommands[F]](l.get(_).nodAchopB(config.nodAchopB))
.compose[TcsCommands[F]](l.get(_).nodBchopA(config.nodBchopA))
.compose[TcsCommands[F]](l.get(_).nodBchopB(config.nodBchopB))
def setProbeTracking(
l: Getter[TcsCommands[F], ProbeTrackingCommand[F, TcsCommands[F]]],
config: TrackingConfig
): TcsCommands[F] => TcsCommands[F] = { (x: TcsCommands[F]) =>
l.get(x).nodAchopA(config.nodAchopA)
}
.compose[TcsCommands[F]](l.get(_).nodAchopB(config.nodAchopB))
.compose[TcsCommands[F]](l.get(_).nodBchopA(config.nodBchopA))
.compose[TcsCommands[F]](l.get(_).nodBchopB(config.nodBchopB))

override def oiwfsProbeTracking(config: TrackingConfig): F[ApplyCommandResult] =
setProbeTracking(Getter[TcsCommands[F], ProbeTrackingCommand[F, TcsCommands[F]]](_.oiwfsProbeTrackingCommand), config)(
setProbeTracking(
Getter[TcsCommands[F], ProbeTrackingCommand[F, TcsCommands[F]]](_.oiwfsProbeTrackingCommand),
config
)(
tcsEpics.startCommand(timeout)
).post
.verifiedRun(ConnectionTimeout)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,27 +294,25 @@ object TcsEpicsSystem {
}

case class TcsChannels[F[_]](
/**
* List of all TcsChannels.
* Channel -> Defines a raw channel
* Other cases -> Group of channels
/**
* List of all TcsChannels. Channel -> Defines a raw channel Other cases -> Group of channels
*/
telltale: TelltaleChannel[F],
telescopeParkDir: Channel[F, CadDirective],
mountFollow: Channel[F, String],
rotStopBrake: Channel[F, String],
rotParkDir: Channel[F, CadDirective],
rotFollow: Channel[F, String],
rotMoveAngle: Channel[F, String],
enclosure: EnclosureChannels[F],
sourceA: TargetChannels[F],
oiwfs: TargetChannels[F],
wavelSourceA: Channel[F, String],
slew: SlewChannels[F],
rotator: RotatorChannels[F],
origin: OriginChannels[F],
focusOffset: Channel[F, String],
oiProbeTracking: ProbeTrackingChannels[F]
telltale: TelltaleChannel[F],
telescopeParkDir: Channel[F, CadDirective],
mountFollow: Channel[F, String],
rotStopBrake: Channel[F, String],
rotParkDir: Channel[F, CadDirective],
rotFollow: Channel[F, String],
rotMoveAngle: Channel[F, String],
enclosure: EnclosureChannels[F],
sourceA: TargetChannels[F],
oiwfs: TargetChannels[F],
wavelSourceA: Channel[F, String],
slew: SlewChannels[F],
rotator: RotatorChannels[F],
origin: OriginChannels[F],
focusOffset: Channel[F, String],
oiProbeTracking: ProbeTrackingChannels[F]
)

// Next case clases are the group channels
Expand Down Expand Up @@ -452,8 +450,8 @@ object TcsEpicsSystem {

def buildProbeTrackingChannels[F[_]](
service: EpicsService[F],
top: String,
name: String
top: String,
name: String
): Resource[F, ProbeTrackingChannels[F]] = for {
aa <- service.getChannel[String](s"${top}:config${name}.A")
ab <- service.getChannel[String](s"${top}:config${name}.B")
Expand Down Expand Up @@ -903,7 +901,7 @@ object TcsEpicsSystem {
}

override val oiwfsProbeTrackingCommand: ProbeTrackingCommand[F, TcsCommands[F]] =
new ProbeTrackingCommand[F, TcsCommands[F ]]{
new ProbeTrackingCommand[F, TcsCommands[F]] {
override def nodAchopA(v: Boolean): TcsCommands[F] = addParam(
tcsEpics.oiwfsProbeTrackingCmd.nodAchopA(v.fold(BinaryOnOff.On, BinaryOnOff.Off))
)
Expand Down Expand Up @@ -1015,10 +1013,11 @@ object TcsEpicsSystem {
channels.focusOffset
)

override val oiwfsProbeTrackingCmd: ProbeTrackingCommandChannels[F] = ProbeTrackingCommandChannels(
channels.telltale,
channels.oiProbeTracking
)
override val oiwfsProbeTrackingCmd: ProbeTrackingCommandChannels[F] =
ProbeTrackingCommandChannels(
channels.telltale,
channels.oiProbeTracking
)
}

case class ParameterlessCommandChannels[F[_]: Monad](
Expand Down Expand Up @@ -1202,8 +1201,8 @@ object TcsEpicsSystem {
writeCadParam[F, BinaryOnOff](tt, slewChannels.autoparkAowfs)(v)
}

case class ProbeTrackingCommandChannels[F[_] : Monad](
tt: TelltaleChannel[F],
case class ProbeTrackingCommandChannels[F[_]: Monad](
tt: TelltaleChannel[F],
probeGuideChannels: ProbeTrackingChannels[F]
) {
def nodAchopA(v: BinaryOnOff): VerifiedEpics[F, F, Unit] =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,13 @@ class TcsBaseControllerEpicsSpec extends CatsEffectSuite {
for {
x <- createController
(st, ctr) = x
_ <- ctr.slew(SlewConfig(slewOptions, target, instrumentSpecifics, GuiderConfig(oiwfsTarget, oiwfsTracking).some))
_ <- ctr.slew(
SlewConfig(slewOptions,
target,
instrumentSpecifics,
GuiderConfig(oiwfsTarget, oiwfsTracking).some
)
)
rs <- st.get
} yield {
// Base Target
Expand Down Expand Up @@ -237,15 +243,23 @@ class TcsBaseControllerEpicsSpec extends CatsEffectSuite {
assertEquals(rs.oiwfs.coordSystem.value, "FK5".some)
assertEquals(rs.oiwfs.ephemerisFile.value, "".some)

//OIWFS probe tracking
// OIWFS probe tracking
assert(rs.oiwfsTracking.nodAchopA.connected)
assert(rs.oiwfsTracking.nodAchopB.connected)
assert(rs.oiwfsTracking.nodBchopA.connected)
assert(rs.oiwfsTracking.nodBchopB.connected)
assertEquals(rs.oiwfsTracking.nodAchopA.value.map(Enumerated[BinaryOnOff].unsafeFromTag), oiwfsTracking.nodAchopA.fold(BinaryOnOff.On, BinaryOnOff.Off).some)
assertEquals(rs.oiwfsTracking.nodAchopB.value.map(Enumerated[BinaryOnOff].unsafeFromTag), oiwfsTracking.nodAchopB.fold(BinaryOnOff.On, BinaryOnOff.Off).some)
assertEquals(rs.oiwfsTracking.nodBchopA.value.map(Enumerated[BinaryOnOff].unsafeFromTag), oiwfsTracking.nodBchopA.fold(BinaryOnOff.On, BinaryOnOff.Off).some)
assertEquals(rs.oiwfsTracking.nodBchopB.value.map(Enumerated[BinaryOnOff].unsafeFromTag), oiwfsTracking.nodBchopB.fold(BinaryOnOff.On, BinaryOnOff.Off).some)
assertEquals(rs.oiwfsTracking.nodAchopA.value.map(Enumerated[BinaryOnOff].unsafeFromTag),
oiwfsTracking.nodAchopA.fold(BinaryOnOff.On, BinaryOnOff.Off).some
)
assertEquals(rs.oiwfsTracking.nodAchopB.value.map(Enumerated[BinaryOnOff].unsafeFromTag),
oiwfsTracking.nodAchopB.fold(BinaryOnOff.On, BinaryOnOff.Off).some
)
assertEquals(rs.oiwfsTracking.nodBchopA.value.map(Enumerated[BinaryOnOff].unsafeFromTag),
oiwfsTracking.nodBchopA.fold(BinaryOnOff.On, BinaryOnOff.Off).some
)
assertEquals(rs.oiwfsTracking.nodBchopB.value.map(Enumerated[BinaryOnOff].unsafeFromTag),
oiwfsTracking.nodBchopB.fold(BinaryOnOff.On, BinaryOnOff.Off).some
)

// Slew Options
assert(rs.slew.zeroChopThrow.connected)
Expand Down Expand Up @@ -471,19 +485,27 @@ class TcsBaseControllerEpicsSpec extends CatsEffectSuite {
val trackingConfig = TrackingConfig(true, false, false, true)

for {
x <- createController
x <- createController
(st, ctr) = x
_ <- ctr.oiwfsProbeTracking(trackingConfig)
rs <- st.get
_ <- ctr.oiwfsProbeTracking(trackingConfig)
rs <- st.get
} yield {
assert(rs.oiwfsTracking.nodAchopA.connected)
assert(rs.oiwfsTracking.nodAchopB.connected)
assert(rs.oiwfsTracking.nodBchopA.connected)
assert(rs.oiwfsTracking.nodBchopB.connected)
assertEquals(rs.oiwfsTracking.nodAchopA.value.map(Enumerated[BinaryOnOff].unsafeFromTag), trackingConfig.nodAchopA.fold(BinaryOnOff.On, BinaryOnOff.Off).some)
assertEquals(rs.oiwfsTracking.nodAchopB.value.map(Enumerated[BinaryOnOff].unsafeFromTag), trackingConfig.nodAchopB.fold(BinaryOnOff.On, BinaryOnOff.Off).some)
assertEquals(rs.oiwfsTracking.nodBchopA.value.map(Enumerated[BinaryOnOff].unsafeFromTag), trackingConfig.nodBchopA.fold(BinaryOnOff.On, BinaryOnOff.Off).some)
assertEquals(rs.oiwfsTracking.nodBchopB.value.map(Enumerated[BinaryOnOff].unsafeFromTag), trackingConfig.nodBchopB.fold(BinaryOnOff.On, BinaryOnOff.Off).some)
assertEquals(rs.oiwfsTracking.nodAchopA.value.map(Enumerated[BinaryOnOff].unsafeFromTag),
trackingConfig.nodAchopA.fold(BinaryOnOff.On, BinaryOnOff.Off).some
)
assertEquals(rs.oiwfsTracking.nodAchopB.value.map(Enumerated[BinaryOnOff].unsafeFromTag),
trackingConfig.nodAchopB.fold(BinaryOnOff.On, BinaryOnOff.Off).some
)
assertEquals(rs.oiwfsTracking.nodBchopA.value.map(Enumerated[BinaryOnOff].unsafeFromTag),
trackingConfig.nodBchopA.fold(BinaryOnOff.On, BinaryOnOff.Off).some
)
assertEquals(rs.oiwfsTracking.nodBchopB.value.map(Enumerated[BinaryOnOff].unsafeFromTag),
trackingConfig.nodBchopB.fold(BinaryOnOff.On, BinaryOnOff.Off).some
)
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,16 @@ import navigate.epics.{TestChannel, VerifiedEpics}
import navigate.model.enums.{DomeMode, ShutterMode}
import navigate.server.acm.{CadDirective, GeminiApplyCommand}
import navigate.server.epicsdata.{BinaryOnOff, BinaryYesNo}
import navigate.server.tcs.TcsEpicsSystem.{EnclosureChannels, OriginChannels, ProbeTrackingChannels, RotatorChannels, SlewChannels, TargetChannels, TcsChannels, buildProbeTrackingChannels}
import navigate.server.tcs.TcsEpicsSystem.{
EnclosureChannels,
OriginChannels,
ProbeTrackingChannels,
RotatorChannels,
SlewChannels,
TargetChannels,
TcsChannels,
buildProbeTrackingChannels
}
import navigate.server.ApplyCommandResult
import monocle.{Focus, Lens}

Expand Down Expand Up @@ -55,7 +64,7 @@ object TestTcsEpicsSystem {
nodAchopA: TestChannel.State[String],
nodAchopB: TestChannel.State[String],
nodBchopA: TestChannel.State[String],
nodBchopB: TestChannel.State[String],
nodBchopB: TestChannel.State[String]
)

case class SlewChannelsState(
Expand Down Expand Up @@ -316,7 +325,7 @@ object TestTcsEpicsSystem {
new TestChannel[F, State, String](s, Focus[State](_.origin.yc))
)

def buildProbeTrackingChannels[F[_] : Applicative](
def buildProbeTrackingChannels[F[_]: Applicative](
s: Ref[F, State],
l: Lens[State, ProbeTrackingState]
): ProbeTrackingChannels[F] = ProbeTrackingChannels(
Expand Down

0 comments on commit 384539f

Please sign in to comment.