//============================================================-
// cgen.h
// Header file for C-WaveformGenerator
//                                             CONTEC.Co.,Ltd.
//============================================================-
//================================================================
// Prototype definition
//================================================================
extern "C" {
	long WINAPI GenOpenApplication(char* DeviceName, short* AppId, unsigned short OpenMode);
	long WINAPI GenCloseApplication(short AppId, unsigned long* Status);
	long WINAPI GenStartOperation(short AppId);
	long WINAPI GenStopOperation(short AppId);
	long WINAPI GenGetApplicationStatus(short AppId, unsigned long* Status);
	long WINAPI GenExportSettingFile(short AppId, char* FilePath);
	long WINAPI GenImportSettingFile(short AppId, char* FilePath);
	long WINAPI GenSaveDataFile(short AppId, char* FilePath, short Param1, short Param2);
	long WINAPI GenSetDeviceName(short AppId, char* DeviceName);
	long WINAPI GenGetDeviceName(short AppId, char* DeviceName);
	long WINAPI GenSetDeviceSetting(short AppId, unsigned short AoChannels, float Frequency, unsigned short FrequencyType, unsigned short FrequencyUnit);
	long WINAPI GenGetDeviceSetting(short AppId, unsigned short* AoChannels, float* Frequency, unsigned short* FrequencyType, unsigned short* FrequencyUnit);
	long WINAPI GenSetOscillation(short AppId, unsigned short OscillationType, unsigned short OscillationStart, float OscillationStop);
	long WINAPI GenGetOscillation(short AppId, unsigned short* OscillationType, unsigned short* OscillationStart, float* OscillationStop);
	long WINAPI GenSetChannelSetting(short AppId, unsigned short AoChannel, float Amplitude, float Offset, unsigned short AmplitudeType, unsigned short AmplitudeUnit, float Duty, float Phase);
	long WINAPI GenGetChannelSetting(short AppId, unsigned short AoChannel,float* Amplitude, float* Offset, unsigned short* AmplitudeType, unsigned short* AmplitudeUnit, float* Duty, float*  Phase);
	long WINAPI GenSetWaveType(short AppId, unsigned short AoChannel, unsigned short WaveType);
	long WINAPI GenGetWaveType(short AppId, unsigned short AoChannel, unsigned short* WaveType);
	long WINAPI GenSetArbitraryDataFile(short AppId, unsigned short AoChannel, char* FilePath);
	long WINAPI GenGetArbitraryDataFile(short AppId, unsigned short AoChannel, char* FilePath);
	long WINAPI GenSetAoSweep(short AppId, unsigned short AoChannel, unsigned short SweepType, unsigned short SweepTime, float SweepStart, float SweepStop);
	long WINAPI GenGetAoSweep(short AppId, unsigned short AoChannel, unsigned short* SweepType, unsigned short* SweepTime, float* SweepStart, float* SweepStop);
	long WINAPI GenGetErrorString(long ErrorCode, char* ErrorString);
}

//================================================================
// Parameters
//================================================================
//----------------------------------------
// App size
//----------------------------------------
#define	GEN_PARAM_WINDOW_OFF						0		// Minimize
#define	GEN_PARAM_WINDOW_NORMAL						1		// Normal
#define	GEN_PARAM_WINDOW_MAX						2		// Maximize

//----------------------------------------
// Termination processing status
//----------------------------------------
#define	GEN_STATUS_CLOSE_SUCCESS					0		// Normal completed
#define	GEN_STATUS_CLOSE_FAILURE					1		// C-WaveformGenerator completed error

//----------------------------------------
// Operation status
//----------------------------------------
#define	GEN_STATUS_BUSY								1		// Running trigger
#define	GEN_STATUS_START_TRG						2		// Start trigger

//----------------------------------------
// Number of channels for data save
//----------------------------------------
#define	GEN_PARAM_DATASAVE_SINGLE					0		// Data save for single channel
#define	GEN_PARAM_DATASAVE_MULTI					1		// Data save for multi channel

//----------------------------------------
// Frequency type
//----------------------------------------
#define	GEN_PARAM_FREQTYPE_FREQUENCY				0		// Frequency
#define	GEN_PARAM_FREQTYPE_PERIOD					1		// Period

//----------------------------------------
// Frequency unit
//----------------------------------------
#define	GEN_PARAM_FREQUNIT_HZ_SEC					0		// Frequency [ Hz ], Period [ sec ]
#define	GEN_PARAM_FREQUNIT_KHZ_MSEC					1		// Frequency [ kHz ], Period [ msec ]

//----------------------------------------
// Oscillation type
//----------------------------------------
#define	GEN_PARAM_OSCILLATION_NONE					0		// None
#define	GEN_PARAM_OSCILLATION_AUTO_BURST			1		// Auto burst
#define	GEN_PARAM_OSCILLATION_TRIGGER_BURST_RISE	2		// Trigger burst(rising edge)
#define	GEN_PARAM_OSCILLATION_TRIGGER_BURST_FALL	3		// Trigger burst(falling edge)

//----------------------------------------
// Amplitude type
//----------------------------------------
#define	GEN_PARAM_AMPTYPE_AMPLITUDE					0		// Amplitude
#define	GEN_PARAM_AMPTYPE_VPP						1		// Vp-p

//----------------------------------------
// Amplitude unit
//----------------------------------------
#define	GEN_PARAM_AMPUNIT_V_MA						0		// Voltage or Current
#define	GEN_PARAM_AMPUNIT_BINARY					1		// LSB

