#!/usr/bin/env python

# $Header: https://oberon.oapd.inaf.it/shins/trunk/shins/src/liifSnapshot.py 1673 2019-03-29 14:05:36Z depa $

# usage:
#  # LbtoIIFSimulator --LOGGER.LEVEL=DEBUG --CONFIG=lbcs/lbcs.iifSimulator-svr.cfg
#  ./liifSnapshot.py [+d] |& tee $INSROOT/var/log/IifSnapshot.$(date -u +%FT%T)
#  ./liifSnapshot.py [+d] [starcat.cat] > $INSROOT/var/log/IifSnapshot.$(date -u +%Y%m%d.%H%M%S)
# The option +d means that also a snapshot of derotator polynomials is taken.
# The starcat argument means that also the focal plane coordinates of these stars should be requested

# Make sure that PYTHONPATH includes ${INSROOT}/lib/python/site-packages
#   and (if applicable) ${ICEDIR}/python to avoid errors with imports here...
import sys
import os
import traceback
import Ice
import time
import datetime

# you need astropy >= 1.3 to avoid an error from importing astroplan...
# https://github.com/astropy/astropy
import astropy
import astropy.units as unit0s
from astropy.time import Time
from astropy import coordinates
from astropy.coordinates import SkyCoord, EarthLocation, AltAz, Angle

# https://github.com/astropy/astroplan
# needs to be part of PYTHONPATH
import astroplan
from astroplan import observer

# import LtcsIifStarcat

try:
    import lbto
except:
    # Here handle the case of newer Ice versions where slice2py may be absent.
    # Use $INSROOT/slice to look for the LbtoIIF*.ice files
    insrootsl = os.environ['INSROOT'] + "/slice"
    # This will also include LbtoIIFFactory.ice by the include mechanism
    # jit - just in time compilation
    jit = "-I" + insrootsl + " --all " + insrootsl + "/LbtoIIFInterfaceFactory.ice"
    Ice.loadSlice(jit)
    import lbto


def appendDDstruct(_key, _dict):
    dd = lbto.DDstruct()
    dd.DDname = _key
    _dict.append(dd)

# @return 0 if succeeded, >0 if not
def tst_GetParameter(iifprx, repCnt=1):
    print(tst_GetParameter)
    # getting radec:

    seqdd = []

    # see further down for a full list of DD entry keys
    appendDDstruct("R_FocalStation", seqdd)
    appendDDstruct("L_FocalStation", seqdd)
    appendDDstruct("R_Instrument", seqdd)
    appendDDstruct("L_Instrument", seqdd)

    appendDDstruct("MountAchievedRAHMS", seqdd)
    appendDDstruct("MountAchievedHAHMS", seqdd)
    appendDDstruct("MountAchievedDECDMS", seqdd)
    appendDDstruct("MountAchievedAZDMS", seqdd)
    appendDDstruct("MountAchievedALTDMS", seqdd)

    appendDDstruct("ParAngle", seqdd)
    appendDDstruct("UTC", seqdd)
    appendDDstruct("LST", seqdd)
    # appendDDstruct("HA",seqdd)
    appendDDstruct("MJDUTC", seqdd)
    appendDDstruct("Epoch", seqdd)

    appendDDstruct("IIFOnSource", seqdd)
    appendDDstruct("IIFAzOnSource", seqdd)
    appendDDstruct("IIFElOnSource", seqdd)
    appendDDstruct("IIFAllOnSource", seqdd)
    appendDDstruct("R_IIFOnSource", seqdd)
    appendDDstruct("L_IIFOnSource", seqdd)
    appendDDstruct("R_PresetMode", seqdd)
    appendDDstruct("L_PresetMode", seqdd)
    appendDDstruct("R_EffectiveMode", seqdd)
    appendDDstruct("L_EffectiveMode", seqdd)
    appendDDstruct("R_PseudoMonocular", seqdd)
    appendDDstruct("L_PseudoMonocular", seqdd)

    appendDDstruct("R_OffsetApplied", seqdd)
    appendDDstruct("L_OffsetApplied", seqdd)
    appendDDstruct("R_GuideDEC", seqdd)
    appendDDstruct("L_GuideDEC", seqdd)
    appendDDstruct("R_GuideRA", seqdd)
    appendDDstruct("L_GuideRA", seqdd)
    appendDDstruct("AZPosition", seqdd)
    appendDDstruct("AZTarget", seqdd)
    # appendDDstruct("AZVelocity",seqdd)
    appendDDstruct("AZTimeStamp", seqdd)
    appendDDstruct("AZTimeToLimit", seqdd)
    appendDDstruct("ELPosition", seqdd)
    appendDDstruct("ELTarget", seqdd)
    # appendDDstruct("ELVelocity",seqdd)
    appendDDstruct("ELTimeStamp", seqdd)

    appendDDstruct("R_AchievedDECDMS", seqdd)
    appendDDstruct("L_AchievedDECDMS", seqdd)
    appendDDstruct("R_AchievedRAHMS", seqdd)
    appendDDstruct("L_AchievedRAHMS", seqdd)
    appendDDstruct("R_AchievedAZDMS", seqdd)
    appendDDstruct("L_AchievedAZDMS", seqdd)
    appendDDstruct("R_AchievedALTDMS", seqdd)
    appendDDstruct("L_AchievedALTDMS", seqdd)

    appendDDstruct("R_IA", seqdd)
    appendDDstruct("L_IA", seqdd)
    appendDDstruct("R_IE", seqdd)
    appendDDstruct("L_IE", seqdd)
    appendDDstruct("R_PointingModel", seqdd)
    appendDDstruct("L_PointingModel", seqdd)
    appendDDstruct("R_PosAngle", seqdd)
    appendDDstruct("L_PosAngle", seqdd)
    appendDDstruct("R_ParAngle", seqdd)
    appendDDstruct("L_ParAngle", seqdd)
    appendDDstruct("R_PresetParAngle", seqdd)
    appendDDstruct("L_PresetParAngle", seqdd)
    appendDDstruct("R_PresetPosAngle", seqdd)
    appendDDstruct("L_PresetPosAngle", seqdd)
    appendDDstruct("R_PresetRotMode", seqdd)
    appendDDstruct("L_PresetRotMode", seqdd)
    appendDDstruct("R_PresetTargetDECDMS", seqdd)
    appendDDstruct("L_PresetTargetDECDMS", seqdd)
    appendDDstruct("R_PresetTargetRAHMS", seqdd)
    appendDDstruct("L_PresetTargetRAHMS", seqdd)
    appendDDstruct("R_PresetTargetAZDMS", seqdd)
    appendDDstruct("L_PresetTargetAZDMS", seqdd)
    appendDDstruct("R_PresetTargetALTDMS", seqdd)
    appendDDstruct("L_PresetTargetALTDMS", seqdd)
    appendDDstruct("R_RAOffset", seqdd)
    appendDDstruct("L_RAOffset", seqdd)
    appendDDstruct("R_RotAngle", seqdd)
    appendDDstruct("L_RotAngle", seqdd)
    appendDDstruct("R_RotCenterDECDMS", seqdd)
    appendDDstruct("L_RotCenterDECDMS", seqdd)
    appendDDstruct("R_RotCenterRAHMS", seqdd)
    appendDDstruct("L_RotCenterRAHMS", seqdd)
    appendDDstruct("R_RotDemandPosition", seqdd)
    appendDDstruct("L_RotDemandPosition", seqdd)
    appendDDstruct("R_RotMode", seqdd)
    appendDDstruct("L_RotMode", seqdd)
    appendDDstruct("R_TargetDEC", seqdd)
    appendDDstruct("L_TargetDEC", seqdd)
    appendDDstruct("R_TargetParAngle", seqdd)
    appendDDstruct("L_TargetParAngle", seqdd)
    appendDDstruct("R_TargetRA", seqdd)
    appendDDstruct("L_TargetRA", seqdd)

    ddlen = len(seqdd)

    for r in range(repCnt):
        jtzt = datetime.datetime.utcnow()
        print(str(jtzt), 'UTC')

        ret = iifprx.GetParameter(seqdd)
        print(ret)
        retlen = len(ret.resmsg)
        # ddlen requested number, retlen-1 responded (0=status)
        for i in range(min(ddlen, retlen - 1)):
            print(seqdd[i].DDname, ret.resmsg[i + 1])
        # print ret.resmsg[1]
        # print ret.resmsg[2]
        if repCnt > 1 :
            time.sleep(3)

    return ret.rescode

