max_demo_sample.cpp
Go to the documentation of this file.
00001 // obid_data_exchange.cpp : Legt das Klassenverhalten f�r die Anwendung fest.
00002 //
00003 
00004 #include "FedmIscMyAxxessReader.h"
00005 
00006 #include "math.h"
00007 
00008 #define TRUE            1
00009 #define FALSE           0
00010 
00011 int main (void)
00012 {
00013         int iBack = 0;
00014         char cErrorText[256];
00015 
00016         // create reader-object with default IDD-Format numerical and IDD-Length of 5 bytes
00017         FedmIscMyAxxessReader m_MaxReader(5);
00018 
00019         m_MaxReader.SetDateFormat(FEDM_MYAXXESS_DATE_FORMAT_ISO8601);
00020 
00021         // create one holiday item (use typical overloaded method)...
00022         FEDM_ISC_MYAXXESS_HOLIDAY_TABLE_ITEM    HolidayItem;
00023         HolidayItem.ucHoliday_Year = 9;
00024         HolidayItem.ucHoliday_Month = 9;
00025         HolidayItem.ucHoliday_Day = 31;
00026         // ...and add to table
00027         m_MaxReader.AddTableItem(&HolidayItem);
00028 
00029         // create two timezone items (use alternative method)...
00030         char tmp1[] = "Days=Mo+Tu+We+Th+Fr+Sa+Su;DateFrom=2009-09-03;TimeFrom=23:12;DateTo=2009-09-31;TimeTo=22:12;";
00031         char tmp2[] = "Days=Mo+Tu+We+Th+Fr+Sa+Su;DateFrom=2009-10-03;TimeFrom=23:12;DateTo=2009-10-31;TimeTo=22:12;";
00032         // ...and add to table
00033         iBack = m_MaxReader.AddTableItem(FEDM_MYAXXESS_TIMEZONE_TABLE, tmp1);
00034         if (iBack)
00035         {
00036                 printf("1: %s\n", m_MaxReader.GetErrorText(iBack));
00037                 return iBack;
00038         }
00039         iBack = m_MaxReader.AddTableItem(FEDM_MYAXXESS_TIMEZONE_TABLE, tmp2);
00040         if (iBack)
00041         {
00042                 printf("2: %s\n", m_MaxReader.GetErrorText(iBack));
00043                 return iBack;
00044         }
00045 
00046         // create one access item (use alternative method)...
00047         char tmp4[] = "IDD=55555;Timezones=2;Reserved=0";
00048         // ...and add to table
00049         iBack = m_MaxReader.AddTableItem(FEDM_MYAXXESS_ACCESS_TABLE, tmp4);
00050         if (iBack)
00051         {
00052                 printf("3: %s\n", m_MaxReader.GetErrorText(iBack));
00053                 return iBack;
00054         }
00055         char tmp5[] = "IDD=1;Timezones=1+2;Reserved=0";
00056         iBack = m_MaxReader.AddTableItem(FEDM_MYAXXESS_ACCESS_TABLE, tmp5);
00057         if (iBack)
00058         {
00059                 printf("4: %s\n", m_MaxReader.GetErrorText(iBack));
00060                 return iBack;
00061         }
00062         char tmp6[] = "IDD=256;Timezones=1;Reserved=0";
00063         iBack = m_MaxReader.AddTableItem(FEDM_MYAXXESS_ACCESS_TABLE, tmp6);
00064         if (iBack)
00065         {
00066                 printf("5: %s\n", m_MaxReader.GetErrorText(iBack));
00067                 return iBack;
00068         }
00069         char tmp7[] = "IDD=9;Timezones=1;Reserved=0";
00070         iBack = m_MaxReader.AddTableItem(FEDM_MYAXXESS_ACCESS_TABLE, tmp7);
00071         if (iBack)
00072         {
00073                 printf("6: %s\n", m_MaxReader.GetErrorText(iBack));
00074                 return iBack;
00075         }
00076 
00077         // establish a connection to the Reader
00078         iBack = m_MaxReader.GetReaderObject()->ConnectTCP("192.168.3.159", 10001);
00079         if(iBack)
00080         {
00081                 printf("7: (192.168.3.159) %s\n", m_MaxReader.GetErrorText(iBack));
00082                 return iBack;
00083         }
00084 
00085         // read all reader info and set reader type for internal use
00086         FEDM_ISC_READER_INFO* pInfo = m_MaxReader.GetReaderObject()->ReadReaderInfo();
00087         if(pInfo ==NULL)
00088         {
00089                 printf("8: %s\n", m_MaxReader.GetErrorText(m_MaxReader.GetLastError()));
00090                 m_MaxReader.GetReaderObject()->DisConnect();
00091                 return iBack;
00092         }
00093 
00094         FedmIscReport_ReaderInfo report(m_MaxReader.GetReaderObject());
00095         string sReport;
00096         report.BuildReport(0xFF, sReport);
00097 
00098         printf("OBID Reader detected. Type is %s\n", m_MaxReader.GetReaderObject()->GetReaderName());
00099         printf("Reader Info:\n%s\n", sReport.c_str());
00100 
00101         // write all tables
00102         iBack = m_MaxReader.WriteTables();
00103         if (iBack)
00104         {
00105                 printf("9: %s\n", m_MaxReader.GetErrorText(iBack));
00106                 m_MaxReader.GetReaderObject()->DisConnect();
00107                 return iBack;
00108         }
00109 
00110 
00111         // read tables from reader
00112         iBack = m_MaxReader.ReadTable(FEDM_MYAXXESS_CRC_LIST);
00113         if (iBack)
00114         {
00115                 printf("10: %s\n", m_MaxReader.GetErrorText(iBack));
00116                 m_MaxReader.GetReaderObject()->DisConnect();
00117                 return iBack;
00118         }
00119 
00120         iBack = m_MaxReader.ReadTable(FEDM_MYAXXESS_METADATA);
00121         if (iBack)
00122         {
00123                 printf("11: %s\n", m_MaxReader.GetErrorText(iBack));
00124                 m_MaxReader.GetReaderObject()->DisConnect();
00125                 return iBack;
00126         }
00127 
00128         
00129         iBack = m_MaxReader.ReadTable(FEDM_MYAXXESS_TIMEZONE_TABLE);
00130         if (iBack)
00131         {
00132                 printf("12: %s\n", m_MaxReader.GetErrorText(iBack));
00133                 m_MaxReader.GetReaderObject()->DisConnect();
00134                 return iBack;
00135         }
00136 
00137         iBack = m_MaxReader.ReadTable(FEDM_MYAXXESS_HOLIDAY_TABLE);
00138         if (iBack)
00139         {
00140                 printf("13: %s\n", m_MaxReader.GetErrorText(iBack));
00141                 m_MaxReader.GetReaderObject()->DisConnect();
00142                 return iBack;
00143         }
00144 
00145         iBack = m_MaxReader.ReadTable(FEDM_MYAXXESS_ACCESS_TABLE);
00146         if (iBack)
00147         {
00148                 printf("14: %s\n", m_MaxReader.GetErrorText(iBack));
00149                 m_MaxReader.GetReaderObject()->DisConnect();
00150                 return iBack;
00151         }
00152 
00153         // save access table in CSV-File
00154         iBack = m_MaxReader.SerializeTableOut(FEDM_MYAXXESS_ACCESS_TABLE, "Tabelle.csv", FEDM_MYAXXESS_FILETYPE_CSV);
00155         if (iBack)
00156         {
00157                 printf("15: %s\n", m_MaxReader.GetErrorText(iBack));
00158                 m_MaxReader.GetReaderObject()->DisConnect();
00159                 return iBack;
00160         }
00161 
00162         // clear access table
00163         iBack = m_MaxReader.ClearTable(FEDM_MYAXXESS_ACCESS_TABLE);
00164         if (iBack)
00165         {
00166                 printf("16: %s\n", m_MaxReader.GetErrorText(iBack));
00167                 m_MaxReader.GetReaderObject()->DisConnect();
00168                 return iBack;
00169         }
00170 
00171         // read access table from file
00172         iBack = m_MaxReader.SerializeTableIn("Tabelle.csv", FEDM_MYAXXESS_FILETYPE_CSV);
00173         if (iBack)
00174         {
00175                 printf("17: %s\n", m_MaxReader.GetErrorText(iBack));
00176                 m_MaxReader.GetReaderObject()->DisConnect();
00177                 return iBack;
00178         }
00179 
00180         // write all tables
00181         iBack = m_MaxReader.WriteTables();
00182         if (iBack)
00183         {
00184                 printf("18: %s\n", m_MaxReader.GetErrorText(iBack));
00185                 m_MaxReader.GetReaderObject()->DisConnect();
00186                 return iBack;
00187         }
00188 
00189         // read access table from Reader
00190         iBack = m_MaxReader.ReadTable(FEDM_MYAXXESS_ACCESS_TABLE);
00191         if (iBack)
00192         {
00193                 printf("19: %s\n", m_MaxReader.GetErrorText(iBack));
00194                 m_MaxReader.GetReaderObject()->DisConnect();
00195                 return iBack;
00196         }
00197 
00198         // save access table in CSV-File
00199         iBack = m_MaxReader.SerializeTableOut(FEDM_MYAXXESS_ACCESS_TABLE, "Tabelle2.csv", FEDM_MYAXXESS_FILETYPE_CSV);
00200         if (iBack)
00201         {
00202                 printf("20: %s\n", m_MaxReader.GetErrorText(iBack));
00203                 m_MaxReader.GetReaderObject()->DisConnect();
00204                 return iBack;
00205         }
00206                 
00207         printf("OK\n");
00208         m_MaxReader.GetReaderObject()->DisConnect();
00209         return TRUE;
00210 }


rfid_drivers
Author(s): Raul Perula-Martinez
autogenerated on Thu Apr 2 2015 03:06:14