//----------------------------------------
// Wave type
//----------------------------------------
#define	GEN_PARAM_WAVE_SINE							0		// Sinewave
#define	GEN_PARAM_WAVE_CONSTANT						1		// Constant
#define	GEN_PARAM_WAVE_TRIANGULAR					2		// Triangular
#define	GEN_PARAM_WAVE_RAMP							3		// Ramp
#define	GEN_PARAM_WAVE_SQUARE						4		// Square
#define	GEN_PARAM_WAVE_NOISE						5		// Noise
#define	GEN_PARAM_WAVE_ARBITRARY					6		// Arbitrary

//----------------------------------------
// Sweep type
//----------------------------------------
#define	GEN_PARAM_SWEEP_NONE						0		// None
#define	GEN_PARAM_SWEEP_FREQUENCY					1		// Frequency sweep
#define	GEN_PARAM_SWEEP_AMPLITUDE					2		// Amplitude sweep
#define	GEN_PARAM_SWEEP_DC_OFFSET					3		// DC offset sweep
#define	GEN_PARAM_SWEEP_DUTY_RATIO					1		// Square Duty ratio sweep

//================================================================
// Error codes
//================================================================
//----------------------------------------
// Initialize Error
//----------------------------------------
#define	GEN_ERR_SUCCESS								0		// Normal completed
#define	GEN_ERR_INI_RESOURCE						1		// Failed in the acquisition of the resource
#define	GEN_ERR_INI_MEMORY							3		// Failed in the allocation of the memory
#define	GEN_ERR_MAKE_OBJECT							100		// Failed in the creation of the object
#define	GEN_ERR_OPEN_APPLICATION					102		// Cannot use C-WaveformGenerator because other application is using
#define	GEN_ERR_CTRL_APPLICATION					103		// Failed to application control

//----------------------------------------
// Common Error
//----------------------------------------
#define	GEN_ERR_APPLICATION_SIZE					10000	// Unable to specify screen size
#define	GEN_ERR_STATUS								10001	// Unable to get status
#define	GEN_ERR_FILEPATH							10002	// The setting file path is invalid
#define	GEN_ERR_FILETYPE							10003	// The setting file type is invalid
#define	GEN_ERR_FILESAVE							10005	// Failed to save file
#define	GEN_ERR_STARTED								10006	// Cannot execute because the device is in operation
#define	GEN_ERR_DEVICENAME							10007	// A device name isn't stored in DeviceName
#define	GEN_ERR_DEVICE_START						10008	// Operation start error occurred
#define	GEN_ERR_DEVICE_STOP							10009	// Operation stop error occurred
#define	GEN_ERR_INVALID_ID							10010	// Invalid AppID was specified
#define	GEN_ERR_BUFF_ADDRESS						10100	// Invalid data buffer address

//----------------------------------------
// Specific Error
//----------------------------------------
//--------------------
// Device Setting Error
//--------------------
#define	GEN_ERR_DEVICENAME_ANALOGOUT				20001	// The specified device does not have analog output function
#define	GEN_ERR_CHANNEL_NUM							20002	// Number of channels is outside the settable range
#define	GEN_ERR_FREQUENCY							20003	// Frequency is outside the settable range
#define	GEN_ERR_FREQUENCY_TYPE						20004	// Frequency type is outside the settable range
#define	GEN_ERR_FREQUENCY_UNIT						20005	// Frequency unit is outside the settable range
#define	GEN_ERR_OSCILLATION_TYPE					20006	// Oscillation type is outside the settable range
#define	GEN_ERR_OSCILLATION_WAVENUM					20007	// Number of oscillations is outside the settable range
#define	GEN_ERR_OSCILLATION_STOP_WAVENUM			20008	// Number of stops or time is outside the settable range
#define	GEN_ERR_OSCILLATION_DATANUM					20009	// Created data is outside the settable range
#define	GEN_ERR_DEVICESET							20010	// There are no devices that can be configured, the SDK will close
#define	GEN_ERR_BASICMODE							20011	// Switched to Basic mode. Settings may change automatically.
//--------------------
// Channel Setting Error
//--------------------
#define	GEN_ERR_CHANNEL_NO							22000	// Channel number is outside the settable range
#define	GEN_ERR_AMPLITUDE							22001	// Amplitude is outside the settable range
#define	GEN_ERR_OFFSET								22002	// Offset is outside the settable range
#define	GEN_ERR_AMPLITUDE_TYPE						22003	// Amplitude type is outside the settable range
#define	GEN_ERR_AMPLITUDE_UNIT						22004	// Amplitude unit is outside the settable range
#define	GEN_ERR_DUTY								22005	// Duty ratio is outside the settable range
#define	GEN_ERR_PHASE								22006	// Phase is outside the settable range
#define	GEN_ERR_WAVE_TYPE							22007	// Waveform type is outside the settable range
#define	GEN_ERR_SWEEP_TYPE							22008	// Sweep type is outside the settable range
#define	GEN_ERR_SWEEP_RATIO							22009	// Sweep time is outside the settable range
#define	GEN_ERR_SWEEP1								22010	// The value before the sweep change is outside the settable range
#define	GEN_ERR_SWEEP2								22011	// The value after the sweep change is outside the settable range
#define	GEN_ERR_WAVEDATA							20012	// Data file is not set when waveform type is arbitrary

#define	GEN_ERR_DEVICE								24001	// Device condition error occurred
#define	GEN_ERR_RELAY								24002	// Relay error occurred