# @return 0 if authorized, >0 if not
def tst_Authorize(iifprx):
    print(tst_Authorize)
    # authorize:

    ret = iifprx.Authorize()
    print(ret)
    return ret.rescode


# @brief Get 6 derotator polynomials covering a total of the next minute.
#  So the distance between the polynomials start times is 10 seconds.
# @param iifprx The proxy to left, ride or both sides
# @return 0 if successful, 1 if error, 2 if warning
def tst_GetRotatorPolynomials(iifprx):
    print(tst_GetRotatorPolynomials)
    nowT = Time.now()
    print(nowT, 'UTC')
    nowT.format = 'mjd'
    print(nowT, 'MJD')
    print('left')
    # start now, 6 polynomials; delta T 10  secs; order 2
    ret = iifprx.GetRotatorPolynomials(nowT.value, 6, 10, 2, 'left')
    print(ret)
    print('right')
    ret = iifprx.GetRotatorPolynomials(nowT.value, 6, 10, 2, 'right')
    print(ret)

    return ret.rescode

# @brief Get the focal plane coordinates of the infrared and AO stars.
# @param sc The catalogue as a sequence of stars
# @param iifprx The proxy to left, ride or both sides
# @return 0 if successful, 1 if error, 2 if warning
# @since 2017-05-30
def tst_GetKFPCoordinates2(sc,iifprx):
    print(tst_GetKFPCoordinates2)
    nowT = Time.now()
    print(nowT, 'UTC')
    nowT.format = 'mjd'
    print(nowT, 'MJD')
    print('left')
    # empty list of stars: let the telescope take the preset' stars list
    # but this does not work in general because the preset was done by the iifDummyLocalhost
    # and the TCS does not recognize that these stars were send from that interface
    # todo: how can we convert the sc to a python list sl of lbto::position2 for the iifprx ?
    sl = []
    ret = iifprx.GetKFPCoordinates2(sl, 'left')
    print(ret)
    print('right')
    ret = iifprx.GetKFPCoordinates2(sl, 'right')
    print(ret)

    return ret.rescode

def getDomain():
    '''
    return either mpia-hd.mpg.de or mountain.lbto.org
    based on several heuristics
    '''
    try:
        # environment variable already set
        domain=os.environ['DOMAIN']
    except:
        # check resolv.conf
        sycmd=os.popen("fgrep domain /etc/resolv.conf | awk '{print $NF}'")
        domain=sycmd.read()
        if len(domain) ==0:
            sycmd=os.popen("fgrep search /etc/resolv.conf | awk '{print $NF}'")
            domain=sycmd.read()
            if len(domain) == 0:
                try:
                    sycmd=os.popen("nslookup irws2")
                    ip=sycmd.read()
                    if ip.find("149") == -1:
                        domain='mountain.lbto.org'
                    else:
                        domain='mpia-hd.mpg.de'
                except:
                    domain='mountain.lbto.org'

    if  'mpia' in domain:
        return 'mpia-hd.mpg.de'
    else:
        return 'mountain.lbto.org'

jtzt = datetime.datetime.utcnow()
print(str(jtzt), 'UTC')

ic = Ice.initialize(sys.argv)

# The following assignment to ep works for the interaction with the IIF server on the mountain.
# Alternatively, for test purposes with Frank's local dummy server compiled
# into our Linc-Nirvana software, do the following:
# i) Replace the link in $HOME/lnsw/config for alias.cfg to alias-lbt.cfg
#    with a symbolic link to alias-localhost.cfg ;
# ii) Start
#      pgrep -al "Simulator*"
#      LbtoIIFSimulator --LOGGER.LEVEL=DEBUG --CONFIG=lbcs/lbcs.iifSimulator-svr.cfg &
#     in the background or better in a terminal on its own or the VM with the LBT simulator
# iii) Replace host and port, the following assignment, by
#       ep = ic.stringToProxy("Factory -t:default -h localhost -p 11001")
# iv) use CTRL-C or 'pkill LbtoIIFSimulator*' to stop the simulator when done.

domain=getDomain()
print domain 
if 'oapd' in domain:
# if 'mpia' in domain:
    # Testing this in a MPIA computer with Frank's simulator:
    # ep = ic.stringToProxy("Factory -t:default -h localhost -p 11001")
    # Testing this in the MPIA VirtualBox setup:

    # ep = ic.stringToProxy("Factory -t:default -h linc2.mpia-hd.mpg.de -p 10000")
    ep = ic.stringToProxy("Factory -t:default -h battra.oapd.inaf.it -p 10000")
else:
    # Using this on the mountain with the online IIF
    # ep = ic.stringToProxy("Factory -t:default -h iif.mountain.lbto.org -p 10000")
    ep = ic.stringToProxy("Factory -t:default -h localhost -p 10213")

iif_factory = lbto.FactoryPrx.checkedCast(ep)
if not iif_factory:
    raise RuntimeError("Invalid proxy")

# # Use this for the left side, SX
# iif_sx = iif_factory.create('LN_IIF','bentGregorianBack left','LINC')
# if not iif_sx:
# 	raise RuntimeError("Invalid proxy SX")
#
# # Use this for the right side, DX
# # The interface allows also to register with 'bentGregorianBack both'
# iif_dx = iif_factory.create('LN_IIF','bentGregorianBack right','LINC')
# if not iif_dx:
# 	raise RuntimeError("Invalid proxy DX")

# iif_sdx = iif_factory.create('LN_LIIF_IIF', 'bentGregorianBack both', 'LINC')
iif_sdx = iif_factory.create('LBTI_LIIF_IIF', 'bentGregorianCenter left', 'LBTI')  # changed since SHARK is being authorized as LBTI
if not iif_sdx:
    raise RuntimeError("Invalid proxy SX+DX")

tst_GetParameter(iif_sdx, 1)

# If this is called with an argument, assume that the derotator
# polynomials are also to be printed.
if len(sys.argv) > 1:
    tst_GetRotatorPolynomials(iif_sdx)

# get also focal plane coordinates for the list of stars in the catalogue
# does not work yet because in tst_GetKFPCoordinates() we're unable to covnert the catalog to a list of lbto::position2
# if len(sys.argv) > 2:
#     sc=LiifStarcat.LiifStarcat(sys.argv[2],'lbto')
#     tst_GetKFPCoordinates2(sc,iif_sdx)

