120 lines
3.1 KiB
C
120 lines
3.1 KiB
C
/*
|
|
************************************************************************
|
|
**
|
|
** Copyright (c) 2010..2012 by
|
|
** Core|Vision B.V.
|
|
** Cereslaan 10b
|
|
** 5384 VT Heesch
|
|
** The Netherlands
|
|
**
|
|
** All Rights Reserved
|
|
**
|
|
************************************************************************
|
|
*/
|
|
/*
|
|
************************************************************************
|
|
**
|
|
** Project name: Dual Inventive: Server for MTinfo Secure
|
|
** Filename: zkl-cmd.h
|
|
** Author: Jack Weeland
|
|
** Date: February 17, 2010
|
|
** File version: $Revision: 1.4 $
|
|
** $Date: 2012/12/05 13:53:33 $
|
|
**
|
|
************************************************************************
|
|
*/
|
|
/*
|
|
************************************************************************
|
|
**
|
|
** Secure Server
|
|
** Commands to a device
|
|
**
|
|
************************************************************************
|
|
*/
|
|
|
|
#ifndef _ZKL_CMD_H
|
|
#define _ZKL_CMD_H
|
|
|
|
#include "secureserver.h"
|
|
#include <sys/types.h> // for struct timeval
|
|
|
|
#include <di-util/cp3000.h>
|
|
|
|
/*
|
|
** Definitions
|
|
*/
|
|
|
|
typedef struct ZKL_CMDRUN_INFO
|
|
{
|
|
// information from the work instruction
|
|
cp3000_device_t master;
|
|
project_t project_id;
|
|
reason_t required_action;
|
|
|
|
// information about the device
|
|
zkl_t device_id;
|
|
unsigned int device_flags; // ZKL_xxx flags
|
|
const char *tcp_server;
|
|
|
|
// output
|
|
gps_position_t gps;
|
|
} *zkl_cmdrun_t;
|
|
|
|
/*
|
|
** Exported functions
|
|
** All return a status code (TCPSTAT_OK or an error code)
|
|
*/
|
|
|
|
// login and logout with the device
|
|
int zkl_login(
|
|
cp3000_device_t *p_device,
|
|
zkl_t id,
|
|
const char *server,
|
|
int status_updates_wanted,
|
|
struct timeval *timeout
|
|
);
|
|
int zkl_logout(cp3000_device_t);
|
|
|
|
// wait until the device has data
|
|
int zkl_wait(cp3000_device_t, struct timeval *timeout);
|
|
|
|
// store and retrieve a value
|
|
int zkl_store(cp3000_device_t, const char *key, const char *value, struct timeval *timeout);
|
|
int zkl_retrieve(cp3000_device_t, const char *key, char *value, size_t value_sz, struct timeval *timeout);
|
|
|
|
// wait for an update for the real-time status; the tokens returned
|
|
// in 'status' must be deleted with cp3000_delete_token()
|
|
int zkl_wait_status(cp3000_device_t, token_info_t *status, struct timeval *timeout);
|
|
|
|
// set command time-out in seconds; returns previous value
|
|
int zkl_set_timeout(int sec);
|
|
|
|
// fields from the 'status' returned above
|
|
unsigned int zkl_get_state(token_info_t); // MCUSTAT_xxx, MCUERR_xxx
|
|
unsigned int zkl_get_rc_state(token_info_t); // MCURC_xxx
|
|
unsigned int zkl_get_sw_state(token_info_t); // MCUSW_xxx
|
|
unsigned int zkl_get_l_state(token_info_t); // MCULOC_xxx
|
|
unsigned int zkl_get_flags(token_info_t); // MCUFLG_xxx
|
|
unsigned int zkl_get_wcpu_state(token_info_t); // WCPUxxx_xxx
|
|
int zkl_get_gps(token_info_t, gps_position_t*);
|
|
|
|
/*
|
|
** High level actions - callbacks for cp3000_start_thread()
|
|
*/
|
|
|
|
// release a device for switching or inhibit switching
|
|
int zkl_release_device(zkl_cmdrun_t);
|
|
int zkl_inhibit_device(zkl_cmdrun_t);
|
|
|
|
// check device and switch or connection status
|
|
int zkl_check_device(zkl_cmdrun_t);
|
|
int zkl_check_connection(zkl_cmdrun_t);
|
|
|
|
// switch a device
|
|
int zkl_switch_device(zkl_cmdrun_t);
|
|
|
|
// simple functionality
|
|
int zkl_simple_function(zkl_cmdrun_t);
|
|
|
|
#endif /* _ZKL_CMD_H */
|