PACKER

PIC Analog to/from Network Packet Application Macro.

PACKER - PIC Analog to/from Network Packet Application Macro 

<CARD>   - ICEPIC card name
<FLAGS>  - Optional run-time flags
<CONFIG> - Configuration table (snapapp uses this)
<CFGFN>  - Port Configuration filename 

This macro runs multiple IO Modules (typically A2Ds|D2As) with optional 
DDCs|DUCs on a DevIce with embedded network ports (PAC,sPAC,Tray,RfPAC) to
convert Analog to/from network packets with precision timing.

The supported packet types are as follows:
  None	- temporarily disable packet output
  ICE	- ICE 64by header used in Midas circles
  SDDS	- SDDS 56by header defined by USG
  VRT	- Vita49 32by header (+trailer) (BE header, LE data)
  VRTL	- Vita49 24by header (-trailer) for easier handling in CPU (LE data)
  VRTW	- Vita49 24by header (-trailer) for WW program
  VRTX	- Vita49 24by header (+trailer) for AST standard
  VRTD	- Vita49 28by header (-trailer) for DIFI standard

PACKER uses many of the same control parameters as the SNAPPER and SENSOR macros with 
the additional network parameters:
 
gcontrol label  "FUNC"   "Function"
gcontrol choice "MODE"   "Operation  " "Setup,Process,Exit" lmode  /nc=1
gcontrol choice "AGCM"   "AGC Mode   " "Off,WB,NB,WB+NB" agcdef
gcontrol choice "XCVR"   "Xcvr Status" "Locked,Fault,None,ReCenterIF,Status" "None"
gcontrol lval   "CHAN"   "Chan"  0 0 ntc 1

gcontrol label  "CFG1"   "Module-1"
gcontrol tval   "TIME1"  "TC" time 1 -1 1  /edit=f
gcontrol dval   "MFREQ1" "IF Freq" rffreq 1 -1 1 /fmt="#0.000" /units="MHz"
gcontrol lval   "MGAIN1" "IF Gain" rfgain -33 30 1 /units="dB"
gcontrol lval   "ADLM1"  "Loading" -48 -48 0 1  /edit=f /vumeter
gcontrol dval   "QFREQ1" "MrkFreq" 0 1 -1 1 /fmt="#0.000" /units="MHz" /edit=f
  
gcontrol label  "CFG2"   "Module-2"
gcontrol tval   "TIME2"  "TC" time 1 -1 1  /edit=f
gcontrol dval   "MFREQ2" "IF Freq" rffreq 1 -1 1 /fmt="#0.000" /units="MHz"
gcontrol lval   "MGAIN2" "IF Gain" rfgain -33 30 1 /units="dB"
gcontrol lval   "ADLM2"  "Loading" -48 -48 0 1  /edit=f /vumeter
gcontrol dval   "QFREQ2" "MrkFreq" 0 1 -1 1 /fmt="#0.000" /units="MHz" /edit=f

gcontrol label  "CONF"   "Configuration"
gcontrol choice "CARD"   "Card Alias " "PIC1AUTO,PIC2AUTO,PICxAUTO" card /input
gcontrol choice "CLOCK"  "Clock Src  " "P,PX" "P"
gcontrol choice "FORMAT" "Format     " "CB,CJ,CI" "CI"
gcontrol dval   "LENGTH" "Length     " 1.0 0.1 10 1
gcontrol choice "PKTTYP" "Packet Type" "None,ICE,SDDS,VRT,VRTL,VRTW,VRTX,VRTX2" "VRTL"
gcontrol choice "PKTLEN" "Packet Size" "1K,2K,4K,8K" "1K"
gcontrol lval  "PKTPORT" "Packet Port" 7000 5000 9000 100
gcontrol prompt "OUID"   "Vita OUID  " "0x101D77"
gcontrol choice "VCTX"   "Vita CTX   " vctxlist "None" /toggle
gcontrol choice "VFCMA"  "Vita FCMA  " "None,+0.0.0.1,+0.0.1.0,+0.1.0.0,+1.0.0.0" "None" /input
gcontrol lval   "AGCL"   "IFLoading  " -9 -18 -3 1 /units="dB"
gcontrol lval   "MING"   "MinIFGain  " -18 1 -1 1  /units="dB"
gcontrol lval   "MAXG"   "MaxIFGain  " 30 1 -1 1  /units="dB"
gcontrol lval   "AGCLN"  "NBLoading  " -30 -60 -3 1 /units="dB"
gcontrol lval   "MINGN"  "MinNBGain  " -6 1 -1 1  /units="dB"
gcontrol lval   "MAXGN"  "MaxNBGain  " 14 1 -1 1  /units="dB"
gcontrol dval   "AGCW"   "Hysteresis " 1 0 6 1   /units="dB"
gcontrol file   "CFGFN"  "CfgFn" cfgfn "packcfg_*"
gcontrol choice "CONFIG" "Configure" "Done,Save,Load,Reload,Trim,Def,Tray,RfPac" "Done" /nc=3