# finally logout from the ICE interface
ic.destroy()

# Appendix: list of data dictionary values
# appendDDstruct("Temp201",seqdd)
# appendDDstruct("Temp202",seqdd)
# appendDDstruct("Temp203",seqdd)
# appendDDstruct("Temp204",seqdd)
# appendDDstruct("Temp205",seqdd)
# appendDDstruct("Temp206",seqdd)
# appendDDstruct("Temp207",seqdd)
# appendDDstruct("Temp208",seqdd)
# appendDDstruct("Temp209",seqdd)
# appendDDstruct("Temp210",seqdd)
# appendDDstruct("Temp301",seqdd)
# appendDDstruct("Temp302",seqdd)
# appendDDstruct("Temp303",seqdd)
# appendDDstruct("Temp304",seqdd)
# appendDDstruct("Temp305",seqdd)
# appendDDstruct("Temp306",seqdd)
# appendDDstruct("Temp307",seqdd)
# appendDDstruct("Temp308",seqdd)
# appendDDstruct("Temp309",seqdd)
# appendDDstruct("Temp310",seqdd)
# appendDDstruct("Temp401",seqdd)
# appendDDstruct("Temp402",seqdd)
# appendDDstruct("Temp403",seqdd)
# appendDDstruct("Temp404",seqdd)
# appendDDstruct("Temp405",seqdd)
# appendDDstruct("Temp406",seqdd)
# appendDDstruct("Temp407",seqdd)
# appendDDstruct("Temp408",seqdd)
# appendDDstruct("ChamberTemp",seqdd)
# appendDDstruct("ChamberDewPoint",seqdd)
# appendDDstruct("LBTWeatherAlive",seqdd)
# appendDDstruct("LBTWeatherAliveFront",seqdd)
# appendDDstruct("LBTDewPoint",seqdd)
# appendDDstruct("LBTHumidity",seqdd)
# appendDDstruct("LBTPressure",seqdd)
# appendDDstruct("LBTRain",seqdd)
# appendDDstruct("LBTTemp",seqdd)
# appendDDstruct("LBTTimeStamp",seqdd)
# appendDDstruct("LBTWindDir",seqdd)
# appendDDstruct("LBTWindDirRaw",seqdd)
# appendDDstruct("LBTWindSpeed",seqdd)
# appendDDstruct("LBTWindDirFront",seqdd)
# appendDDstruct("LBTWindDirFrontRaw",seqdd)
# appendDDstruct("LBTWindSpeedFront",seqdd)
# appendDDstruct("SQMAlive",seqdd)
# appendDDstruct("SQMTimeStamp",seqdd)
# appendDDstruct("SQMBrightness",seqdd)
# appendDDstruct("SMTWeatherAlive",seqdd)
# appendDDstruct("SMTDewPoint",seqdd)
# appendDDstruct("SMTHumidity",seqdd)
# appendDDstruct("SMTPressure",seqdd)
# appendDDstruct("SMTRain",seqdd)
# appendDDstruct("SMTTemp",seqdd)
# appendDDstruct("SMTPeakWindDir1m",seqdd)
# appendDDstruct("SMTPeakWindSpeed1m",seqdd)
# appendDDstruct("SMTTimeStamp",seqdd)
# appendDDstruct("SMTWindDir",seqdd)
# appendDDstruct("SMTWindSpeed",seqdd)
# appendDDstruct("SMTTau",seqdd)
# appendDDstruct("SMTTauSigma",seqdd)
# appendDDstruct("SMTTauZenith",seqdd)
# appendDDstruct("SMTZenithOpacity",seqdd)
# appendDDstruct("DIMMElevation",seqdd)
# appendDDstruct("DIMMSeeing",seqdd)
# appendDDstruct("DIMMSeeingZenith",seqdd)
# appendDDstruct("DIMMR0",seqdd)
# appendDDstruct("DIMMMessage",seqdd)
# appendDDstruct("DIMMStatus",seqdd)
# appendDDstruct("DIMMTimeStamp",seqdd)
# appendDDstruct("Build",seqdd)
# appendDDstruct("R_FocalStation",seqdd)
# appendDDstruct("L_FocalStation",seqdd)
# appendDDstruct("R_Instrument",seqdd)
# appendDDstruct("L_Instrument",seqdd)
# appendDDstruct("IIFRunning",seqdd)
# appendDDstruct("DDSRunning",seqdd)
# appendDDstruct("LSSRunning",seqdd)
# appendDDstruct("ECSRunning",seqdd)
# appendDDstruct("ENVRunning",seqdd)
# appendDDstruct("PCSRunning",seqdd)
# appendDDstruct("MCSRunning",seqdd)
# appendDDstruct("OSSRunning",seqdd)
# appendDDstruct("R_PMCRunning",seqdd)
# appendDDstruct("L_PMCRunning",seqdd)
# appendDDstruct("R_PSFRunning",seqdd)
# appendDDstruct("L_PSFRunning",seqdd)
# appendDDstruct("R_GCSRunning",seqdd)
# appendDDstruct("L_GCSRunning",seqdd)
# appendDDstruct("R_AOSRunning",seqdd)
# appendDDstruct("L_AOSRunning",seqdd)
# appendDDstruct("IIFOnSource",seqdd)
# appendDDstruct("iif.onSource",seqdd)
# appendDDstruct("IIFAzOnSource",seqdd)
# appendDDstruct("IIFElOnSource",seqdd)
# appendDDstruct("IIFAllOnSource",seqdd)
# appendDDstruct("R_IIFOnSource",seqdd)
# appendDDstruct("L_IIFOnSource",seqdd)
# appendDDstruct("R_PresetMode",seqdd)
# appendDDstruct("L_PresetMode",seqdd)
# appendDDstruct("R_EffectiveMode",seqdd)
# appendDDstruct("L_EffectiveMode",seqdd)
# appendDDstruct("R_NonSiderealOverride",seqdd)
# appendDDstruct("L_NonSiderealOverride",seqdd)
# appendDDstruct("R_NonSiderealName",seqdd)
# appendDDstruct("L_NonSiderealName",seqdd)
# appendDDstruct("R_PseudoMonocular",seqdd)
# appendDDstruct("L_PseudoMonocular",seqdd)
# appendDDstruct("R_ShutterOpen",seqdd)
# appendDDstruct("L_ShutterOpen",seqdd)
# appendDDstruct("R_FrontRotatorReady",seqdd)
# appendDDstruct("L_FrontRotatorReady",seqdd)
# appendDDstruct("R_DirectRotatorReady",seqdd)
# appendDDstruct("L_DirectRotatorReady",seqdd)
# appendDDstruct("R_AOReferenceRA",seqdd)
# appendDDstruct("L_AOReferenceRA",seqdd)
# appendDDstruct("R_AOReferenceDEC",seqdd)
# appendDDstruct("L_AOReferenceDEC",seqdd)
# appendDDstruct("R_OffsetApplied",seqdd)
# appendDDstruct("L_OffsetApplied",seqdd)
# appendDDstruct("R_AGWFilter",seqdd)
# appendDDstruct("L_AGWFilter",seqdd)
# appendDDstruct("R_AGWFilterPos",seqdd)
# appendDDstruct("L_AGWFilterPos",seqdd)
# appendDDstruct("R_AGWFocus",seqdd)
# appendDDstruct("L_AGWFocus",seqdd)
# appendDDstruct("R_AGWHappy",seqdd)
# appendDDstruct("L_AGWHappy",seqdd)
# appendDDstruct("R_AGWPosX",seqdd)
# appendDDstruct("L_AGWPosX",seqdd)
# appendDDstruct("R_AGWReqX",seqdd)
# appendDDstruct("L_AGWReqX",seqdd)
# appendDDstruct("R_AGWPosY",seqdd)
# appendDDstruct("L_AGWPosY",seqdd)
# appendDDstruct("R_AGWReqY",seqdd)
# appendDDstruct("L_AGWReqY",seqdd)
# appendDDstruct("R_AGWKFPPosX",seqdd)
# appendDDstruct("L_AGWKFPPosX",seqdd)
# appendDDstruct("R_AGWKFPPosY",seqdd)
# appendDDstruct("L_AGWKFPPosY",seqdd)
# appendDDstruct("R_AGWKFPReqX",seqdd)
# appendDDstruct("L_AGWKFPReqX",seqdd)
# appendDDstruct("R_AGWKFPReqY",seqdd)
# appendDDstruct("L_AGWKFPReqY",seqdd)
# appendDDstruct("R_GuideBadCount",seqdd)
# appendDDstruct("L_GuideBadCount",seqdd)
# appendDDstruct("R_GuideExpTime",seqdd)
# appendDDstruct("L_GuideExpTime",seqdd)
# appendDDstruct("R_GuideDEC",seqdd)
# appendDDstruct("L_GuideDEC",seqdd)
# appendDDstruct("R_GuideRA",seqdd)
# appendDDstruct("L_GuideRA",seqdd)
# appendDDstruct("R_GuideHotspotX",seqdd)
# appendDDstruct("L_GuideHotspotX",seqdd)
# appendDDstruct("R_GuideHotspotY",seqdd)
# appendDDstruct("L_GuideHotspotY",seqdd)
# appendDDstruct("R_GuideIntTime",seqdd)
# appendDDstruct("L_GuideIntTime",seqdd)
# appendDDstruct("R_GuideFlag",seqdd)
# appendDDstruct("L_GuideFlag",seqdd)
# appendDDstruct("R_GuideAcquisition",seqdd)
# appendDDstruct("L_GuideAcquisition",seqdd)
# appendDDstruct("R_GuideActive",seqdd)
# appendDDstruct("L_GuideActive",seqdd)
# appendDDstruct("R_GuideAcquireImage",seqdd)
# appendDDstruct("L_GuideAcquireImage",seqdd)
# appendDDstruct("R_GuideFreq",seqdd)
# appendDDstruct("L_GuideFreq",seqdd)
# appendDDstruct("R_GuideSeeing",seqdd)
# appendDDstruct("L_GuideSeeing",seqdd)
# appendDDstruct("R_GuideSeeingValid",seqdd)
# appendDDstruct("L_GuideSeeingValid",seqdd)
# appendDDstruct("R_GuideImageTime",seqdd)
# appendDDstruct("L_GuideImageTime",seqdd)
# appendDDstruct("R_GuideImageTimeStamp",seqdd)
# appendDDstruct("L_GuideImageTimeStamp",seqdd)
# appendDDstruct("R_GuideStarLost",seqdd)
# appendDDstruct("L_GuideStarLost",seqdd)
# appendDDstruct("R_GuidingStatus",seqdd)
# appendDDstruct("L_GuidingStatus",seqdd)
# appendDDstruct("R_WFSCycleTime",seqdd)
# appendDDstruct("L_WFSCycleTime",seqdd)
# appendDDstruct("R_WFSExpTime",seqdd)
# appendDDstruct("L_WFSExpTime",seqdd)
# appendDDstruct("R_WFSHotspotX",seqdd)
# appendDDstruct("L_WFSHotspotX",seqdd)
# appendDDstruct("R_WFSHotspotY",seqdd)
# appendDDstruct("L_WFSHotspotY",seqdd)
# appendDDstruct("R_WFSIntTime",seqdd)
# appendDDstruct("L_WFSIntTime",seqdd)
# appendDDstruct("R_WFSCounter",seqdd)
# appendDDstruct("L_WFSCounter",seqdd)
# appendDDstruct("R_WFSFilename",seqdd)
# appendDDstruct("L_WFSFilename",seqdd)
# appendDDstruct("R_WFSFWHMMean",seqdd)
# appendDDstruct("L_WFSFWHMMean",seqdd)
# appendDDstruct("R_WFSFWHMSigma",seqdd)
# appendDDstruct("L_WFSFWHMSigma",seqdd)
# appendDDstruct("R_WFSPath",seqdd)
# appendDDstruct("L_WFSPath",seqdd)
# appendDDstruct("R_WFSFlag",seqdd)
# appendDDstruct("L_WFSFlag",seqdd)
# appendDDstruct("R_WFSAcquireImage",seqdd)
# appendDDstruct("L_WFSAcquireImage",seqdd)
# appendDDstruct("R_WFSStatusValue",seqdd)
# appendDDstruct("L_WFSStatusValue",seqdd)
# appendDDstruct("R_WFSRMS",seqdd)
# appendDDstruct("L_WFSRMS",seqdd)
# appendDDstruct("R_WFSRMShex",seqdd)
# appendDDstruct("L_WFSRMShex",seqdd)
# appendDDstruct("R_WFSRMSlow",seqdd)
# appendDDstruct("L_WFSRMSlow",seqdd)
# appendDDstruct("R_WFSIsCollimated",seqdd)
# appendDDstruct("L_WFSIsCollimated",seqdd)
# appendDDstruct("R_WFSZ2",seqdd)
# appendDDstruct("L_WFSZ2",seqdd)
# appendDDstruct("R_WFSZ3",seqdd)
# appendDDstruct("L_WFSZ3",seqdd)
# appendDDstruct("R_WFSZ4",seqdd)
# appendDDstruct("L_WFSZ4",seqdd)
# appendDDstruct("R_WFSZ5",seqdd)
# appendDDstruct("L_WFSZ5",seqdd)
# appendDDstruct("R_WFSZ6",seqdd)
# appendDDstruct("L_WFSZ6",seqdd)
# appendDDstruct("R_WFSZ7",seqdd)
# appendDDstruct("L_WFSZ7",seqdd)
# appendDDstruct("R_WFSZ8",seqdd)
# appendDDstruct("L_WFSZ8",seqdd)
# appendDDstruct("R_WFSZ9",seqdd)
# appendDDstruct("L_WFSZ9",seqdd)
# appendDDstruct("R_WFSZ10",seqdd)
# appendDDstruct("L_WFSZ10",seqdd)
# appendDDstruct("R_WFSZ11",seqdd)
# appendDDstruct("L_WFSZ11",seqdd)
# appendDDstruct("R_WFSZ12",seqdd)
# appendDDstruct("L_WFSZ12",seqdd)
# appendDDstruct("R_WFSZ13",seqdd)
# appendDDstruct("L_WFSZ13",seqdd)
# appendDDstruct("R_WFSZ14",seqdd)
# appendDDstruct("L_WFSZ14",seqdd)
# appendDDstruct("R_WFSZ15",seqdd)
# appendDDstruct("L_WFSZ15",seqdd)
# appendDDstruct("R_WFSZ16",seqdd)
# appendDDstruct("L_WFSZ16",seqdd)
# appendDDstruct("R_WFSZ17",seqdd)
# appendDDstruct("L_WFSZ17",seqdd)
# appendDDstruct("R_WFSZ18",seqdd)
# appendDDstruct("L_WFSZ18",seqdd)
# appendDDstruct("R_WFSZ19",seqdd)
# appendDDstruct("L_WFSZ19",seqdd)
# appendDDstruct("R_WFSZ20",seqdd)
# appendDDstruct("L_WFSZ20",seqdd)
# appendDDstruct("R_WFSZ21",seqdd)
# appendDDstruct("L_WFSZ21",seqdd)
# appendDDstruct("R_WFSZ22",seqdd)
# appendDDstruct("L_WFSZ22",seqdd)
# appendDDstruct("AZPosition",seqdd)
# appendDDstruct("AZTarget",seqdd)
# appendDDstruct("AZServoMode",seqdd)
# appendDDstruct("AZVelocity",seqdd)
# appendDDstruct("AZTimeStamp",seqdd)
# appendDDstruct("AZTimeToLimit",seqdd)
# appendDDstruct("ELPosition",seqdd)
# appendDDstruct("ELTarget",seqdd)
# appendDDstruct("ELServoMode",seqdd)
# appendDDstruct("ELVelocity",seqdd)
# appendDDstruct("ELTimeStamp",seqdd)
# appendDDstruct("R_FBGRPosition",seqdd)
# appendDDstruct("L_FBGRPosition",seqdd)
# appendDDstruct("R_FBGRVelocity",seqdd)
# appendDDstruct("L_FBGRVelocity",seqdd)
# appendDDstruct("R_FBGRTimeToLimit",seqdd)
# appendDDstruct("L_FBGRTimeToLimit",seqdd)
# appendDDstruct("R_RBGRPosition",seqdd)
# appendDDstruct("L_RBGRPosition",seqdd)
# appendDDstruct("R_RBGRVelocity",seqdd)
# appendDDstruct("L_RBGRVelocity",seqdd)
# appendDDstruct("R_RBGRTimeToLimit",seqdd)
# appendDDstruct("L_RBGRTimeToLimit",seqdd)
# appendDDstruct("R_DGRPosition",seqdd)
# appendDDstruct("L_DGRPosition",seqdd)
# appendDDstruct("R_DGRVelocity",seqdd)
# appendDDstruct("L_DGRVelocity",seqdd)
# appendDDstruct("R_DGRTimeToLimit",seqdd)
# appendDDstruct("L_DGRTimeToLimit",seqdd)
# appendDDstruct("R_M2X",seqdd)
# appendDDstruct("L_M2X",seqdd)
# appendDDstruct("R_M2Y",seqdd)
# appendDDstruct("L_M2Y",seqdd)
# appendDDstruct("R_M2Z",seqdd)
# appendDDstruct("L_M2Z",seqdd)
# appendDDstruct("R_M2Rx",seqdd)
# appendDDstruct("L_M2Rx",seqdd)
# appendDDstruct("R_M2Ry",seqdd)
# appendDDstruct("L_M2Ry",seqdd)
# appendDDstruct("R_M2Rz",seqdd)
# appendDDstruct("L_M2Rz",seqdd)
# appendDDstruct("R_M2StateMsg",seqdd)
# appendDDstruct("L_M2StateMsg",seqdd)
# appendDDstruct("R_M3Tip",seqdd)
# appendDDstruct("L_M3Tip",seqdd)
# appendDDstruct("R_M3Tilt",seqdd)
# appendDDstruct("L_M3Tilt",seqdd)
# appendDDstruct("R_M3Piston",seqdd)
# appendDDstruct("L_M3Piston",seqdd)
# appendDDstruct("R_M3Sel",seqdd)
# appendDDstruct("L_M3Sel",seqdd)
# appendDDstruct("R_M3StateMsg",seqdd)
# appendDDstruct("L_M3StateMsg",seqdd)
# appendDDstruct("PCSTimeStamp",seqdd)
# appendDDstruct("AZDemandTimeStamp",seqdd)
# appendDDstruct("AZDemandPosition",seqdd)
# appendDDstruct("AZDemandVelocity",seqdd)
# appendDDstruct("AZDemandAcceleration",seqdd)
# appendDDstruct("ELDemandTimeStamp",seqdd)
# appendDDstruct("ELDemandPosition",seqdd)
# appendDDstruct("ELDemandVelocity",seqdd)
# appendDDstruct("ELDemandAcceleration",seqdd)
# appendDDstruct("MountAchievedRAHMS",seqdd)
# appendDDstruct("MountAchievedHAHMS",seqdd)
# appendDDstruct("MountAchievedDECDMS",seqdd)
# appendDDstruct("MountAchievedAZDMS",seqdd)
# appendDDstruct("MountAchievedALTDMS",seqdd)
# appendDDstruct("MountAchievedRA",seqdd)
# appendDDstruct("MountAchievedHA",seqdd)
# appendDDstruct("MountAchievedDEC",seqdd)
# appendDDstruct("MountAchievedAZ",seqdd)
# appendDDstruct("MountAchievedALT",seqdd)
# appendDDstruct("UTC",seqdd)
# appendDDstruct("LST",seqdd)
# appendDDstruct("MJDUTC",seqdd)
# appendDDstruct("Epoch",seqdd)
# appendDDstruct("ParAngle",seqdd)
# appendDDstruct("AirMass",seqdd)
# appendDDstruct("R_AchievedDECDMS",seqdd)
# appendDDstruct("L_AchievedDECDMS",seqdd)
# appendDDstruct("R_AchievedDEC",seqdd)
# appendDDstruct("L_AchievedDEC",seqdd)
# appendDDstruct("R_AchievedRAHMS",seqdd)
# appendDDstruct("L_AchievedRAHMS",seqdd)
# appendDDstruct("R_AchievedRA",seqdd)
# appendDDstruct("L_AchievedRA",seqdd)
# appendDDstruct("R_AchievedAZDMS",seqdd)
# appendDDstruct("L_AchievedAZDMS",seqdd)
# appendDDstruct("R_AchievedAZ",seqdd)
# appendDDstruct("L_AchievedAZ",seqdd)
# appendDDstruct("R_AchievedALTDMS",seqdd)
# appendDDstruct("L_AchievedALTDMS",seqdd)
# appendDDstruct("R_AchievedALT",seqdd)
# appendDDstruct("L_AchievedALT",seqdd)
# appendDDstruct("R_AchievedGALLDeg",seqdd)
# appendDDstruct("L_AchievedGALLDeg",seqdd)
# appendDDstruct("R_AchievedGALBDeg",seqdd)
# appendDDstruct("L_AchievedGALBDeg",seqdd)
# appendDDstruct("R_AZGain",seqdd)
# appendDDstruct("L_AZGain",seqdd)
# appendDDstruct("R_CA",seqdd)
# appendDDstruct("L_CA",seqdd)
# appendDDstruct("R_DECOffset",seqdd)
# appendDDstruct("L_DECOffset",seqdd)
# appendDDstruct("R_ELGain",seqdd)
# appendDDstruct("L_ELGain",seqdd)
# appendDDstruct("R_GSCumXPredmMeas",seqdd)
# appendDDstruct("L_GSCumXPredmMeas",seqdd)
# appendDDstruct("R_GSCumYPredmMeas",seqdd)
# appendDDstruct("L_GSCumYPredmMeas",seqdd)
# appendDDstruct("R_GSPresetDECDMS",seqdd)
# appendDDstruct("L_GSPresetDECDMS",seqdd)
# appendDDstruct("R_GSPresetRAHMS",seqdd)
# appendDDstruct("L_GSPresetRAHMS",seqdd)
# appendDDstruct("R_GSXMeasured",seqdd)
# appendDDstruct("L_GSXMeasured",seqdd)
# appendDDstruct("R_GSXPredicted",seqdd)
# appendDDstruct("L_GSXPredicted",seqdd)
# appendDDstruct("R_GSYMeasured",seqdd)
# appendDDstruct("L_GSYMeasured",seqdd)
# appendDDstruct("R_GSYPredicted",seqdd)
# appendDDstruct("L_GSYPredicted",seqdd)
# appendDDstruct("R_IA",seqdd)
# appendDDstruct("L_IA",seqdd)
# appendDDstruct("R_IE",seqdd)
# appendDDstruct("L_IE",seqdd)
# appendDDstruct("R_PointingModel",seqdd)
# appendDDstruct("L_PointingModel",seqdd)
# appendDDstruct("R_PosAngle",seqdd)
# appendDDstruct("L_PosAngle",seqdd)
# appendDDstruct("R_ParAngle",seqdd)
# appendDDstruct("L_ParAngle",seqdd)
# appendDDstruct("R_POXBase",seqdd)
# appendDDstruct("L_POXBase",seqdd)
# appendDDstruct("R_POXOffset",seqdd)
# appendDDstruct("L_POXOffset",seqdd)
# appendDDstruct("R_POXCurrent",seqdd)
# appendDDstruct("L_POXCurrent",seqdd)
# appendDDstruct("R_POYBase",seqdd)
# appendDDstruct("L_POYBase",seqdd)
# appendDDstruct("R_POYOffset",seqdd)
# appendDDstruct("L_POYOffset",seqdd)
# appendDDstruct("R_POYCurrent",seqdd)
# appendDDstruct("L_POYCurrent",seqdd)
# appendDDstruct("R_PORACurrent",seqdd)
# appendDDstruct("L_PORACurrent",seqdd)
# appendDDstruct("R_PODECCurrent",seqdd)
# appendDDstruct("L_PODECCurrent",seqdd)
# appendDDstruct("R_PORACurrentHMS",seqdd)
# appendDDstruct("L_PORACurrentHMS",seqdd)
# appendDDstruct("R_PODECCurrentDMS",seqdd)
# appendDDstruct("L_PODECCurrentDMS",seqdd)
# appendDDstruct("R_PresetParAngle",seqdd)
# appendDDstruct("L_PresetParAngle",seqdd)
# appendDDstruct("R_PresetPosAngle",seqdd)
# appendDDstruct("L_PresetPosAngle",seqdd)
# appendDDstruct("R_PresetRotMode",seqdd)
# appendDDstruct("L_PresetRotMode",seqdd)
# appendDDstruct("R_PresetTargetDECDMS",seqdd)
# appendDDstruct("L_PresetTargetDECDMS",seqdd)
# appendDDstruct("R_PresetTargetRAHMS",seqdd)
# appendDDstruct("L_PresetTargetRAHMS",seqdd)
# appendDDstruct("R_PresetTargetAZDMS",seqdd)
# appendDDstruct("L_PresetTargetAZDMS",seqdd)
# appendDDstruct("R_PresetTargetALTDMS",seqdd)
# appendDDstruct("L_PresetTargetALTDMS",seqdd)
# appendDDstruct("R_PresetTargetGALLDeg",seqdd)
# appendDDstruct("L_PresetTargetGALLDeg",seqdd)
# appendDDstruct("R_PresetTargetGALBDeg",seqdd)
# appendDDstruct("L_PresetTargetGALBDeg",seqdd)
# appendDDstruct("R_RAOffset",seqdd)
# appendDDstruct("L_RAOffset",seqdd)
# appendDDstruct("R_RotAngle",seqdd)
# appendDDstruct("L_RotAngle",seqdd)
# appendDDstruct("R_RotCenterDECDMS",seqdd)
# appendDDstruct("L_RotCenterDECDMS",seqdd)
# appendDDstruct("R_RotCenterDEC",seqdd)
# appendDDstruct("L_RotCenterDEC",seqdd)
# appendDDstruct("R_RotCenterRAHMS",seqdd)
# appendDDstruct("L_RotCenterRAHMS",seqdd)
# appendDDstruct("R_RotCenterRA",seqdd)
# appendDDstruct("L_RotCenterRA",seqdd)
# appendDDstruct("R_RotDemandPosition",seqdd)
# appendDDstruct("L_RotDemandPosition",seqdd)
# appendDDstruct("R_RotMode",seqdd)
# appendDDstruct("L_RotMode",seqdd)
# appendDDstruct("R_TargetDEC",seqdd)
# appendDDstruct("L_TargetDEC",seqdd)
# appendDDstruct("R_TargetParAngle",seqdd)
# appendDDstruct("L_TargetParAngle",seqdd)
# appendDDstruct("R_TargetRA",seqdd)
# appendDDstruct("L_TargetRA",seqdd)
# appendDDstruct("NonSiderealTarget",seqdd)
# appendDDstruct("R_NSRATRKRate",seqdd)
# appendDDstruct("L_NSRATRKRate",seqdd)
# appendDDstruct("R_NSDECTRKRate",seqdd)
# appendDDstruct("L_NSDECTRKRate",seqdd)
# appendDDstruct("R_NSTRKEpoch",seqdd)
# appendDDstruct("L_NSTRKEpoch",seqdd)
# appendDDstruct("R_NSTRKEquinox",seqdd)
# appendDDstruct("L_NSTRKEquinox",seqdd)
# appendDDstruct("R_NSTRKFrame",seqdd)
# appendDDstruct("L_NSTRKFrame",seqdd)
# appendDDstruct("R_NSEphemerisName",seqdd)
# appendDDstruct("L_NSEphemerisName",seqdd)
# appendDDstruct("R_NSType",seqdd)
# appendDDstruct("L_NSType",seqdd)
# appendDDstruct("R_M1X",seqdd)
# appendDDstruct("L_M1X",seqdd)
# appendDDstruct("R_M1Y",seqdd)
# appendDDstruct("L_M1Y",seqdd)
# appendDDstruct("R_M1Z",seqdd)
# appendDDstruct("L_M1Z",seqdd)
# appendDDstruct("R_M1Rx",seqdd)
# appendDDstruct("L_M1Rx",seqdd)
# appendDDstruct("R_M1Ry",seqdd)
# appendDDstruct("L_M1Ry",seqdd)
# appendDDstruct("R_M1Rz",seqdd)
# appendDDstruct("L_M1Rz",seqdd)
# appendDDstruct("R_M1AirTemp",seqdd)
# appendDDstruct("L_M1AirTemp",seqdd)
# appendDDstruct("R_M1GlassTemp",seqdd)
# appendDDstruct("L_M1GlassTemp",seqdd)
# appendDDstruct("R_M1TargetTemp",seqdd)
# appendDDstruct("L_M1TargetTemp",seqdd)
# appendDDstruct("R_M1CollX",seqdd)
# appendDDstruct("L_M1CollX",seqdd)
# appendDDstruct("R_M1CollY",seqdd)
# appendDDstruct("L_M1CollY",seqdd)
# appendDDstruct("R_M1CollZ",seqdd)
# appendDDstruct("L_M1CollZ",seqdd)
# appendDDstruct("R_M1CollRx",seqdd)
# appendDDstruct("L_M1CollRx",seqdd)
# appendDDstruct("R_M1CollRy",seqdd)
# appendDDstruct("L_M1CollRy",seqdd)
# appendDDstruct("R_M1CollRz",seqdd)
# appendDDstruct("L_M1CollRz",seqdd)
# appendDDstruct("R_M1CollTemp",seqdd)
# appendDDstruct("L_M1CollTemp",seqdd)
# appendDDstruct("R_M1CollTemp2",seqdd)
# appendDDstruct("L_M1CollTemp2",seqdd)
# appendDDstruct("R_M1ActOptX",seqdd)
# appendDDstruct("L_M1ActOptX",seqdd)
# appendDDstruct("R_M1ActOptY",seqdd)
# appendDDstruct("L_M1ActOptY",seqdd)
# appendDDstruct("R_M1ActOptZ",seqdd)
# appendDDstruct("L_M1ActOptZ",seqdd)
# appendDDstruct("R_M1ActOptRx",seqdd)
# appendDDstruct("L_M1ActOptRx",seqdd)
# appendDDstruct("R_M1ActOptRy",seqdd)
# appendDDstruct("L_M1ActOptRy",seqdd)
# appendDDstruct("R_M1ActOptRz",seqdd)
# appendDDstruct("L_M1ActOptRz",seqdd)
# appendDDstruct("R_M1Mode1OffX",seqdd)
# appendDDstruct("L_M1Mode1OffX",seqdd)
# appendDDstruct("R_M1Mode1OffY",seqdd)
# appendDDstruct("L_M1Mode1OffY",seqdd)
# appendDDstruct("R_M1Mode1OffZ",seqdd)
# appendDDstruct("L_M1Mode1OffZ",seqdd)
# appendDDstruct("R_M1Mode1OffRx",seqdd)
# appendDDstruct("L_M1Mode1OffRx",seqdd)
# appendDDstruct("R_M1Mode1OffRy",seqdd)
# appendDDstruct("L_M1Mode1OffRy",seqdd)
# appendDDstruct("R_M1Mode1OffRz",seqdd)
# appendDDstruct("L_M1Mode1OffRz",seqdd)
# appendDDstruct("R_M1Mode1ManX",seqdd)
# appendDDstruct("L_M1Mode1ManX",seqdd)
# appendDDstruct("R_M1Mode1ManY",seqdd)
# appendDDstruct("L_M1Mode1ManY",seqdd)
# appendDDstruct("R_M1Mode1ManZ",seqdd)
# appendDDstruct("L_M1Mode1ManZ",seqdd)
# appendDDstruct("R_M1Mode1ManRx",seqdd)
# appendDDstruct("L_M1Mode1ManRx",seqdd)
# appendDDstruct("R_M1Mode1ManRy",seqdd)
# appendDDstruct("L_M1Mode1ManRy",seqdd)
# appendDDstruct("R_M1Mode1ManRz",seqdd)
# appendDDstruct("L_M1Mode1ManRz",seqdd)
# appendDDstruct("R_M1Z2",seqdd)
# appendDDstruct("L_M1Z2",seqdd)
# appendDDstruct("R_M1Z3",seqdd)
# appendDDstruct("L_M1Z3",seqdd)
# appendDDstruct("R_M1Z4",seqdd)
# appendDDstruct("L_M1Z4",seqdd)
# appendDDstruct("R_M1Z5",seqdd)
# appendDDstruct("L_M1Z5",seqdd)
# appendDDstruct("R_M1Z6",seqdd)
# appendDDstruct("L_M1Z6",seqdd)
# appendDDstruct("R_M1Z7",seqdd)
# appendDDstruct("L_M1Z7",seqdd)
# appendDDstruct("R_M1Z8",seqdd)
# appendDDstruct("L_M1Z8",seqdd)
# appendDDstruct("R_M1Z9",seqdd)
# appendDDstruct("L_M1Z9",seqdd)
# appendDDstruct("R_M1Z10",seqdd)
# appendDDstruct("L_M1Z10",seqdd)
# appendDDstruct("R_M1Z11",seqdd)
# appendDDstruct("L_M1Z11",seqdd)
# appendDDstruct("R_M1Z12",seqdd)
# appendDDstruct("L_M1Z12",seqdd)
# appendDDstruct("R_M1Z13",seqdd)
# appendDDstruct("L_M1Z13",seqdd)
# appendDDstruct("R_M1Z14",seqdd)
# appendDDstruct("L_M1Z14",seqdd)
# appendDDstruct("R_M1Z15",seqdd)
# appendDDstruct("L_M1Z15",seqdd)
# appendDDstruct("R_M1Z16",seqdd)
# appendDDstruct("L_M1Z16",seqdd)
# appendDDstruct("R_M1Z17",seqdd)
# appendDDstruct("L_M1Z17",seqdd)
# appendDDstruct("R_M1Z18",seqdd)
# appendDDstruct("L_M1Z18",seqdd)
# appendDDstruct("R_M1Z19",seqdd)
# appendDDstruct("L_M1Z19",seqdd)
# appendDDstruct("R_M1Z20",seqdd)
# appendDDstruct("L_M1Z20",seqdd)
# appendDDstruct("R_M1Z21",seqdd)
# appendDDstruct("L_M1Z21",seqdd)
# appendDDstruct("R_M1Z22",seqdd)
# appendDDstruct("L_M1Z22",seqdd)
# appendDDstruct("R_M2CollX",seqdd)
# appendDDstruct("L_M2CollX",seqdd)
# appendDDstruct("R_M2CollY",seqdd)
# appendDDstruct("L_M2CollY",seqdd)
# appendDDstruct("R_M2CollZ",seqdd)
# appendDDstruct("L_M2CollZ",seqdd)
# appendDDstruct("R_M2CollRx",seqdd)
# appendDDstruct("L_M2CollRx",seqdd)
# appendDDstruct("R_M2CollRy",seqdd)
# appendDDstruct("L_M2CollRy",seqdd)
# appendDDstruct("R_M2CollRz",seqdd)
# appendDDstruct("L_M2CollRz",seqdd)
# appendDDstruct("R_M2CollTemp",seqdd)
# appendDDstruct("L_M2CollTemp",seqdd)
# appendDDstruct("R_M2ActOptX",seqdd)
# appendDDstruct("L_M2ActOptX",seqdd)
# appendDDstruct("R_M2ActOptY",seqdd)
# appendDDstruct("L_M2ActOptY",seqdd)
# appendDDstruct("R_M2ActOptZ",seqdd)
# appendDDstruct("L_M2ActOptZ",seqdd)
# appendDDstruct("R_M2ActOptRx",seqdd)
# appendDDstruct("L_M2ActOptRx",seqdd)
# appendDDstruct("R_M2ActOptRy",seqdd)
# appendDDstruct("L_M2ActOptRy",seqdd)
# appendDDstruct("R_M2ActOptRz",seqdd)
# appendDDstruct("L_M2ActOptRz",seqdd)
# appendDDstruct("R_M2Mode1OffX",seqdd)
# appendDDstruct("L_M2Mode1OffX",seqdd)
# appendDDstruct("R_M2Mode1OffY",seqdd)
# appendDDstruct("L_M2Mode1OffY",seqdd)
# appendDDstruct("R_M2Mode1OffZ",seqdd)
# appendDDstruct("L_M2Mode1OffZ",seqdd)
# appendDDstruct("R_M2Mode1OffRx",seqdd)
# appendDDstruct("L_M2Mode1OffRx",seqdd)
# appendDDstruct("R_M2Mode1OffRy",seqdd)
# appendDDstruct("L_M2Mode1OffRy",seqdd)
# appendDDstruct("R_M2Mode1OffRz",seqdd)
# appendDDstruct("L_M2Mode1OffRz",seqdd)
# appendDDstruct("R_M2Mode1ManX",seqdd)
# appendDDstruct("L_M2Mode1ManX",seqdd)
# appendDDstruct("R_M2Mode1ManY",seqdd)
# appendDDstruct("L_M2Mode1ManY",seqdd)
# appendDDstruct("R_M2Mode1ManZ",seqdd)
# appendDDstruct("L_M2Mode1ManZ",seqdd)
# appendDDstruct("R_M2Mode1ManRx",seqdd)
# appendDDstruct("L_M2Mode1ManRx",seqdd)
# appendDDstruct("R_M2Mode1ManRy",seqdd)
# appendDDstruct("L_M2Mode1ManRy",seqdd)
# appendDDstruct("R_M2Mode1ManRz",seqdd)
# appendDDstruct("L_M2Mode1ManRz",seqdd)
# appendDDstruct("R_M3CollTip",seqdd)
# appendDDstruct("L_M3CollTip",seqdd)
# appendDDstruct("R_M3CollTilt",seqdd)
# appendDDstruct("L_M3CollTilt",seqdd)
# appendDDstruct("R_M3CollPiston",seqdd)
# appendDDstruct("L_M3CollPiston",seqdd)
# appendDDstruct("R_M3CollSel",seqdd)
# appendDDstruct("L_M3CollSel",seqdd)
# appendDDstruct("R_M3CollTemp",seqdd)
# appendDDstruct("L_M3CollTemp",seqdd)
# appendDDstruct("R_AOBadSeeing",seqdd)
# appendDDstruct("L_AOBadSeeing",seqdd)
# appendDDstruct("R_AOShape",seqdd)
# appendDDstruct("L_AOShape",seqdd)
# appendDDstruct("R_AOOffsetX",seqdd)
# appendDDstruct("L_AOOffsetX",seqdd)
# appendDDstruct("R_AOOffsetY",seqdd)
# appendDDstruct("L_AOOffsetY",seqdd)
# appendDDstruct("R_AOOffsetZ",seqdd)
# appendDDstruct("L_AOOffsetZ",seqdd)
# appendDDstruct("R_AOmode",seqdd)
# appendDDstruct("L_AOmode",seqdd)
# appendDDstruct("R_AORefMag",seqdd)
# appendDDstruct("L_AORefMag",seqdd)
# appendDDstruct("R_AORefCindex",seqdd)
# appendDDstruct("L_AORefCindex",seqdd)
# appendDDstruct("R_AORefX",seqdd)
# appendDDstruct("L_AORefX",seqdd)
# appendDDstruct("R_AORefY",seqdd)
# appendDDstruct("L_AORefY",seqdd)
# appendDDstruct("R_AOdx",seqdd)
# appendDDstruct("L_AOdx",seqdd)
# appendDDstruct("R_AOdy",seqdd)
# appendDDstruct("L_AOdy",seqdd)
# appendDDstruct("R_AOfreq",seqdd)
# appendDDstruct("L_AOfreq",seqdd)
# appendDDstruct("R_AOgain",seqdd)
# appendDDstruct("L_AOgain",seqdd)
# appendDDstruct("R_AOmag",seqdd)
# appendDDstruct("L_AOmag",seqdd)
# appendDDstruct("R_AOnbins",seqdd)
# appendDDstruct("L_AOnbins",seqdd)
# appendDDstruct("R_AOnmodes",seqdd)
# appendDDstruct("L_AOnmodes",seqdd)
# appendDDstruct("R_AOr0",seqdd)
# appendDDstruct("L_AOr0",seqdd)
# appendDDstruct("R_AOslnull",seqdd)
# appendDDstruct("L_AOslnull",seqdd)
# appendDDstruct("R_AOsnmode",seqdd)
# appendDDstruct("L_AOsnmode",seqdd)
# appendDDstruct("R_AOttmodul",seqdd)
# appendDDstruct("L_AOttmodul",seqdd)
# appendDDstruct("R_AOStatus",seqdd)
# appendDDstruct("L_AOStatus",seqdd)
# appendDDstruct("R_AOCorrectedModes",seqdd)
# appendDDstruct("L_AOCorrectedModes",seqdd)
# appendDDstruct("R_AOMode",seqdd)
# appendDDstruct("L_AOMode",seqdd)
# appendDDstruct("R_AOslReady",seqdd)
# appendDDstruct("L_AOslReady",seqdd)
# appendDDstruct("R_AOaoReady",seqdd)
# appendDDstruct("L_AOaoReady",seqdd)
# appendDDstruct("R_AOLoopOn",seqdd)
# appendDDstruct("L_AOLoopOn",seqdd)
# appendDDstruct("R_AOStrehl",seqdd)
# appendDDstruct("L_AOStrehl",seqdd)
# appendDDstruct("R_AOFLAOWccdBin",seqdd)
# appendDDstruct("L_AOFLAOWccdBin",seqdd)
# appendDDstruct("R_AOFLAOWccdFreq",seqdd)
# appendDDstruct("L_AOFLAOWccdFreq",seqdd)
# appendDDstruct("R_AOFLAOWmodAmp",seqdd)
# appendDDstruct("L_AOFLAOWmodAmp",seqdd)
# appendDDstruct("R_AOFLAOWcounts",seqdd)
# appendDDstruct("L_AOFLAOWcounts",seqdd)
# appendDDstruct("R_AOLBTIWccdBin",seqdd)
# appendDDstruct("L_AOLBTIWccdBin",seqdd)
# appendDDstruct("R_AOLBTIWccdFreq",seqdd)
# appendDDstruct("L_AOLBTIWccdFreq",seqdd)
# appendDDstruct("R_AOLBTIWmodAmp",seqdd)
# appendDDstruct("L_AOLBTIWmodAmp",seqdd)
# appendDDstruct("R_AOLBTIWcounts",seqdd)
# appendDDstruct("L_AOLBTIWcounts",seqdd)
# appendDDstruct("R_AOOffloadY",seqdd)
# appendDDstruct("L_AOOffloadY",seqdd)
# appendDDstruct("R_AOOffloadX",seqdd)
# appendDDstruct("L_AOOffloadX",seqdd)
# appendDDstruct("R_AOOffloadZ",seqdd)
# appendDDstruct("L_AOOffloadZ",seqdd)
# appendDDstruct("R_AnemTimeStamp",seqdd)
# appendDDstruct("L_AnemTimeStamp",seqdd)
# appendDDstruct("R_AnemWindAvg1s",seqdd)
# appendDDstruct("L_AnemWindAvg1s",seqdd)
# appendDDstruct("R_AnemWindAvg10s",seqdd)
# appendDDstruct("L_AnemWindAvg10s",seqdd)
# appendDDstruct("R_AnemWindAvg1m",seqdd)
# appendDDstruct("L_AnemWindAvg1m",seqdd)
