/*  Copyright (C) MOXA Inc. All rights reserved.

    This software is distributed under the terms of the
    MOXA License.  See the file COPYING-MOXA for details.
*/

#ifndef _DIGITAL_INPUT_OUTPUT_H
#define _DIGITAL_INPUT_OUTPUT_H

//#include "stdafx.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "mxdgio.h"

/* struct of serial ports (SP Master/Slave) */
typedef struct _DGIO_PRM {
	int				dout_port_num;			//digital output port number
	int				din_port_num;			//digital input port number
	int				port_type;			//input or output
	int				read_interval;
	int				write_interval;
	unsigned int	ok_count;
	unsigned int	error_count;
	unsigned int	thread_stop;
	
} DGIO_PRM,*PDGIO_PRM;

#define _DEBUG_MSG 1

#define MAX_DIN_NUMBER	 6
#define MAX_DOUT_NUMBER 2

#define DGIO_SIGNAL_HIGH	1
#define DGIO_SIGNAL_LOW	0

#define DGIO_DIN_LOW_ERROR		(-1)
#define DGIO_DIN_HIGH_ERROR	(-2)

#ifdef __cplusplus
extern "C" {
#endif

DWORD thread_dgio(LPVOID pdgio);

int init_dgio_data(HANDLE hDIO, int dout_len, int dout_start, int init_value);

int verify_dgio_data(HANDLE hDIO, int dout_len, int dout_start, int din_len, int din_start, int compare_data);


#ifdef __cplusplus
}
#endif

#endif /* _DIGITAL_INPUT_OUTPUT_H */