gcontrol label  "DISP"   "Displays" 0
gcontrol choice "NFFT"   "Fft Size  " "1K,2K,4K,8K,16K,32k,64K" "4K" /input
gcontrol choice "PSDR"   "Disp Rate " "5,10,25,50,100" "25" /units="Hz" /input
gcontrol choice "PSDA"   "Disp Avg  " "1,5,10,20" "5" /units="Frames" /input
gcontrol lval   "EXPA"   "Expn Avg  " 5 0 100 1 /units="Frames"
gcontrol lval   "WBSCL"  "WB PSD Scale" 20 -80 100 10 /units="dB"
gcontrol lval   "WBRNG"  "WB PSD Range" 80  30 100 10 /units="dB"
gcontrol lval   "NBSCL"  "NB PSD Scale" 20 -80 100 10 /units="dB"
gcontrol lval   "NBRNG"  "NB PSD Range" 80  30 100 10 /units="dB"

gcontrol label  "SYS"    "System" 0
gcontrol prompt "FLAGS"  "Flags " ""
gcontrol prompt "AFLAGS" "aFlags" aflags
gcontrol choice "WAVE"   "Waveform" waves "TWOT" /input

gcontrol choice "ACTION" "Action" "Monitor,Process,Rec/PB,Stop,Config,Exit,ExitNow"
gcontrol pipe   "PMON"   "Pipes"

These can be set by the GUI, snapapp table file, or text setup file packset.tbl.
The current parameters are remembered in the packset results table entry.

These can be controlled remotely by sending a SET message via icenet:
  icenet SET <hostaddr> {PKTTYP=VRTL,PKTLEN=4K}
where the key in the key=value pairs are one of the gcontrol names described above.
If using a browser to form the network request, the POST would have the form:
  http://<host>:<port>/Controls/Set?{PKTTYP=VRTL,PKTLEN=4K}


Indiviual channel parameters are setup by a seperate configuration file.
This is a text file with tab seperated columns of the format:

CHN	ENA	IOM	QSFP	ADDR		SID	FMT	RATE	FREQ	BW	GAIN	XATN	XCVR
iMod1	On	1	1.1	224.0.0.1	100A	CI	480	820.0	400	20	15	AR26-ar
iMod2	On	2	2.1	224.0.0.2	100B	CI	480	820.0	400	20	15	AR26-ar
iTun1	Pkt	1	1.5	224.0.1.1	101A	CI	24	820.0	12.5	0
iTun2	Pkt	2	2.5	224.0.1.2	101B	CI	24	820.0	12.5	0
iTun3	Pkt	1	1.6	224.0.2.1	102A	CI	20	1150.0	10	0
iTun4	Pkt	2	2.6	224.0.2.2	102B	CI	20	1150.0	10	0
iTun5	Off	1	1.7	224.0.3.1	103A	CI	30	890.0	15.0	0
iTun6	Off	2	2.7	224.0.3.2	103B	CI	30	890.0	15.0	0
iTun7	Off	1	1.8	224.0.4.1	104A	CI	60	930.0	27.5	0
iTun8	Off	2	2.8	224.0.4.2	104B	CI	60	930.0	27.5	0
oMod1	On	1	1.1	224.0.0.1	100A	CI	480	820.0	400	20	15	AT18-at
oMod2	On	2	2.1	224.0.0.2	100B	CI	480	820.0	400	20	15	AT18-at
oTun1	Pkt	1	1.5	224.0.1.1	101A	CI	24	820.0	12.5	0
oTun2	Pkt	2	2.5	224.0.1.2	101B	CI	24	820.0	12.5	0
oTun3	Pkt	1	1.6	224.0.2.1	102A	CI	20	1150.0	10	0
oTun4	Pkt	2	2.6	224.0.2.2	102B	CI	20	1150.0	10	0
oTun5	Off	1	1.7	224.0.3.1	103A	CI	30	890.0	15.0	0
oTun6	Off	2	2.7	224.0.3.2	103B	CI	30	890.0	15.0	0
oTun7	Gen	1	1.8	224.0.4.1	104A	CI	60	930.0	27.5	0
oTun8	Gen	2	2.8	224.0.4.2	104B	CI	60	930.0	27.5	0

The CHN field specifies the resource on the card.
 iModX: Input module
 oModX: Output module
 iTunX: Digital tuner behind an input module
 oTunX: Digital tuner in front of an output module
The ENA field enables different real-time functions 
 Off:	Disables the channel
 On:	Enables the channel
 Pkt:	Enables the channel with network in/output
 Gen:	Generates a test signal
 Tst:	Plots a test signal at the 1 PPS trigger
The IOM field specifies the I/O Module index 
 Note:  Odd numbered tuners must be paired with odd numbered modules
The QSFP field specifies the QSFP fiber number and virtual channel number
 Tray:	has 1-8 10G fibres with 4 virtual channels in each
 RfPac:	has 1-2 100G fibres with 16 virtual channels in each
