LLC2_API
example0.cpp
Go to the documentation of this file.
00001 /* ------------------------------------------------------------------------- */
00002 /* file example0.cpp                                                                 */
00003 /* ------------------------------------------------------------------------- */
00004 /*   Copyright (C) 2011 Peter Milne, D-TACQ Solutions Ltd
00005  *                      <Peter dot Milne at D hyphen TACQ dot com>
00006  *  Created on: Sep 14, 2011
00007  *      Author: pgm
00008 
00009     http://www.d-tacq.com
00010 
00011     This program is free software; you can redistribute it and/or modify
00012     it under the terms of Version 2 of the GNU General Public License
00013     as published by the Free Software Foundation;
00014 
00015     This program is distributed in the hope that it will be useful,
00016     but WITHOUT ANY WARRANTY; without even the implied warranty of
00017     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018     GNU General Public License for more details.
00019 
00020     You should have received a copy of the GNU General Public License
00021     along with this program; if not, write to the Free Software
00022     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.                */
00023 /* ------------------------------------------------------------------------- */
00024 
00025 /** @file example0.cpp null control system example.
00026  *
00027  * Simplest "null control system":
00028  * outputs and fills user buffers no data change, no use of data.
00029  */
00030 #include <stdio.h>
00031 #include <sys/types.h>
00032 #include <sys/stat.h>
00033 #include <unistd.h>
00034 #include <stdlib.h>
00035 #include <errno.h>
00036 #include <assert.h>
00037 
00038 #include "ll2.h"
00039 #include "testharness.h"
00040 
00041 
00042 int main(int argc, const char* argv[])
00043 {
00044         LL_ControlSystem& the_system = LL_ControlSystem::create("example0");
00045 #define SAMPLES (the_system.getSamples())
00046 
00047         the_system.init(argc, argv);
00048         the_system.addCard(new ACQ196(SLOT2));
00049         the_system.addCard(new AO32(SLOT4));
00050 
00051         short* AO_buf = znew<short>(the_system.getAO_count());
00052         short* AI_buf = znew<short>(the_system.getAI_count());
00053         unsigned *DI_buf = znew<unsigned>(the_system.getDI_count()/BITS_PER_DX_WORD);
00054         unsigned *DO_buf = znew<unsigned>(the_system.getDO_count()/BITS_PER_DX_WORD);
00055         unsigned *ST_buf = znew<unsigned>(the_system.getStatus_count());
00056 
00057         the_system.Arm();
00058 
00059         for (int ii = 0; ii < SAMPLES; ++ii){
00060                 int rc = the_system.IO(AO_buf, DO_buf, AI_buf, DI_buf, ST_buf);
00061         }
00062 
00063         the_system.Stop();
00064         LL_ControlSystem::closedown(the_system);
00065 }