#! /usr/bin/env python


from jwql.edb import engineering_database as ed
from astropy.time import Time

start = Time('2021-09-28T00:00:00')
end = Time('2021-09-29T00:00:00')

miri_menonics = [
'SE_ZIMIRICEA',
'SE_ZBUSVLT',
'IMIR_HK_ICE_SEC_VOLT4',
'IGDP_MIR_ICE_INTER_TEMP',
#'SI_GZMPT1AK',
'ST_ZTC1MIRIA',
'IGDP_MIR_ICE_T1P_CRYO',
'IGDP_MIR_ICE_T2R_CRYO',
'IGDP_MIR_ICE_T3LW_CRYO',
'IGDP_MIR_ICE_T4SW_CRYO',
'IGDP_MIR_ICE_T5IMG_CRYO',
'IGDP_MIR_ICE_T6DECKCRYO',
'IGDP_MIR_ICE_T7IOC_CRYO',
'IGDP_MIR_ICE_FW_CRYO',
'IGDP_MIR_ICE_CCC_CRYO',
'IGDP_MIR_ICE_GW14_CRYO',
'IGDP_MIR_ICE_GW23_CRYO',
'IGDP_MIR_ICE_POMP_CRYO',
'IGDP_MIR_ICE_POMR_CRYO',
'IGDP_MIR_ICE_IFU_CRYO',
'IGDP_MIR_ICE_IMG_CRYO',
'SE_ZIMIRFPEA',
'IMIR_PDU_V_DIG_5V',
'IMIR_PDU_I_DIG_5V',
'IMIR_PDU_V_ANA_5V',
'IMIR_PDU_I_ANA_5V',
'IMIR_PDU_V_ANA_N5V',
'IMIR_PDU_I_ANA_N5V',
'IMIR_PDU_V_ANA_7V',
'IMIR_PDU_I_ANA_7V',
'IMIR_PDU_V_ANA_N7V',
'IMIR_PDU_I_ANA_N7V',
'IMIR_SPW_V_DIG_2R5V',
'IMIR_PDU_V_REF_2R5V',
'IGDP_MIR_IC_V_VDETCOM',
'IGDP_MIR_SW_V_VDETCOM',
'IGDP_MIR_LW_V_VDETCOM',
'IGDP_MIR_IC_V_VSSOUT',
'IGDP_MIR_SW_V_VSSOUT',
'IGDP_MIR_LW_V_VSSOUT',
'IGDP_MIR_IC_V_VRSTOFF',
'IGDP_MIR_SW_V_VRSTOFF',
'IGDP_MIR_LW_V_VRSTOFF',
'IGDP_MIR_IC_V_VP',
'IGDP_MIR_SW_V_VP',
'IGDP_MIR_LW_V_VP',
'IGDP_MIR_IC_V_VDDUC',
'IGDP_MIR_SW_V_VDDUC',
'IGDP_MIR_LW_V_VDDUC',
'IMIR_PDU_TEMP',
#'SI_GZMPT2AK',
'ST_ZTC2MIRIA',
'IMIR_IC_SCE_ANA_TEMP1',
'IMIR_SW_SCE_ANA_TEMP1',
'IMIR_LW_SCE_ANA_TEMP1',
'IMIR_IC_SCE_DIG_TEMP',
'IMIR_SW_SCE_DIG_TEMP',
'IMIR_LW_SCE_DIG_TEMP',
'IGDP_MIR_IC_DET_TEMP',
'IGDP_MIR_LW_DET_TEMP',
'IGDP_MIR_SW_DET_TEMP',
'IMIR_HK_ICE_SEC_VOLT1',
'IMIR_HK_ICE_SEC_VOLT2',
'IMIR_HK_ICE_SEC_VOLT3',
'IMIR_HK_ICE_SEC_VOLT4',
'SE_ZIMIRICEA',
'IMIR_HK_FW_POS_VOLT',
'IMIR_HK_FW_POS_RATIO',
'IMIR_HK_FW_CUR_POS',
'IMIR_HK_GW14_POS_VOLT',
'IMIR_HK_GW14_POS_RATIO',
'IMIR_HK_GW14_CUR_POS',
'IMIR_HK_GW23_POS_VOLT',
'IMIR_HK_GW23_POS_RATIO',
'IMIR_HK_GW23_CUR_POS',
'IMIR_HK_CCC_POS_VOLT',
'IMIR_HK_CCC_POS_RATIO',
'IMIR_HK_CCC_CUR_POS',
'IMIR_HK_CCC_ACTUATOR']

change_only = []
all_points = []
for miri in miri_menonics:
    m = ed.get_mnemonic(miri, start, end)
    print(miri, len(m))
    info = m.meta['TlmMnemonics'][0]['AllPoints']
    if info == 0:
        change_only.append(miri)
    elif info == 1:
        all_points.append(miri)
    else:
        stop

print('CHANGE ONLY:')
for c in change_only:
    print(c)
print('\n\nALL POINTS:')
for c in all_points:
    print(c)