The ADDR field specifies the multicast address for this channel
The SID field specifies the Vita49 Stream ID
The FMT field specifies the Midas data format digraph
The RATE field specifies the samplerate in MHz
The FREQ field specifies the center frequency in MHz
The BW field specifies the bandwidth in MHz
The GAIN field specifies the gain in dB
The XATN field specifies the RF front end attenuation to use
The XCVR field specifies the RF front end alias to use

These can be controlled remotely by sending a SETCFG message via icenet:
  icenet MSG <hostaddr> {NAME=SETCFG,INFO=-1,DATA={CHN=iTun1,IOM=3,FREQ=1000,RATE=12.5,BW=10,GAIN=-5,QSFP=1.2}}
or queried by sending a GETCFG message:
  icenet MSGR <hostaddr> {NAME=GETCFG,INFO=-1}
where the key in the key=value pairs are one of the column key described above.
The info field is the one based row number. Row=0 affects all rows. Row=-1 uses the CHN field to select the row.

If using a browser to form the network request, the POST would have the form:
  http://<host>:<port>/Message/Send?{NAME=SETCFG,INFO=-1,DATA={CHN=iMod3,FREQ=1010,GAIN=-6}}
or
  http://<host>:<port>/Message/Recv?{NAME=GETCFG,INFO=-1}

To load an entirely new configuration file:
  icenet SET <hostaddr> {CFGFN=packcfg_mycfg,CONFIG=load}
and to start the macro processing:
  icenet SET <hostaddr> {MODE=process}

To query the QSFP stats, use the iceserver at port 8080 with the command
  icenet MSGR <hostaddr:8080> {NAME=GETQSTAT,INFO=<isfp>}
or 
  http://<host>:8080/Message/Recv?{NAME=GETQSTAT,INFO=<isfp>}

If using a browser to form the network request, the POST would have the form:
  http://<host>:<port>/Controls/Set?{CFGFN=packcfg_mycfg,CONFIG=load}
  http://<host>:<port>/Controls/Set?{MODE=process}

By default Vita-49 packets are filtered by OUID and SID. Setting either to -1 accepts any.
The ICE Organizational Unique ID for Vita49 packets is 0x101D77.  The DIFI OUID is 0x6A621E.
Setting the OUID=0 will use these default fixed values.  An OUID>0 will adopt that value.

The Vita49 DIFI standard for control flow on analog playback can be enabled with the
VFCMA (Vita Flow Control Multicast Address) parameter.  This is either a full multicast
or unicast address or if preceded by a + or - is added/subtracted from that channel's
packet data address.

If Unicast addresses are used, the targets must be named in the /var/etc/arptbl. Ex:
  192.168.1.123 dev eth0 lladdr aa:bb:cc:dd:ee:ff PERMANENT
  192.168.2.123 dev eth0 lladdr 56:bb:cc:dd:ee:ff PERMANENT

If the /SAP switch is applied in playback mode, special code is enabled to synchronize the
analog playback to the timecode in the packet headers. This is currently only supported 
in the Vita49 formats.  The data must arrive at the device with ample time and duration 
to flush buffers.  It need not be continuous.

If the bitrate exceeds a single fiber in ACQ mode, the packets are split across the fibers 
on the same QSFP. To force this mode, add the flags MUXGBE=2 or MUXGBE=4 in the GUI or in 
the config file.  To run the highest bandwidth mode, 750 MHz 16 bit, the 2nd channel must 
be deactivated using the ENA flag in the channel list or by applying the /ntc=1 switch.

The VCTX bitmask field is used to handle the Vita49 context packets.

The fields for timing the context output packets are:
  OnSec	- At the earliest time between packets after a 1 second rollover
  OnChx	- When a context parameter changes
  dSec	- deciSecond. Every 100 mSec
  cSec	- centiSecond. Every 10 mSec
  mSec	- milliSecond. Every 1 mSec
The fields to by output are:
  BW	- Bandwidth
  IF	- IF tuning 
  RF	- RF tuning 
  REFL	- Reference Level
  GAIN	- Gain setting
  SR	- Sample Rate
  TEMP	- Temperature
  FMT	- Data Format
  GPS	- (Not supported yet)
The fields for handling context input packets:
  xSR	- dynamic input sample rate change 
  xIF	- dynamic input IF change 
  xRF	- dynamic input RF change 
  xGAIN	- dynamic input Gain change 
These dynamic change fields only affect behavior when the UDUC core is in the path.

Messages:
  GETCFG	- gets the configuration of INFO=row as a key=value table
  SETCFG	- sets the configuration of INFO=row as a key=value table (row=0 is all rows, row=-1 uses CHN)

Switches:
  /SAP		- Synchronize Analog Playback to packet timecode
  /TC=tcm	- Time Code Mode (CPUp0) 
  /QSFPLOOP	- redress QSFP column to support loopback QSFP cable test mode
  /TESTLOOP=n	- special test mode to test /SAP timecode accuracy