//  ==========================================================================
//  
//  @(#) $Id: test1.C,v 1.4 2000/10/19 03:21:57 brian Exp $
//  
//  --------------------------------------------------------------------------
//  
//  Copyright (C) 1997-2000  Brian Bidulock <bidulock@dallas.net>
//  
//  All Rights Reserved.
//  
//  This library is free software; you can redistribute it and/or modify it
//  under the terms of the GNU Lesser General Public License as published by
//  the Free Software Foundation; either version 2.1 of the License, or (at
//  your option) any later version.
//  
//  This library is distributed in the hope that it will be useful, but
//  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
//  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser Public License
//  for more details.
//  
//  You should have received a copy of the GNU Lesser General Public License
//  along with this library; if not, write to the Free Software Foundation,
//  Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
// 
//  Last Modified $Date: 2000/10/19 03:21:57 $ by $Author: brian $
// 
//  --------------------------------------------------------------------------
// 
//  $Log: test1.C,v $
//  Revision 1.4  2000/10/19 03:21:57  brian
//  Whoops, messed up when adding headers.
//
//  Revision 1.3  2000/10/13 15:45:51  brian
//  First public release.
//
//  ==========================================================================

static char const ident[] = "$Id: test1.C,v 1.4 2000/10/19 03:21:57 brian Exp $";

#pragma implementation

#include "L2_Codec.H"
#include <iostream.h>

int len0 = 3; char fme0[] = { 0x01, 0xfe, 0x00 };
int len1 = 4; char fme1[] = { 0x01, 0xfe, 0x01, 0x02 };
int len2 = 5; char fme2[] = { 0x01, 0xfe, 0x02, 0x05, 0x00 };
int len3 = 6; char fme3[] = { 0x01, 0xfe, 0x03, 0x01, 0x02, 0x03 };

int len4 = 100; char fme4[100];
int len5 = 6; char fme5[] = { 1, 2, 3, 4, 5, 6 };

main() {
    Codec_SU anSU;    
    Codec_SU* SU = &anSU;

    char* temp;

    Codec::decode(SU,fme1,len1); Codec::report(SU); cout << '\n';
    if (SU->LSSU->SF->test("SIE")) cout << "Yes, we have an SIE!\n\n";
    if (!SU->LSS2->SF->test("SIB")) cout << "No, we don't have an SIB!\n\n";
    if (SU->LSSU->SF->get(temp)) cout << "We have an " << temp << "\n\n";
    Codec::decode(SU,fme2,len2); Codec::report(SU); cout << '\n';
    if (SU->LSS2->SF->test("SIB")) cout << "Yes, we have an SIB!\n\n";
    if (!SU->LSS2->SF->test("SIE")) cout << "No, we don't have an SIE!\n\n";
    if (SU->LSS2->SF->get(temp)) cout << "We have an " << temp << "\n\n";
    Codec::decode(SU,fme0,len0); Codec::report(SU); cout << '\n';
    Codec::decode(SU,fme3,len3); Codec::report(SU); cout << '\n';

    cout.form("BSNR = %d\n",SU->BSN->value);
    cout.form("BIBR = %d\n",SU->BIB->value);
    cout.form("FSNR = %d\n",SU->FSN->value);
    cout.form("FIBR = %d\n",SU->FIB->value);
    cout.form("LI   = %d\n",SU->LI ->value);

    int i;

    len4 = 100;

    Codec::rebuild();
    SU->BSN->set(41);
    SU->BIB->set(1);
    SU->FSN->set(32);
    SU->FIB->set(0);
    SU->MSU->build();
    SU->MSU->PDU->set(fme5,len5);
    //if (Codec::encode(SU,fme4,len4)) cout.form("Encoded %d bytes: ",len4);
    //for (i=0;i<len4;i++) cout.form("%2x ",fme4[i]&0xff); cout << "\n";
    //Codec::report(SU); cout << '\n';
    //if (Codec::decode(SU,fme4,len4)) cout.form("Decoded %d bytes.\n",len4);
    Codec::encode(SU,fme4,len4);
    Codec::decode(SU,fme4,len4);
    Codec::report(SU); cout << '\n';

    len4 = 100;

    Codec::rebuild();
    SU->BSN->set(42);
    SU->BIB->set(0);
    SU->FSN->set(33);
    SU->FIB->set(1);
    SU->LSSU->build();
    SU->LSSU->SF->set("SIPO");
    //if (Codec::encode(SU,fme4,len4)) cout.form("Encoded %d bytes: ",len4);
    //for (i=0;i<len4;i++) cout.form("%2x ",fme4[i]&0xff); cout << "\n";
    //Codec::report(SU); cout << '\n';
    //if (Codec::decode(SU,fme4,len4)) cout.form("Decoded %d bytes.\n",len4);
    Codec::encode(SU,fme4,len4);
    Codec::decode(SU,fme4,len4);
    Codec::report(SU); cout << '\n';

    len4 = 100;

    Codec::rebuild();
    SU->BSN->set(43);
    SU->BIB->set(1);
    SU->FSN->set(34);
    SU->FIB->set(0);
    SU->LSSU->build();
    SU->LSSU->SF->set("SIOS");
    //if (Codec::encode(SU,fme4,len4)) cout.form("Encoded %d bytes: ",len4);
    //for (i=0;i<len4;i++) cout.form("%2x ",fme4[i]&0xff); cout << "\n";
    //Codec::report(SU); cout << '\n';
    //if (Codec::decode(SU,fme4,len4)) cout.form("Decoded %d bytes.\n",len4);
    Codec::encode(SU,fme4,len4);
    Codec::decode(SU,fme4,len4);
    Codec::report(SU); cout << '\n';

    len4 = 100;

    Codec::rebuild();
    SU->BSN->set(44);
    SU->BIB->set(0);
    SU->FSN->set(35);
    SU->FIB->set(1);
    SU->LSS2->build();
    SU->LSS2->SF->set("SIB");
    //if (Codec::encode(SU,fme4,len4)) cout.form("Encoded %d bytes: ",len4);
    //for (i=0;i<len4;i++) cout.form("%2x ",fme4[i]&0xff); cout << "\n";
    //Codec::report(SU); cout << '\n';
    //if (Codec::decode(SU,fme4,len4)) cout.form("Decoded %d bytes.\n",len4);
    Codec::encode(SU,fme4,len4);
    Codec::decode(SU,fme4,len4);
    Codec::report(SU); cout << '\n';

    cout << "...Done.\n";
    cout.flush();
};

