From f31ed90b255a554a1930ac721d595ade0c8095a2 Mon Sep 17 00:00:00 2001 From: Bruno Luvizotto Date: Wed, 10 Aug 2016 10:35:52 -0400 Subject: [PATCH 01/15] Add files for supporting PIE517 piezo controller --- motorApp/PiSrc/Makefile | 1 + motorApp/PiSrc/PIE517Register.cc | 68 ++++ motorApp/PiSrc/devPIE517.cc | 316 ++++++++++++++ motorApp/PiSrc/devPIMotor.dbd | 6 + motorApp/PiSrc/drvPIE517.cc | 680 +++++++++++++++++++++++++++++++ motorApp/PiSrc/drvPIE517.h | 75 ++++ 6 files changed, 1146 insertions(+) create mode 100755 motorApp/PiSrc/PIE517Register.cc create mode 100755 motorApp/PiSrc/devPIE517.cc create mode 100755 motorApp/PiSrc/drvPIE517.cc create mode 100755 motorApp/PiSrc/drvPIE517.h diff --git a/motorApp/PiSrc/Makefile b/motorApp/PiSrc/Makefile index b38e4d27..4a380b08 100644 --- a/motorApp/PiSrc/Makefile +++ b/motorApp/PiSrc/Makefile @@ -19,6 +19,7 @@ SRCS += devPIC862.cc drvPIC862.cc PIC862Register.cc SRCS += devPIC663.cc drvPIC663.cc PIC663Register.cc SRCS += devPIE710.cc drvPIE710.cc PIE710Register.cc SRCS += devPIE516.cc drvPIE516.cc PIE516Register.cc +SRCS += devPIE517.cc drvPIE517.cc PIE517Register.cc SRCS += devPIE816.cc drvPIE816.cc PIE816Register.cc diff --git a/motorApp/PiSrc/PIE517Register.cc b/motorApp/PiSrc/PIE517Register.cc new file mode 100755 index 00000000..63ea618f --- /dev/null +++ b/motorApp/PiSrc/PIE517Register.cc @@ -0,0 +1,68 @@ +/* +FILENAME... PIE517Register.cc +USAGE... Register PI motor device driver shell commands. + +Version: $Revision: 1.1 $ +Modified By: $Author: sullivan $ +Last Modified: $Date: 2007-03-30 20:01:05 $ +*/ + +/***************************************************************** + COPYRIGHT NOTIFICATION +***************************************************************** + +(C) COPYRIGHT 1993 UNIVERSITY OF CHICAGO + +This software was developed under a United States Government license +described on the COPYRIGHT_UniversityOfChicago file included as part +of this distribution. +**********************************************************************/ + +#include +#include +#include +#include +#include +#include "motor.h" +#include "drvPIE517.h" +#include "epicsExport.h" + +extern "C" +{ + +// Pi Setup arguments +static const iocshArg setupArg0 = {"Max. controller count", iocshArgInt}; +static const iocshArg setupArg1 = {"Polling rate", iocshArgInt}; +// Pi Config arguments +static const iocshArg configArg0 = {"Card being configured", iocshArgInt}; +static const iocshArg configArg1 = {"asyn port name", iocshArgString}; +static const iocshArg configArg2 = {"asyn address (GPIB)", iocshArgInt}; + +static const iocshArg * const PIE517SetupArgs[2] = {&setupArg0, &setupArg1}; +static const iocshArg * const PIE517ConfigArgs[3] = {&configArg0, &configArg1, + &configArg2}; + +static const iocshFuncDef setupPIE517 = {"PIE517Setup", 2, PIE517SetupArgs}; +static const iocshFuncDef configPIE517 = {"PIE517Config", 3, PIE517ConfigArgs}; + +static void setupPIE517CallFunc(const iocshArgBuf *args) +{ + PIE517Setup(args[0].ival, args[1].ival); +} + + +static void configPIE517CallFunc(const iocshArgBuf *args) +{ + PIE517Config(args[0].ival, args[1].sval, args[2].ival); +} + + +static void PIE517motorRegister(void) +{ + iocshRegister(&setupPIE517, setupPIE517CallFunc); + iocshRegister(&configPIE517, configPIE517CallFunc); +} + +epicsExportRegistrar(PIE517motorRegister); + +} // extern "C" diff --git a/motorApp/PiSrc/devPIE517.cc b/motorApp/PiSrc/devPIE517.cc new file mode 100755 index 00000000..83255724 --- /dev/null +++ b/motorApp/PiSrc/devPIE517.cc @@ -0,0 +1,316 @@ +/* +FILENAME... devPIE517.cc +USAGE... Motor record device level support for Physik Instrumente (PI) + GmbH & Co. E-516 motor controller. + +Version: $Revision: 1.2 $ +Modified By: $Author: sluiter $ +Last Modified: $Date: 2008-03-14 20:21:37 $ +*/ + +/* + * Original Author: Ron Sluiter + * Date: 12/17/03 + * Current Author: Joe Sullivan + * + * Experimental Physics and Industrial Control System (EPICS) + * + * Copyright 1991, the Regents of the University of California, + * and the University of Chicago Board of Governors. + * + * This software was produced under U.S. Government contracts: + * (W-7405-ENG-36) at the Los Alamos National Laboratory, + * and (W-31-109-ENG-38) at Argonne National Laboratory. + * + * Initial development by: + * The Controls and Automation Group (AT-8) + * Ground Test Accelerator + * Accelerator Technology Division + * Los Alamos National Laboratory + * + * Co-developed with + * The Controls and Computing Group + * Accelerator Systems Division + * Advanced Photon Source + * Argonne National Laboratory + * + * Modification Log: + * ----------------- + * .01 08/10/16 Bruno Luvizotto (brunoluvizotto@gmail.com) - copied from devPIE516.cc + * .02 08/10/16 Bruno Luvizotto (brunoluvizotto@gmail.com) - edited the files for the E517 controller + */ + + +#include +#include "motorRecord.h" +#include "motor.h" +#include "motordevCom.h" +#include "drvPIE517.h" +#include "epicsExport.h" + +extern struct driver_table PIE517_access; + +/* ----------------Create the dsets for devPIE517----------------- */ +static struct driver_table *drvtabptr; +static long PIE517_init(void *); +static long PIE517_init_record(void *); +static long PIE517_start_trans(struct motorRecord *); +static RTN_STATUS PIE517_build_trans(motor_cmnd, double *, struct motorRecord *); +static RTN_STATUS PIE517_end_trans(struct motorRecord *); + +struct motor_dset devPIE517 = +{ + {8, NULL, (DEVSUPFUN) PIE517_init, (DEVSUPFUN) PIE517_init_record, NULL}, + motor_update_values, + PIE517_start_trans, + PIE517_build_trans, + PIE517_end_trans +}; + +extern "C" {epicsExportAddress(dset,devPIE517);} + +/* --------------------------- program data --------------------- */ + +/* This table is used to define the command types */ +/* WARNING! this must match "motor_cmnd" in motor.h */ + +static msg_types PIE517_table[] = { + MOTION, /* MOVE_ABS */ + MOTION, /* MOVE_REL */ + MOTION, /* HOME_FOR */ + MOTION, /* HOME_REV */ + IMMEDIATE, /* LOAD_POS */ + IMMEDIATE, /* SET_VEL_BASE */ + IMMEDIATE, /* SET_VELOCITY */ + IMMEDIATE, /* SET_ACCEL */ + IMMEDIATE, /* GO */ + IMMEDIATE, /* SET_ENC_RATIO */ + INFO, /* GET_INFO */ + MOVE_TERM, /* STOP_AXIS */ + VELOCITY, /* JOG */ + IMMEDIATE, /* SET_PGAIN */ + IMMEDIATE, /* SET_IGAIN */ + IMMEDIATE, /* SET_DGAIN */ + IMMEDIATE, /* ENABLE_TORQUE */ + IMMEDIATE, /* DISABL_TORQUE */ + IMMEDIATE, /* PRIMITIVE */ + IMMEDIATE, /* SET_HIGH_LIMIT */ + IMMEDIATE, /* SET_LOW_LIMIT */ + VELOCITY /* JOG_VELOCITY */ +}; + + +static struct board_stat **PIE517_cards; + +/* --------------------------- program data --------------------- */ + + +/* initialize device support for PIE517 stepper motor */ +static long PIE517_init(void *arg) +{ + long rtnval; + int after = (arg == 0) ? 0 : 1; + + if (after == 0) + { + drvtabptr = &PIE517_access; + (drvtabptr->init)(); + } + + rtnval = motor_init_com(after, *drvtabptr->cardcnt_ptr, drvtabptr, &PIE517_cards); + return(rtnval); +} + + +/* initialize a record instance */ +static long PIE517_init_record(void *arg) +{ + struct motorRecord *mr = (struct motorRecord *) arg; + /* Disable change of direction testing in record support */ + /* This is a closed-loop device */ + mr->ntm = menuYesNoNO; + return(motor_init_record_com(mr, *drvtabptr->cardcnt_ptr, drvtabptr, PIE517_cards)); +} + + +/* start building a transaction */ +static long PIE517_start_trans(struct motorRecord *mr) +{ + motor_start_trans_com(mr, PIE517_cards); + return(OK); +} + + +/* end building a transaction */ +static RTN_STATUS PIE517_end_trans(struct motorRecord *mr) +{ + motor_end_trans_com(mr, drvtabptr); + return(OK); +} + + +/* add a part to the transaction */ +static RTN_STATUS PIE517_build_trans(motor_cmnd command, double *parms, struct motorRecord *mr) +{ + struct motor_trans *trans = (struct motor_trans *) mr->dpvt; + struct mess_node *motor_call; + struct controller *brdptr; + struct PIE517controller *cntrl; + char buff[110]; + int card, maxdigits; + unsigned int size; + double dval, cntrl_units, res; + RTN_STATUS rtnval; + bool send; + + send = true; /* Default to send motor command. */ + rtnval = OK; + buff[0] = '\0'; + + /* Protect against NULL pointer with WRTITE_MSG(GO/STOP_AXIS/GET_INFO, NULL). */ + dval = (parms == NULL) ? 0.0 : *parms; + + rtnval = (RTN_STATUS) motor_start_trans_com(mr, PIE517_cards); + + motor_call = &(trans->motor_call); + card = motor_call->card; + brdptr = (*trans->tabptr->card_array)[card]; + if (brdptr == NULL) + return(rtnval = ERROR); + + cntrl = (struct PIE517controller *) brdptr->DevicePrivate; + res = cntrl->drive_resolution[motor_call->signal]; + cntrl_units = dval; + maxdigits = 3; + + if (PIE517_table[command] > motor_call->type) + motor_call->type = PIE517_table[command]; + + if (trans->state != BUILD_STATE) + return(rtnval = ERROR); + + if (command == PRIMITIVE && mr->init != NULL && strlen(mr->init) != 0) + strcat(motor_call->message, mr->init); + + switch (command) + { + case MOVE_ABS: + case MOVE_REL: + case HOME_FOR: + case HOME_REV: + case JOG: + if (strlen(mr->prem) != 0) + { + strcat(motor_call->message, mr->prem); + strcat(motor_call->message, EOL_E517); + } + if (strlen(mr->post) != 0) + motor_call->postmsgptr = (char *) &mr->post; + break; + + default: + break; + } + + + switch (command) + { + case MOVE_ABS: + sprintf(buff, "MOV # %.*f", maxdigits, (cntrl_units * res)); + strcat(buff, EOL_E517); + break; + + case MOVE_REL: + sprintf(buff, "MVR # %.*f", maxdigits, (cntrl_units * res)); + strcat(buff, EOL_E517); + break; + + case HOME_FOR: + case HOME_REV: + rtnval = ERROR; + break; + + case LOAD_POS: + rtnval = ERROR; + break; + + case SET_VEL_BASE: + send = false; /* DC motor; not base velocity. */ + break; + + case SET_VELOCITY: + sprintf(buff, "VEL # %.*f", maxdigits, (cntrl_units * res)); + strcat(buff, EOL_E517); + break; + + case ENABLE_TORQUE: + strcpy(buff, "SVO #1"); + strcat(buff, EOL_E517); + break; + + case DISABL_TORQUE: + strcpy(buff, "SVO #0"); + strcat(buff, EOL_E517); + break; + + case SET_ACCEL: + /* The PIE517 does not support acceleration commands. */ + case GO: + /* The PIE517 starts moving immediately on move commands, GO command + * does nothing. */ + send = false; + break; + + case PRIMITIVE: + case GET_INFO: + /* These commands are not actually done by sending a message, but + rather they will indirectly cause the driver to read the status + of all motors */ + break; + + case STOP_AXIS: + /* No stop command available - use move relative 0 */ + sprintf(buff, "STP #"); + strcat(buff, EOL_E517); + break; + + case JOG_VELOCITY: + case JOG: + sprintf(buff, "VEL # %.*f", maxdigits, cntrl_units); + strcat(buff, EOL_E517); + break; + + case SET_PGAIN: + send = false; + break; + case SET_IGAIN: + send = false; + break; + case SET_DGAIN: + send = false; + break; + + case SET_HIGH_LIMIT: + case SET_LOW_LIMIT: + case SET_ENC_RATIO: + trans->state = IDLE_STATE; /* No command sent to the controller. */ + send = false; + break; + + default: + send = false; + rtnval = ERROR; + } + + size = strlen(buff); + if (send == false) + return(rtnval); + else if (size > sizeof(buff) || (strlen(motor_call->message) + size) > MAX_MSG_SIZE) + errlogMessage("PIE517_build_trans(): buffer overflow.\n"); + else + { + strcat(motor_call->message, buff); + rtnval = motor_end_trans_com(mr, drvtabptr); + } + return(rtnval); +} diff --git a/motorApp/PiSrc/devPIMotor.dbd b/motorApp/PiSrc/devPIMotor.dbd index 67584994..04e0c06d 100644 --- a/motorApp/PiSrc/devPIMotor.dbd +++ b/motorApp/PiSrc/devPIMotor.dbd @@ -46,6 +46,12 @@ driver(drvPIE516) registrar(PIE516motorRegister) variable(drvPIE516debug) +# Physik Instrumente (PI) GmbH & Co. E-517 driver support. +device(motor,VME_IO,devPIE517,"PIE517") +driver(drvPIE517) +registrar(PIE517motorRegister) +variable(drvPIE517debug) + # Physik Instrumente (PI) GmbH & Co. E-816 driver support. device(motor,VME_IO,devPIE816,"PIE816") driver(drvPIE816) diff --git a/motorApp/PiSrc/drvPIE517.cc b/motorApp/PiSrc/drvPIE517.cc new file mode 100755 index 00000000..5ba40cb9 --- /dev/null +++ b/motorApp/PiSrc/drvPIE517.cc @@ -0,0 +1,680 @@ +/* +FILENAME... drvPIE517.cc +USAGE... Motor record driver level support for Physik Instrumente (PI) + GmbH & Co. E-516 motor controller. + +Version: $Revision: 1.1 $ +Modified By: $Author: sullivan $ +Last Modified: $Date: 2007-03-30 20:01:05 $ +*/ + +/* + * Original Author: Ron Sluiter + * Date: 10/18/05 + * Current Author: Joe Sullivan + * + * Experimental Physics and Industrial Control System (EPICS) + * + * Copyright 1991, the Regents of the University of California, + * and the University of Chicago Board of Governors. + * + * This software was produced under U.S. Government contracts: + * (W-7405-ENG-36) at the Los Alamos National Laboratory, + * and (W-31-109-ENG-38) at Argonne National Laboratory. + * + * Initial development by: + * The Controls and Automation Group (AT-8) + * Ground Test Accelerator + * Accelerator Technology Division + * Los Alamos National Laboratory + * + * Co-developed with + * The Controls and Computing Group + * Accelerator Systems Division + * Advanced Photon Source + * Argonne National Laboratory + * + * Modification Log: + * ----------------- + * .01 08/10/16 Bruno Luvizotto (brunoluvizotto@gmail.com) - copied from devPIE516.cc. + * .02 08/10/16 Bruno Luvizotto (brunoluvizotto@gmail.com) - edited the files for the E517 controller. + * Tested on PI VER: + * FW_DSP: 02.034 + * FW_FPGA: 02.040 + * FW_MCU: 1.22.6 + */ + +/* +DESIGN LIMITATIONS... + 1 - Like all controllers, the PIE517 must be powered-on when EPICS is first + booted up. +*/ + +#include +#include +#include +#include "motorRecord.h" +#include "motor.h" +#include "drvPIE517.h" +#include "epicsExport.h" + +#define GET_IDENT "VER?" +#define SET_ONLINE "ONL # 1" /* Set Online Mode ON */ +#define SET_VELCTRL "VCO # 1" /* Set Velocity Control Mode - Required for DONE */ +#define READ_ONLINE "ONL? #" /* Read Online Mode */ +#define READ_POS "POS? #" /* Read position */ +#define READ_OVERFLOW "OVF? #" /* Read Servo Overflow Status */ +#define READ_ONTARGET "ONT? #" /* Read Position ON Target */ +#define READ_SERVO "SVO? #" /* Read Servo Enable Status */ + + +#define PIE517_NUM_CARDS 10 +#define MAX_AXES 3 +#define BUFF_SIZE 100 /* Maximum length of string to/from PIE517 */ + +/*----------------debugging-----------------*/ +volatile int drvPIE517debug = 0; +extern "C" {epicsExportAddress(int, drvPIE517debug);} +static inline void Debug(int level, const char *format, ...) { + #ifdef DEBUG + if (level < drvPIE517debug) { + va_list pVar; + va_start(pVar, format); + vprintf(format, pVar); + va_end(pVar); + } + #endif +} + +/* --- Local data. --- */ +int PIE517_num_cards = 0; +static char *PIE517_axis[] = {"1 ", "2 ", "3 "}; //{"A", "B", "C"}; + +/* Local data required for every driver; see "motordrvComCode.h" */ +#include "motordrvComCode.h" + + +/*----------------functions-----------------*/ +static int recv_mess(int, char *, int); +static RTN_STATUS send_mess(int, char const *, char *); +static int set_status(int, int); +static long report(int); +static long init(); +static int motor_init(); +static void query_done(int, int, struct mess_node *); + +/*----------------functions-----------------*/ + +struct driver_table PIE517_access = +{ + motor_init, + motor_send, + motor_free, + motor_card_info, + motor_axis_info, + &mess_queue, + &queue_lock, + &free_list, + &freelist_lock, + &motor_sem, + &motor_state, + &total_cards, + &any_motor_in_motion, + send_mess, + recv_mess, + set_status, + query_done, + NULL, + &initialized, + PIE517_axis +}; + +struct +{ + long number; + long (*report) (int); + long (*init) (void); +} drvPIE517 = {2, report, init}; + +extern "C" {epicsExportAddress(drvet, drvPIE517);} + +static struct thread_args targs = {SCAN_RATE, &PIE517_access, 0.0}; + +/********************************************************* + * Print out driver status report + *********************************************************/ +static long report(int level) +{ + int card; + + if (PIE517_num_cards <=0) + printf(" No PIE517 controllers configured.\n"); + else + { + for (card = 0; card < PIE517_num_cards; card++) + { + struct controller *brdptr = motor_state[card]; + + if (brdptr == NULL) + printf(" PIE517 controller %d connection failed.\n", card); + else + { + struct PIE517controller *cntrl; + + cntrl = (struct PIE517controller *) brdptr->DevicePrivate; + printf(" PIE517 controller #%d, port=%s, id: %s \n", card, + cntrl->asyn_port, brdptr->ident); + } + } + } + return(OK); +} + + +static long init() +{ + /* + * We cannot call motor_init() here, because that function can do GPIB I/O, + * and hence requires that the drvGPIB have already been initialized. + * That cannot be guaranteed, so we need to call motor_init from device + * support + */ + /* Check for setup */ + if (PIE517_num_cards <= 0) + { + Debug(1, "init(): PIE517 driver disabled. PIE517Setup() missing from startup script.\n"); + } + return((long) 0); +} + + +static void query_done(int card, int axis, struct mess_node *nodeptr) +{ +} + + +/******************************************************************************** +* * +* FUNCTION NAME: set_status * +* * +* LOGIC: * +* Initialize. * +* Send "Moving Status" query. * +* Read response. * +* IF normal response to query. * +* Set communication status to NORMAL. * +* ELSE * +* IF communication status is NORMAL. * +* Set communication status to RETRY. * +* NORMAL EXIT. * +* ELSE * +* Set communication status error. * +* ERROR EXIT. * +* ENDIF * +* ENDIF * +* * +* IF "Moving Status" indicates any motion (i.e. status != 0). * +* Clear "Done Moving" status bit. * +* ELSE * +* Set "Done Moving" status bit. * +* ENDIF * +* * +* * +********************************************************************************/ + +static int set_status(int card, int signal) +{ + struct PIE517controller *cntrl; + struct mess_node *nodeptr; + struct mess_info *motor_info; + struct motorRecord *mr; + /* Message parsing variables */ + char buff[BUFF_SIZE]; + int rtn_state; + unsigned int overflow_status, ontarget_status, servo_status, online_status; + epicsInt32 motorData; + bool plusdir, ls_active, plusLS, minusLS; + bool readOK; + msta_field status; + + cntrl = (struct PIE517controller *) motor_state[card]->DevicePrivate; + motor_info = &(motor_state[card]->motor_info[signal]); + nodeptr = motor_info->motor_motion; + if (nodeptr != NULL) + mr = (struct motorRecord *) nodeptr->mrecord; + else + mr = NULL; + status.All = motor_info->status.All; + + recv_mess(card, buff, FLUSH); + + readOK = false; +// send_mess(card, READ_ONLINE, PIE517_axis[signal]); +// if (recv_mess(card, buff, 1) && sscanf(buff, "%d", &online_status)) +// { +// if (!online_status) +// { +// /* Assume Controller Reboot - Set ONLINE and Velocity Control ON */ +// send_mess(card, SET_ONLINE, PIE517_axis[signal]); +// //send_mess(card, SET_VELCTRL, (char) NULL); +// } + + send_mess(card, READ_ONTARGET, PIE517_axis[signal]); + if (recv_mess(card, buff, 1) && sscanf(buff, "%d", &ontarget_status)) + { + send_mess(card, READ_OVERFLOW, PIE517_axis[signal]); + if (recv_mess(card, buff, 1) && sscanf(buff, "%d", &overflow_status)) + { + send_mess(card, READ_SERVO, PIE517_axis[signal]); + if (recv_mess(card, buff, 1) && sscanf(buff, "%d", &servo_status)) + { + send_mess(card, READ_POS, PIE517_axis[signal]); + if (recv_mess(card, buff, 1)) + { + motorData = NINT(atof(buff) / cntrl->drive_resolution[signal]); + readOK = true; + } + } + } + } +// } + + if (readOK) + { + cntrl->status = NORMAL; + status.Bits.CNTRL_COMM_ERR = 0; + } + else + { + if (cntrl->status == NORMAL) + { + cntrl->status = RETRY; + rtn_state = OK; + goto exit; + } + else + { + cntrl->status = COMM_ERR; + status.Bits.CNTRL_COMM_ERR = 1; + status.Bits.RA_PROBLEM = 1; + rtn_state = 1; + goto exit; + } + } + + + /* Always DONE if torque disabled */ + status.Bits.RA_DONE = (ontarget_status) ? 1 : 0; + status.Bits.RA_HOME = status.Bits.RA_DONE; + + status.Bits.EA_POSITION = (servo_status) ? 1 : 0; /* Torgue disabled flag */ + + ls_active = plusLS = minusLS = false; + + /* LS status may be true but servo is not within position error - keep updating */ + /* No Limit switches but if the Servo Controller overflows indicate with a + LS */ + if (status.Bits.RA_DONE) + plusLS = overflow_status ? true : false; + + if (motorData == motor_info->position) + { + if (nodeptr != 0) /* Increment counter only if motor is moving. */ + motor_info->no_motion_count++; + } + else + { + status.Bits.RA_DIRECTION = (motorData >= motor_info->position) ? 1 : 0; + motor_info->position = motor_info->encoder_position = motorData; + motor_info->no_motion_count = 0; + } + + plusdir = (status.Bits.RA_DIRECTION) ? true : false; + + /* Set limit switch error indicators. */ + if (plusLS == true) + { + status.Bits.RA_PLUS_LS = 1; + if (plusdir == true) + ls_active = true; + } + else + status.Bits.RA_PLUS_LS = 0; + + if (minusLS == true) + { + status.Bits.RA_MINUS_LS = 1; + if (plusdir == false) + ls_active = true; + } + else + status.Bits.RA_MINUS_LS = 0; + + /* encoder status */ + status.Bits.EA_SLIP = 0; + status.Bits.EA_SLIP_STALL = 0; + status.Bits.EA_HOME = 0; + + status.Bits.RA_PROBLEM = 0; + + /* Parse motor velocity? */ + /* NEEDS WORK */ + + motor_info->velocity = 0; + + if (!status.Bits.RA_DIRECTION) + motor_info->velocity *= -1; + + rtn_state = (!motor_info->no_motion_count || ls_active == true || + status.Bits.RA_DONE | status.Bits.RA_PROBLEM) ? 1 : 0; + + /* Test for post-move string. */ + if ((status.Bits.RA_DONE || ls_active == true) && nodeptr != 0 && + nodeptr->postmsgptr != 0) + { + strcpy(buff, nodeptr->postmsgptr); + send_mess(card, buff, (char) NULL); + nodeptr->postmsgptr = NULL; + } + +exit: + motor_info->status.All = status.All; + return(rtn_state); +} + + +/*****************************************************/ +/* send a message to the PIE517 board */ +/* send_mess() */ +/*****************************************************/ +static RTN_STATUS send_mess(int card, char const *com, char *name) +{ + char local_buff[MAX_MSG_SIZE]; + char *pbuff; + struct PIE517controller *cntrl; + int comsize, namesize; + size_t nwrite; + + comsize = (com == NULL) ? 0 : strlen(com); + namesize = (name == NULL) ? 0 : strlen(name); + + if ((comsize + namesize) > MAX_MSG_SIZE) + { + errlogMessage("drvPIE517.cc:send_mess(); message size violation.\n"); + return(ERROR); + } + else if (comsize == 0) /* Normal exit on empty input message. */ + return(OK); + + if (!motor_state[card]) + { + errlogPrintf("drvPIE517.cc:send_mess() - invalid card #%d\n", card); + return(ERROR); + } + + local_buff[0] = (char) NULL; /* Terminate local buffer. */ + + if (name == NULL) + strcat(local_buff, com); /* Make a local copy of the string. */ + else + { + strcpy(local_buff, com); + pbuff = strchr(local_buff, '#'); + if (pbuff != NULL) + *pbuff = *name; + else + Debug(1, "send_mess(): NAME ERROR: message = %s\n", local_buff); + } + + Debug(2, "send_mess(): message = %s\n", local_buff); + + cntrl = (struct PIE517controller *) motor_state[card]->DevicePrivate; + pasynOctetSyncIO->write(cntrl->pasynUser, local_buff, strlen(local_buff), + COMM_TIMEOUT, &nwrite); + + return(OK); +} + + +/*****************************************************/ +/* receive a message from the PIE517 board */ +/* recv_mess() */ +/*****************************************************/ +static int recv_mess(int card, char *com, int flag) +{ + struct PIE517controller *cntrl; + size_t nread = 0; + asynStatus status = asynError; + int eomReason; + char *pos; + + /* Check that card exists */ + if (!motor_state[card]) + return(ERROR); + + cntrl = (struct PIE517controller *) motor_state[card]->DevicePrivate; + + if (flag == FLUSH) + pasynOctetSyncIO->flush(cntrl->pasynUser); + else + status = pasynOctetSyncIO->read(cntrl->pasynUser, com, BUFF_SIZE, + COMM_TIMEOUT, &nread, &eomReason); + pos=strchr(com,'='); + if(pos != NULL) + strcpy(com,&pos[1]); + + if ((status != asynSuccess) || (nread <= 0)) + { + com[0] = '\0'; + nread = 0; + } + + Debug(2, "recv_mess(): message = \"%s\"\n", com); + return(nread); +} + + +/*****************************************************/ +/* Setup system configuration */ +/* PIE517Setup() */ +/*****************************************************/ +RTN_STATUS +PIE517Setup(int num_cards, /* maximum number of controllers in system. */ + int scan_rate) /* polling rate - 1/60 sec units. */ +{ + int itera; + + if (num_cards < 1 || num_cards > PIE517_NUM_CARDS) + PIE517_num_cards = PIE517_NUM_CARDS; + else + PIE517_num_cards = num_cards; + + /* Set motor polling task rate */ + if (scan_rate >= 1 && scan_rate <= 60) + targs.motor_scan_rate = scan_rate; + else + targs.motor_scan_rate = SCAN_RATE; + + /* + * Allocate space for motor_state structures. Note this must be done + * before PIE517Config is called, so it cannot be done in motor_init() + * This means that we must allocate space for a card without knowing + * if it really exists, which is not a serious problem + */ + motor_state = (struct controller **) malloc(PIE517_num_cards * + sizeof(struct controller *)); + + for (itera = 0; itera < PIE517_num_cards; itera++) + motor_state[itera] = (struct controller *) NULL; + + return(OK); +} + + +/*****************************************************/ +/* Configure a controller */ +/* PIE517Config() */ +/*****************************************************/ +RTN_STATUS +PIE517Config(int card, /* card being configured */ + const char *name, /* asyn port name */ + int addr) /* asyn address (GPIB) */ +{ + struct PIE517controller *cntrl; + + if (card < 0 || card >= PIE517_num_cards) + return(ERROR); + + motor_state[card] = (struct controller *) malloc(sizeof(struct controller)); + motor_state[card]->DevicePrivate = malloc(sizeof(struct PIE517controller)); + cntrl = (struct PIE517controller *) motor_state[card]->DevicePrivate; + + strcpy(cntrl->asyn_port, name); + cntrl->asyn_address = addr; + return(OK); +} + + +/*****************************************************/ +/* initialize all software and hardware */ +/* This is called from the initialization routine in */ +/* device support. */ +/* motor_init() */ +/*****************************************************/ +static int motor_init() +{ + struct controller *brdptr; + struct PIE517controller *cntrl; + int card_index, motor_index; + char buff[BUFF_SIZE], *pbuff; + int total_axis; + int status; + int version; + bool online; + asynStatus success_rtn; + static const char output_terminator[] = EOL_E517; + static const char input_terminator[] = EOL_E517; + + initialized = true; /* Indicate that driver is initialized. */ + + /* Check for setup */ + if (PIE517_num_cards <= 0) + return(ERROR); + + for (card_index = 0; card_index < PIE517_num_cards; card_index++) + { + if (!motor_state[card_index]) + continue; + + brdptr = motor_state[card_index]; + brdptr->ident[0] = (char) NULL; /* No controller identification message. */ + brdptr->cmnd_response = false; + total_cards = card_index + 1; + cntrl = (struct PIE517controller *) brdptr->DevicePrivate; + + status = version = 0; + + /* Initialize communications channel */ + success_rtn = pasynOctetSyncIO->connect(cntrl->asyn_port, 0, + &cntrl->pasynUser, NULL); + if (success_rtn == asynSuccess) + { + //int retry = 0; + + pasynOctetSyncIO->setOutputEos(cntrl->pasynUser, output_terminator, + strlen(output_terminator)); + pasynOctetSyncIO->setInputEos(cntrl->pasynUser, input_terminator, + strlen(input_terminator)); + + /* Send a message to the board, see if it exists */ + /* flush any junk at input port - should not be any data available */ + pasynOctetSyncIO->flush(cntrl->pasynUser); + + /* Assure that Controller is ONLINE */ + online = true; + //do + //{ + // online = false; + // /* Set Controller to ONLINE mode */ + // send_mess(card_index, SET_ONLINE, (char) NULL); + // send_mess(card_index, READ_ONLINE, (char) NULL); + // if ((status = recv_mess(card_index, buff, 1))) + //online = (atoi(buff)==1) ? true : false; + // else + //retry++; + //} while (online == false && retry < 3); + + //send_mess(card_index, GET_IDENT, (char) NULL); + //status = recv_mess(card_index, buff, 1); + + /* Parse out E517 revision (2 decimal places) and convert to int */ + if ((pbuff = strchr(buff, 'V'))) + version = NINT(atof(pbuff+1) * 100); + else + version = 0; + } + + if (success_rtn == asynSuccess && online == true) + { + strcpy(brdptr->ident, buff); + brdptr->localaddr = (char *) NULL; + brdptr->motor_in_motion = 0; + + /* Check for E517 versions that need the status word shifted up 8 bits */ + /*if (version >= 311) + cntrl->versionSupport = true; + else + cntrl->versionSupport = false;*/ + + /* Determine # of axes. Request stage name. See if it responds */ + for (total_axis = 0; total_axis < MAX_AXES; total_axis++) + { + send_mess(card_index, READ_POS, PIE517_axis[total_axis]); + status = recv_mess(card_index, buff, 1); + if (!status) + break; + } + brdptr->total_axis = total_axis; + + /* Turn ON velocity control mode - All axis */ + //send_mess(card_index, SET_VELCTRL, (char) NULL); + + for (motor_index = 0; motor_index < total_axis; motor_index++) + { + struct mess_info *motor_info = &brdptr->motor_info[motor_index]; + + motor_info->status.All = 0; + motor_info->no_motion_count = 0; + motor_info->encoder_position = 0; + motor_info->position = 0; + brdptr->motor_info[motor_index].motor_motion = NULL; + /* PIE517 has DC motor support only */ + motor_info->encoder_present = YES; + motor_info->status.Bits.EA_PRESENT = 1; + motor_info->pid_present = NO; + motor_info->status.Bits.GAIN_SUPPORT = 1; + + cntrl->drive_resolution[motor_index] = POS_RES; + + set_status(card_index, motor_index); /* Read status of each motor */ + } + } + else + motor_state[card_index] = (struct controller *) NULL; + } + + any_motor_in_motion = 0; + + mess_queue.head = (struct mess_node *) NULL; + mess_queue.tail = (struct mess_node *) NULL; + + free_list.head = (struct mess_node *) NULL; + free_list.tail = (struct mess_node *) NULL; + + epicsThreadCreate((char *) "PIE517_motor", epicsThreadPriorityMedium, + epicsThreadGetStackSize(epicsThreadStackMedium), + (EPICSTHREADFUNC) motor_task, (void *) &targs); + + return(OK); +} + + diff --git a/motorApp/PiSrc/drvPIE517.h b/motorApp/PiSrc/drvPIE517.h new file mode 100755 index 00000000..3d1c942b --- /dev/null +++ b/motorApp/PiSrc/drvPIE517.h @@ -0,0 +1,75 @@ +/* File: drvPIE516.h */ + + +/* Device Driver Support definitions for motor */ +/* + * Original Author: Ron Sluiter + * Current Author: Joe Sullivan + * Date: 09/20/2005 + * + * Modification Log: + * ----------------- + * .01 08/10/16 Bruno Luvizotto (brunoluvizotto@gmail.com) - copied from drvPIE516.h + * .02 08/10/16 Bruno Luvizotto (brunoluvizotto@gmail.com) - edited the files for the E517 controller + */ + +#ifndef INCdrvPIE517h +#define INCdrvPIE517h 1 + +#include "motordrvCom.h" +#include "asynDriver.h" +#include "asynDriver.h" +#include "asynOctetSyncIO.h" + +#define COMM_TIMEOUT 2 /* Timeout in seconds. */ +#define POS_RES 0.001 /* Position resolution. */ + +#define EOL_E517 "\n" /* Command End-Of-Line = LF (0x10) */ + +struct PIE517controller +{ + asynUser *pasynUser; /* asynUser structure */ + int asyn_address; /* Use for GPIB or other address with asyn */ + CommStatus status; /* Controller communication status. */ + double drive_resolution[4]; + bool versionSupport; /* Track supported Versions - include in Report */ + char asyn_port[80]; /* asyn port name */ +}; + + +typedef union +{ + epicsUInt16 All; + struct + { +#ifdef MSB_First + unsigned int cmnd_err :1; /* 15 - Command Error */ + unsigned int na6 :1; /* 14 - */ + unsigned int autozero :1; /* 13 - AutoZero function is running */ + unsigned int plus_ls :1; /* 12 - Positive limit switch flag. */ + unsigned int minus_ls :1; /* 11 - Negative limit switch flag. */ + unsigned int moving :1; /* 10 - Moving indicator - position error outside tolerance */ + unsigned int volt_limit :1; /* 9 - piezo voltage limit reached */ + unsigned int torque :1; /* 8 - Servo-control status */ + unsigned int nabyte :8; + +#else + unsigned int nabyte :8; + unsigned int torque :1; /* 8 - Servo-control status */ + unsigned int volt_limit :1; /* 9 - piezo voltage limit reached */ + unsigned int moving :1; /* 10 - Moving indicator - position error outside tolerance */ + unsigned int minus_ls :1; /* 11 - Negative limit switch flag. */ + unsigned int plus_ls :1; /* 12 - Positive limit switch flag. */ + unsigned int autozero :1; /* 13 - AutoZero function is running */ + unsigned int na6 :1; /* 14 - */ + unsigned int cmnd_err :1; /* 15 - Command Error */ +#endif + } Bits; +} E517_Status_Reg; + + +/* Function prototypes. */ +extern RTN_STATUS PIE517Setup(int, int); +extern RTN_STATUS PIE517Config(int, const char *, int); + +#endif /* INCdrvPIE517h */ From 5c0d5d8c1f15952f9bd3b6bc0c649d87f3f771e5 Mon Sep 17 00:00:00 2001 From: Keenan Lang Date: Wed, 14 Sep 2016 15:22:27 -0500 Subject: [PATCH 02/15] Scriptable motor support --- .../iocWithAsyn/motor.substitutions.script | 15 + iocBoot/iocWithAsyn/scripts/softMotor.lua | 61 ++ iocBoot/iocWithAsyn/scripts/vmc.lua | 66 ++ iocBoot/iocWithAsyn/st.cmd.script | 18 + motorApp/Db/ScriptMotorReload.db | 9 + motorApp/Makefile | 6 + motorApp/ScriptMotorSrc/Makefile | 30 + motorApp/ScriptMotorSrc/ScriptMotorDriver.cpp | 859 ++++++++++++++++++ motorApp/ScriptMotorSrc/ScriptMotorDriver.dbd | 1 + motorApp/ScriptMotorSrc/ScriptMotorDriver.h | 76 ++ 10 files changed, 1141 insertions(+) create mode 100644 iocBoot/iocWithAsyn/motor.substitutions.script create mode 100644 iocBoot/iocWithAsyn/scripts/softMotor.lua create mode 100644 iocBoot/iocWithAsyn/scripts/vmc.lua create mode 100644 iocBoot/iocWithAsyn/st.cmd.script create mode 100644 motorApp/Db/ScriptMotorReload.db create mode 100644 motorApp/ScriptMotorSrc/Makefile create mode 100644 motorApp/ScriptMotorSrc/ScriptMotorDriver.cpp create mode 100644 motorApp/ScriptMotorSrc/ScriptMotorDriver.dbd create mode 100644 motorApp/ScriptMotorSrc/ScriptMotorDriver.h diff --git a/iocBoot/iocWithAsyn/motor.substitutions.script b/iocBoot/iocWithAsyn/motor.substitutions.script new file mode 100644 index 00000000..c2f63ea9 --- /dev/null +++ b/iocBoot/iocWithAsyn/motor.substitutions.script @@ -0,0 +1,15 @@ +file "$(TOP)/db/asyn_motor.db" +{ + pattern + {P, M, DTYP, PORT, ADDR, DESC, EGU, DIR, VMAX, VELO, VBAS, ACCL, BDST, BVEL, BACC, MRES, PREC, DHLM, DLLM, INIT} + {IOC:, m1, "asynMotor", VMC_MOTOR, 0, "VMCMotor", mm, Pos, 15., 3., .05, .5, 0, 1.0, 2, .025, 5, 0, 0, ""} + {IOC:, m2, "asynMotor", SOFT_MOTOR, 0, "SoftMotor", mm, Pos, 15., 3., .05, .5, 0, 1.0, 2, .025, 5, 0, 0, ""} +} + +file "$(TOP)/db/ScriptMotorReload.db" +{ + pattern + {P, PORT} + {IOC:, SOFT_MOTOR} + {IOC:, VMC_MOTOR} +} diff --git a/iocBoot/iocWithAsyn/scripts/softMotor.lua b/iocBoot/iocWithAsyn/scripts/softMotor.lua new file mode 100644 index 00000000..a03e698e --- /dev/null +++ b/iocBoot/iocWithAsyn/scripts/softMotor.lua @@ -0,0 +1,61 @@ +MovingPollPeriod = 0.25 + +lastPos = 0 +targetPos = 0 + +function move(position, relative, minVel, maxVel, accel) + local MRES = asyn.getDoubleParam( DRIVER, AXIS, "MOTOR_REC_RESOLUTION") + + if (relative) then + local prev = asyn.getDoubleParam( DRIVER, AXIS, "MOTOR_POSITION") + targetPos = prev + (position * MRES) + else + targetPos = (position * MRES) + end + + epics.put(DRIVE_PV, targetPos) + + if (position > 0) then + asyn.setIntegerParam( DRIVER, AXIS, "MOTOR_STATUS_DIRECTION", 1) + else + asyn.setIntegerParam( DRIVER, AXIS, "MOTOR_STATUS_DIRECTION", 0) + end + + asyn.callParamCallbacks(DRIVER, AXIS) +end + + +function poll() + local curr = epics.get(READBACK_PV) + local MRES = asyn.getDoubleParam( DRIVER, AXIS, "MOTOR_REC_RESOLUTION") + + asyn.setDoubleParam( DRIVER, AXIS, "MOTOR_POSITION", curr / MRES) + + local done = 0 + local moving = 1 + + if (curr == targetPos) then + done = 1 + moving = 0 + elseif (math.abs(curr - targetPos) <= MRES and lastPos == curr) then + done = 1 + moving = 0 + end + + lastPos = curr + + asyn.setIntegerParam( DRIVER, AXIS, "MOTOR_STATUS_DONE", done) + asyn.setIntegerParam( DRIVER, AXIS, "MOTOR_STATUS_MOVING", moving) + + asyn.callParamCallbacks(DRIVER, AXIS) + + return (done ~= 1) +end + + +function stop(acceleration) + local curr = asyn.getDoubleParam( DRIVER, AXIS, "MOTOR_POSITION") + + epics.put(DRIVE_PV, curr) + targetPos = curr +end diff --git a/iocBoot/iocWithAsyn/scripts/vmc.lua b/iocBoot/iocWithAsyn/scripts/vmc.lua new file mode 100644 index 00000000..46ff05fe --- /dev/null +++ b/iocBoot/iocWithAsyn/scripts/vmc.lua @@ -0,0 +1,66 @@ +IdlePollPeriod = 1.0 +MovingPollPeriod = 0.25 +ForcedFastPolls = 2 + +InTerminator = "\r\n" +OutTerminator = "\r\n" + +function sendAccelAndVelocity(minVel, maxVel, accel) + asyn.writeread( string.format( "%d BAS %f", AXIS + 1, minVel) , PORT); + asyn.writeread( string.format( "%d VEL %f", AXIS + 1, maxVel) , PORT); + asyn.writeread( string.format( "%d ACC %f", AXIS + 1, accel ) , PORT); +end + + +function move(position, relative, minVel, maxVel, accel) + sendAccelAndVelocity( minVel, maxVel, accel) + + if (relative) then + asyn.writeread( string.format( "%d MR %d", AXIS + 1, math.floor(position) ) , PORT) + else + asyn.writeread( string.format( "%d MV %d", AXIS + 1, math.floor(position) ) , PORT) + end +end + + +function moveVelocity(minVel, maxVel, accel) + sendAccelAndVelocity( minVel, maxVel, accel) + + asyn.writeread( string.format( "%d JOG %f", AXIS + 1, maxVel) , PORT); +end + + +function poll() + asyn.write( string.format( "%d POS?", AXIS + 1) , PORT) + + asyn.setDoubleParam( DRIVER, AXIS, "MOTOR_POSITION", tonumber( asyn.read(PORT) ) ) + + asyn.write( string.format( "%d ST?", AXIS + 1) , PORT) + + local status = tonumber( asyn.read(PORT) ) + + local direction = (status & 1) + local done = (status & 2) >> 1 + local limit_high = (status & 8) >> 3 + local limit_low = (status & 16) >> 4 + + asyn.setIntegerParam( DRIVER, AXIS, "MOTOR_STATUS_DIRECTION", direction) + asyn.setIntegerParam( DRIVER, AXIS, "MOTOR_STATUS_DONE", done) + asyn.setIntegerParam( DRIVER, AXIS, "MOTOR_STATUS_MOVING", done ~ 1) + asyn.setIntegerParam( DRIVER, AXIS, "MOTOR_STATUS_HIGH_LIMIT", limit_high) + asyn.setIntegerParam( DRIVER, AXIS, "MOTOR_STATUS_LOW_LIMIT", limit_low) + + asyn.callParamCallbacks(DRIVER, AXIS) + + return (done ~= 1) +end + + +function stop(acceleration) + asyn.writeread( string.format( "%d AB", AXIS + 1) , PORT); +end + + +function setPosition(position) + asyn.writeread( string.format( "%d POS %d", AXIS + 1, math.floor(position) ) , PORT); +end diff --git a/iocBoot/iocWithAsyn/st.cmd.script b/iocBoot/iocWithAsyn/st.cmd.script new file mode 100644 index 00000000..995c60a4 --- /dev/null +++ b/iocBoot/iocWithAsyn/st.cmd.script @@ -0,0 +1,18 @@ +< envPaths + +dbLoadDatabase("$(TOP)/dbd/WithAsyn.dbd") +WithAsyn_registerRecordDeviceDriver(pdbbase) + +epicsEnvSet("LUA_SCRIPT_PATH", "./scripts") + +# Connect to virtual motor controller server +drvAsynIPPortConfigure("VMC","127.0.0.1:31337", 0, 0, 0) + +#ScriptControllerConfig( "PORT_NAME", num_axes, "lua_script", "PARAMS=") +ScriptControllerConfig("VMC_MOTOR", 1, "vmc.lua", "PORT=VMC") + +ScriptControllerConfig("SOFT_MOTOR", 1, "softMotor.lua", "DRIVE_PV='IOC:m1.VAL', READBACK_PV='IOC:m2.RBV'") + +dbLoadTemplate("motor.substitutions.script") + +iocInit diff --git a/motorApp/Db/ScriptMotorReload.db b/motorApp/Db/ScriptMotorReload.db new file mode 100644 index 00000000..63904454 --- /dev/null +++ b/motorApp/Db/ScriptMotorReload.db @@ -0,0 +1,9 @@ +record(bo, "$(P)$(PORT):ScriptReload") +{ + field(DESC, "$(PORT) Script Reload") + field(DTYP, "asynInt32") + field(OUT, "@asyn($(PORT), 0, 0)RELOAD_SCRIPT") + + field(ZNAM, "Loaded") + field(ONAM, "Reload") +} diff --git a/motorApp/Makefile b/motorApp/Makefile index 36ce18e1..a2d877d7 100644 --- a/motorApp/Makefile +++ b/motorApp/Makefile @@ -105,6 +105,12 @@ MicronixSrc_DEPEND_DIRS = MotorSrc DIRS += PhytronSrc PhytronSrc_DEPEND_DIRS = MotorSrc +# The Script motor support requires the lua scripting module +ifdef SCRIPT +DIRS += ScriptMotorSrc +ScriptMotorSrc_DEPEND_DIRS = MotorSrc +endif + endif # Install the edl files diff --git a/motorApp/ScriptMotorSrc/Makefile b/motorApp/ScriptMotorSrc/Makefile new file mode 100644 index 00000000..e27e5fd6 --- /dev/null +++ b/motorApp/ScriptMotorSrc/Makefile @@ -0,0 +1,30 @@ +# Makefile +TOP=../.. + +include $(TOP)/configure/CONFIG +#---------------------------------------- +# ADD MACRO DEFINITIONS AFTER THIS LINE +#============================= + +#================================================== +# Build an IOC support library +LIBRARY_IOC = ScriptMotor + +# motorRecord.h will be created from motorRecord.dbd +# install devMotorSoft.dbd into /dbd +DBD += ScriptMotorDriver.dbd + +INC += ScriptMotorDriver.h + +# The following are compiled and added to the Support library +ScriptMotor_SRCS += ScriptMotorDriver.cpp + +ScriptMotor_LIBS += motor +ScriptMotor_LIBS += asyn +ScriptMotor_LIBS += script +ScriptMotor_LIBS += $(EPICS_BASE_IOC_LIBS) + +include $(TOP)/configure/RULES +#---------------------------------------- +# ADD RULES AFTER THIS LINE + diff --git a/motorApp/ScriptMotorSrc/ScriptMotorDriver.cpp b/motorApp/ScriptMotorSrc/ScriptMotorDriver.cpp new file mode 100644 index 00000000..bea0d553 --- /dev/null +++ b/motorApp/ScriptMotorSrc/ScriptMotorDriver.cpp @@ -0,0 +1,859 @@ +#include +#include +#include +#include +#include + +#include +#include + +#include + +#include "asynMotorController.h" +#include "asynMotorAxis.h" + +#include +#include "ScriptMotorDriver.h" + +#define NINT(f) (int)((f)>0 ? (f)+0.5 : (f)-0.5) + + +/************************************************ + * These are the ScriptMotorController methods * + ************************************************/ + + +/** Creates a new ScriptMotorController object. + * \param[in] asyn_port The name of the asyn port that will be created for this driver + * \param[in] serial_port The name of the drvAsynSerialPort that was created previously to connect to the VirtualMotor controller + * \param[in] max_axes The number of axes that this controller supports + * \param[in] script_file + * \param[in] params + */ +ScriptMotorController::ScriptMotorController(const char* asyn_port, + int max_axes, + const char* script_file, + const char* params) + : asynMotorController(asyn_port, + max_axes, + 1, // No. ScriptMotorController asyn parameters + 0, // No. additional interfaces beyond those in base class + 0, // No. additional callback interfaces beyond those in base class + ASYN_CANBLOCK | ASYN_MULTIDEVICE, + 1, // autoconnect + 0, // Default priority + 0) // Default stack size +{ + this->script = std::string(script_file); + + if (params) { this->init_params = std::string(params); } + else { this->init_params = std::string(""); } + + this->createParam("RELOAD_SCRIPT", asynParamInt32, &this->ScriptMotorReload); + + for (int axis = 0; axis < max_axes; axis += 1) + { + new ScriptMotorAxis(this, axis, script_file, params); + } + + this->startPoller(this->movingPollPeriod_, this->idlePollPeriod_, this->forcedFastPolls_); +} + +void ScriptMotorController::reload() +{ + this->lock(); + for (int index = 0; index < this->numAxes_; index += 1) + { + ScriptMotorAxis* axis = this->getAxis(index); + axis->reload(this->script.c_str(), this->init_params.c_str()); + } + this->unlock(); + + printf("Controller %s reloaded %s.\n", this->portName, this->script.c_str()); +} + +/** Creates a new ScriptMotorController object. + * Configuration command, called directly or from iocsh + * \param[in] asyn_port The name of the asyn port that will be created for this driver + * \param[in] max_axes The number of axes that this controller supports + * \param[in] script_file + * \param[in] params + */ +extern "C" int ScriptMotorCreateController(const char* asyn_port, + int max_axes, + const char* script_file, + const char* params) +{ + new ScriptMotorController(asyn_port, max_axes, script_file, params); + return(asynSuccess); +} + + +/** Reports on status of the driver + * \param[in] fp The file pointer on which report information will be written + * \param[in] level The level of report detail desired + * + * If details > 0 then information is printed about each axis. + * After printing controller-specific information it calls asynMotorController::report() + */ +void ScriptMotorController::report(FILE *fp, int level) +{ + fprintf(fp, "Script Motor Controller driver %s\n", this->portName); + fprintf(fp, " numAxes=%d\n", numAxes_); + fprintf(fp, " moving poll period=%f\n", movingPollPeriod_); + fprintf(fp, " idle poll period=%f\n", idlePollPeriod_); + + // Call the base class method + asynMotorController::report(fp, level); +} + +asynStatus ScriptMotorController::writeInt32(asynUser *pasynUser, epicsInt32 value) +{ + int function = pasynUser->reason; + + if (function == this->ScriptMotorReload) + { + if (value == 1) { this->reload(); } + return asynSuccess; + } + else + { + return asynMotorController::writeInt32(pasynUser, value); + } +} + +asynStatus ScriptMotorController::setIntegerParam(int list, int function, int value) +{ + if (function >= this->motorStatusDirection_ && function <= this->motorStatusHomed_) + { + ScriptMotorAxis* axis = (ScriptMotorAxis*) this->getAxis(list); + epicsUInt32 status = axis->setStatusParam(function, value); + asynMotorController::setIntegerParam(list, this->motorStatus_, status); + } + + return asynMotorController::setIntegerParam(list, function, value); +} + +asynStatus ScriptMotorController::setDoubleParam(int list, int function, double value) +{ + if (function == this->motorPosition_ || function == this->motorEncoderPosition_) + { + ScriptMotorAxis* axis = (ScriptMotorAxis*) this->getAxis(list); + axis->setPositionParam(function, value); + } + + return asynMotorController::setDoubleParam(list, function, value); +} + +void ScriptMotorController::configAxis(int axisNo, const char* params) +{ + ScriptMotorAxis* axis = this->getAxis(axisNo); + + if (params) { axis->params = std::string(params); } + else { axis->params = std::string(""); } + + axis->config(params); +} + +/** Returns a pointer to an ScriptMotorAxis object. + * Returns NULL if the axis number encoded in pasynUser is invalid. + * \param[in] pasynUser asynUser structure that encodes the axis index number. */ +ScriptMotorAxis* ScriptMotorController::getAxis(asynUser *pasynUser) +{ + return static_cast(asynMotorController::getAxis(pasynUser)); +} + + +/** Returns a pointer to an ScriptMotorAxis object. + * Returns NULL if the axis number encoded in pasynUser is invalid. + * \param[in] axisNo Axis index number. */ +ScriptMotorAxis* ScriptMotorController::getAxis(int axisNo) +{ + return static_cast(asynMotorController::getAxis(axisNo)); +} + + +/****************************************** + * These are the ScriptMotorAxis methods * + ******************************************/ + + +/** Creates a new ScriptMotorAxis object. + * \param[in] pC Pointer to the ScriptMotorController to which this axis belongs. + * \param[in] axisNo Index number of this axis, range 0 to pC->numAxes_-1. + * + * Initializes register numbers, etc. + */ +ScriptMotorAxis::ScriptMotorAxis(ScriptMotorController *pC, int axisNo, const char* script_file, const char* params) + : asynMotorAxis(pC, axisNo), + pC_(pC) +{ + this->initState(script_file); + this->config(params); + + int isnum; + + lua_getglobal(this->state, "MovingPollPeriod"); + double MovingPollPeriod = lua_tonumberx(this->state, -1, &isnum); + if (isnum) { pC->movingPollPeriod_ = MovingPollPeriod; } + lua_remove(this->state, -1); + + lua_getglobal(this->state, "IdlePollPeriod"); + double IdlePollPeriod = lua_tonumberx(this->state, -1, &isnum); + if (isnum) { pC->idlePollPeriod_ = IdlePollPeriod; } + lua_remove(this->state, -1); + + lua_getglobal(this->state, "ForcedFastPolls"); + double ForcedFastPolls = lua_tonumberx(this->state, -1, &isnum); + if (isnum) { pC->forcedFastPolls_ = ForcedFastPolls; } + lua_remove(this->state, -1); + + // Zero the encoder position (this only appears to be a problem on windows) + setDoubleParam(pC_->motorEncoderPosition_, 0.0); + + // Make the changed parameters take effect + callParamCallbacks(); +} + +void ScriptMotorAxis::initState(const char* script_file) +{ + this->state = luaL_newstate(); + int status = luaLoadScript(this->state, script_file); + + if (status) { printf("Error compiling script file: %s\n", script_file); } + + lua_pushstring(this->state, (const char*) this->pC_->portName); + lua_setglobal(this->state, "DRIVER"); + + lua_pushnumber(this->state, axisNo_); + lua_setglobal(this->state, "AXIS"); +} + +void ScriptMotorAxis::reload(const char* script_file, const char* controller_params) +{ + this->initState(script_file); + this->config(controller_params); + this->config(this->params.c_str()); +} + +epicsUInt32 ScriptMotorAxis::setStatusParam(int index, int value) +{ + if (index >= pC_->motorStatusDirection_ && index <= pC_->motorStatusHomed_) + { + epicsUInt32 status = status_.status; + int mask = 1 << (index - pC_->motorStatusDirection_); + + if (value) { status |= mask; } + else { status &= ~mask; } + + if (status != status_.status) + { + status_.status = status; + statusChanged_ = 1; + } + + return status; + } + + return 0; +} + +void ScriptMotorAxis::setPositionParam(int index, double value) +{ + if (index == pC_->motorPosition_) + { + if (value != status_.position) + { + statusChanged_ = 1; + status_.position = value; + } + } + else if (index == pC_->motorEncoderPosition_) + { + if (value != status_.encoderPosition) + { + statusChanged_ = 1; + status_.encoderPosition = value; + } + } +} + + +/* + * + */ +extern "C" int ScriptMotorCreateAxis(const char* ScriptMotorName, int axisNo, const char* params) +{ + static const char *functionName = "VirtualMotorCreateAxis"; + + ScriptMotorController *pC = (ScriptMotorController*) findAsynPortDriver(ScriptMotorName); + if (!pC) + { + printf("Error port %s not found\n", ScriptMotorName); + return asynError; + } + + pC->lock(); + pC->configAxis(axisNo, params); + pC->unlock(); + + return asynSuccess; +} + + +/** Reports on status of the axis + * \param[in] fp The file pointer on which report information will be written + * \param[in] level The level of report detail desired + * + * After printing device-specific information calls asynMotorAxis::report() + */ +void ScriptMotorAxis::report(FILE *fp, int level) +{ + if (level > 0) { + fprintf(fp, " Axis #%d\n", axisNo_); + fprintf(fp, " axisIndex_=%d\n", axisIndex_); + } + + // Call the base class method + asynMotorAxis::report(fp, level); +} + + +/* + * move() is called by asynMotor device support when an absolute or a relative move is requested. + * It can be called multiple times if BDST > 0 or RTRY > 0. + * + * Arguments in terms of motor record fields: + * position (steps) = RVAL = DVAL / MRES + * baseVelocity (steps/s) = VBAS / abs(MRES) + * velocity (step/s) = VELO / abs(MRES) + * acceleration (step/s/s) = (velocity - baseVelocity) / ACCL + */ +asynStatus ScriptMotorAxis::move(double position, int relative, double minVelocity, double maxVelocity, double acceleration) +{ + asynStatus status; + // static const char *functionName = "ScriptMotorAxis::move"; + + int result = lua_getglobal(this->state, "move"); + if (result != LUA_TFUNCTION) + { + // No function in script + } + else + { + lua_pushnumber(this->state, position); + lua_pushboolean(this->state, relative); + lua_pushnumber(this->state, minVelocity); + lua_pushnumber(this->state, maxVelocity); + lua_pushnumber(this->state, acceleration); + + if (lua_pcall(this->state, 5, 1, 0)) + { + this->logError(); + return asynError; + } + + int rettype = lua_type(this->state, -1); + + // Do something with returned value + + lua_pop(this->state, 1); + } + + return asynSuccess; +} + + +/* + * home() is called by asynMotor device support when a home is requested. + * Note: forwards is set by device support, NOT by the motor record. + * + * Arguments in terms of motor record fields: + * minVelocity (steps/s) = VBAS / abs(MRES) + * maxVelocity (step/s) = HVEL / abs(MRES) + * acceleration (step/s/s) = (maxVelocity - minVelocity) / ACCL + * forwards = 1 if HOMF was pressed, 0 if HOMR was pressed + */ + +asynStatus ScriptMotorAxis::home(double minVelocity, double maxVelocity, double acceleration, int forwards) +{ + int result = lua_getglobal(this->state, "home"); + if (result != LUA_TFUNCTION) + { + // No function in script + } + else + { + lua_pushnumber(this->state, minVelocity); + lua_pushnumber(this->state, maxVelocity); + lua_pushnumber(this->state, acceleration); + lua_pushboolean(this->state, forwards); + + if (lua_pcall(this->state, 4, 1, 0)) + { + this->logError(); + return asynError; + } + + int rettype = lua_type(this->state, -1); + + // Do something with returned value + + lua_pop(this->state, 1); + } + + return asynSuccess; +} + + + +/* + * moveVelocity() is called by asynMotor device support when a jog is requested. + * If a controller doesn't have a jog command (or jog commands), this a jog can be simulated here. + * + * Arguments in terms of motor record fields: + * minVelocity (steps/s) = VBAS / abs(MRES) + * maxVelocity (step/s) = (jog_direction == forward) ? JVEL * DIR / MRES : -1 * JVEL * DIR / MRES + * acceleration (step/s/s) = JAR / abs(EGU) + */ +asynStatus ScriptMotorAxis::moveVelocity(double minVelocity, double maxVelocity, double acceleration) +{ + int result = lua_getglobal(this->state, "moveVelocity"); + if (result != LUA_TFUNCTION) + { + // No function in script + } + else + { + lua_pushnumber(this->state, minVelocity); + lua_pushnumber(this->state, maxVelocity); + lua_pushnumber(this->state, acceleration); + + if (lua_pcall(this->state, 3, 1, 0)) + { + this->logError(); + return asynError; + } + + int rettype = lua_type(this->state, -1); + + // Do something with returned value + + lua_pop(this->state, 1); + } + + return asynSuccess; +} + + +/* + * stop() is called by asynMotor device support whenever a user presses the stop button. + * It is also called when the jog button is released. + * + * Arguments in terms of motor record fields: + * acceleration = ??? + */ +asynStatus ScriptMotorAxis::stop(double acceleration) +{ + int result = lua_getglobal(this->state, "stop"); + if (result != LUA_TFUNCTION) + { + // No function in script + } + else + { + lua_pushnumber(this->state, acceleration); + + if (lua_pcall(this->state, 1, 1, 0)) + { + this->logError(); + return asynError; + } + + int rettype = lua_type(this->state, -1); + + // Do something with returned value + + lua_pop(this->state, 1); + } + + return asynSuccess; +} + + +/* + * setPosition() is called by asynMotor device support when a position is redefined. + * It is also required for autosave to restore a position to the controller at iocInit. + * + * Arguments in terms of motor record fields: + * position (steps) = DVAL / MRES = RVAL + */ +asynStatus ScriptMotorAxis::setPosition(double position) +{ + int result = lua_getglobal(this->state, "setPosition"); + if (result != LUA_TFUNCTION) + { + // No function in script + } + else + { + lua_pushnumber(this->state, position); + + if (lua_pcall(this->state, 1, 1, 0)) + { + this->logError(); + return asynError; + } + + int rettype = lua_type(this->state, -1); + + // Do something with returned value + + lua_pop(this->state, 1); + } + + return asynSuccess; +} + +asynStatus ScriptMotorAxis::setEncoderPosition(double position) +{ + int result = lua_getglobal(this->state, "setEncoderPosition"); + if (result != LUA_TFUNCTION) + { + // No function in script + } + else + { + lua_pushnumber(this->state, position); + + if (lua_pcall(this->state, 1, 1, 0)) + { + this->logError(); + return asynError; + } + + int rettype = lua_type(this->state, -1); + + // Do something with returned value + + lua_pop(this->state, 1); + } + + return asynSuccess; +} + +asynStatus ScriptMotorAxis::setHighLimit(double highLimit) +{ + int result = lua_getglobal(this->state, "setHighLimit"); + if (result != LUA_TFUNCTION) + { + // No function in script + } + else + { + lua_pushnumber(this->state, highLimit); + + if (lua_pcall(this->state, 1, 1, 0)) + { + this->logError(); + return asynError; + } + + int rettype = lua_type(this->state, -1); + + // Do something with returned value + + lua_pop(this->state, 1); + } + + return asynSuccess; +} + +asynStatus ScriptMotorAxis::setLowLimit(double lowLimit) +{ + int result = lua_getglobal(this->state, "setLowLimit"); + if (result != LUA_TFUNCTION) + { + // No function in script + } + else + { + lua_pushnumber(this->state, lowLimit); + + if (lua_pcall(this->state, 1, 1, 0)) + { + this->logError(); + return asynError; + } + + int rettype = lua_type(this->state, -1); + + // Do something with returned value + + lua_pop(this->state, 1); + } + + return asynSuccess; +} + + +asynStatus ScriptMotorAxis::setPGain(double PGain) +{ + int result = lua_getglobal(this->state, "setPGain"); + if (result != LUA_TFUNCTION) + { + // No function in script + } + else + { + lua_pushnumber(this->state, PGain); + + if (lua_pcall(this->state, 1, 1, 0)) + { + this->logError(); + return asynError; + } + + int rettype = lua_type(this->state, -1); + + // Do something with returned value + + lua_pop(this->state, 1); + } + + return asynSuccess; +} + +asynStatus ScriptMotorAxis::setIGain(double IGain) +{ + int result = lua_getglobal(this->state, "setIGain"); + if (result != LUA_TFUNCTION) + { + // No function in script + } + else + { + lua_pushnumber(this->state, IGain); + + if (lua_pcall(this->state, 1, 1, 0)) + { + this->logError(); + return asynError; + } + + int rettype = lua_type(this->state, -1); + + // Do something with returned value + + lua_pop(this->state, 1); + } + + return asynSuccess; +} + +asynStatus ScriptMotorAxis::setDGain(double DGain) +{ + int result = lua_getglobal(this->state, "setDGain"); + if (result != LUA_TFUNCTION) + { + // No function in script + } + else + { + lua_pushnumber(this->state, DGain); + + if (lua_pcall(this->state, 1, 1, 0)) + { + this->logError(); + return asynError; + } + + int rettype = lua_type(this->state, -1); + + // Do something with returned value + + lua_pop(this->state, 1); + } + + return asynSuccess; +} + +/* + * setClosedLoop() is called by asynMotor device support when a user enables or disables torque, + * usually from the motorx_all.adl, but only for drivers that set the following params to 1: + * pC->motorStatusGainSupport_ + * pC->motorStatusHasEncoder_ + * What is actually implemented here varies greatly based on the specfics of the controller. + * + * Arguments in terms of motor record fields: + * closedLoop = CNEN + */ + +asynStatus ScriptMotorAxis::setClosedLoop(bool closedLoop) +{ + int result = lua_getglobal(this->state, "setClosedLoop"); + if (result != LUA_TFUNCTION) + { + // No function in script + } + else + { + lua_pushboolean(this->state, (int) closedLoop); + + if (lua_pcall(this->state, 1, 1, 0)) + { + this->logError(); + return asynError; + } + + int rettype = lua_type(this->state, -1); + + // Do something with returned value + + lua_pop(this->state, 1); + } + + return asynSuccess; +} + +asynStatus ScriptMotorAxis::setEncoderRatio(double EncoderRatio) +{ + int result = lua_getglobal(this->state, "setEncoderRatio"); + if (result != LUA_TFUNCTION) + { + // No function in script + } + else + { + lua_pushnumber(this->state, EncoderRatio); + + if (lua_pcall(this->state, 1, 1, 0)) + { + this->logError(); + return asynError; + } + + int rettype = lua_type(this->state, -1); + + // Do something with returned value + + lua_pop(this->state, 1); + } + + return asynSuccess; +} + + + +/** Polls the axis. + * This function reads the motor position, the limit status, the home status, the moving status, + * and the drive power-on status. + * It calls setIntegerParam() and setDoubleParam() for each item that it polls, + * and then calls callParamCallbacks() at the end. + * \param[out] moving A flag that is set indicating that the axis is moving (true) or done (false). */ +asynStatus ScriptMotorAxis::poll(bool *moving) +{ + int result = lua_getglobal(this->state, "poll"); + if (result != LUA_TFUNCTION) + { + // No function in script + } + else + { + if (lua_pcall(this->state, 0, 1, 0)) + { + this->logError(); + return asynError; + } + + int rettype = lua_type(this->state, -1); + + if (rettype == LUA_TBOOLEAN) + { + if (lua_toboolean(this->state, -1)) { *moving = true; } + else { *moving = false; } + } + + lua_pop(this->state, 1); + } + + this->callParamCallbacks(); + return asynSuccess; +} + +void ScriptMotorAxis::config(const char* params) +{ + luaLoadParams(this->state, params); +} + +void ScriptMotorAxis::logError() +{ + std::string err(lua_tostring(this->state, -1)); + lua_pop(this->state, 1); + + printf("%s\n", err.c_str()); +} + +void ScriptMotorReload(const char* port) +{ + ScriptMotorController* controller = (ScriptMotorController*) findAsynPortDriver(port); + + if (controller != NULL) { controller->reload(); } +} + + +/** Code for iocsh registration */ +static const iocshArg ScriptMotorReloadArg0 = {"Motor Port name", iocshArgString}; + +static const iocshArg* const ScriptMotorReloadArgs[] = {&ScriptMotorReloadArg0}; + +static const iocshFuncDef ScriptMotorReloadDef = {"ScriptMotorReload", 1, ScriptMotorReloadArgs}; + +static void ScriptMotorReloadCallFunc(const iocshArgBuf *args) +{ + ScriptMotorReload(args[0].sval); +} + + +static const iocshArg ScriptMotorCreateControllerArg0 = {"Motor Port name", iocshArgString}; +static const iocshArg ScriptMotorCreateControllerArg1 = {"Number of axes", iocshArgInt}; +static const iocshArg ScriptMotorCreateControllerArg2 = {"Control Script", iocshArgString}; +static const iocshArg ScriptMotorCreateControllerArg3 = {"Parameters", iocshArgString}; +static const iocshArg * const ScriptMotorCreateControllerArgs[] = {&ScriptMotorCreateControllerArg0, + &ScriptMotorCreateControllerArg1, + &ScriptMotorCreateControllerArg2, + &ScriptMotorCreateControllerArg3}; +static const iocshFuncDef ScriptMotorCreateControllerDef = {"ScriptControllerConfig", 4, ScriptMotorCreateControllerArgs}; +static void ScriptMotorCreateContollerCallFunc(const iocshArgBuf *args) +{ + ScriptMotorCreateController(args[0].sval, args[1].ival, args[2].sval, args[3].sval); +} + + +static const iocshArg ScriptMotorCreateAxisArg0 = {"Controller port name", iocshArgString}; +static const iocshArg ScriptMotorCreateAxisArg1 = {"Axis number", iocshArgInt}; +static const iocshArg ScriptMotorCreateAxisArg2 = {"Parameters", iocshArgString}; + +static const iocshArg * const ScriptMotorCreateAxisArgs[] = {&ScriptMotorCreateAxisArg0, + &ScriptMotorCreateAxisArg1, + &ScriptMotorCreateAxisArg2}; + +static const iocshFuncDef ScriptMotorCreateAxisDef = {"ScriptAxisConfig", 3, ScriptMotorCreateAxisArgs}; +static void ScriptMotorCreateAxisCallFunc(const iocshArgBuf *args) +{ + ScriptMotorCreateAxis(args[0].sval, args[1].ival, args[2].sval); +} + + + +static void ScriptMotorRegister(void) +{ + iocshRegister(&ScriptMotorReloadDef, ScriptMotorReloadCallFunc); + iocshRegister(&ScriptMotorCreateControllerDef, ScriptMotorCreateContollerCallFunc); + iocshRegister(&ScriptMotorCreateAxisDef, ScriptMotorCreateAxisCallFunc); +} + + +extern "C" { +epicsExportRegistrar(ScriptMotorRegister); +} diff --git a/motorApp/ScriptMotorSrc/ScriptMotorDriver.dbd b/motorApp/ScriptMotorSrc/ScriptMotorDriver.dbd new file mode 100644 index 00000000..8f5bbc23 --- /dev/null +++ b/motorApp/ScriptMotorSrc/ScriptMotorDriver.dbd @@ -0,0 +1 @@ +registrar(ScriptMotorRegister) diff --git a/motorApp/ScriptMotorSrc/ScriptMotorDriver.h b/motorApp/ScriptMotorSrc/ScriptMotorDriver.h new file mode 100644 index 00000000..efa010cd --- /dev/null +++ b/motorApp/ScriptMotorSrc/ScriptMotorDriver.h @@ -0,0 +1,76 @@ +#include "asynMotorController.h" +#include "asynMotorAxis.h" + +#include +#include "epicsScript.h" + +class epicsShareClass ScriptMotorAxis : public asynMotorAxis +{ +public: + /* These are the methods we override from the base class */ + ScriptMotorAxis(class ScriptMotorController *pC, int axisNo, const char* script_file, const char* params); + + void reload(const char* script, const char* params); + + void report(FILE *fp, int level); + + asynStatus move(double position, int relative, double min_velocity, double max_velocity, double acceleration); + asynStatus moveVelocity(double min_velocity, double max_velocity, double acceleration); + asynStatus home(double min_velocity, double max_velocity, double acceleration, int forwards); + asynStatus stop(double acceleration); + asynStatus poll(bool *moving); + asynStatus setPosition(double position); + asynStatus setEncoderPosition(double position); + asynStatus setHighLimit(double highLimit); + asynStatus setLowLimit(double lowLimit); + asynStatus setPGain(double pGain); + asynStatus setIGain(double iGain); + asynStatus setDGain(double dGain); + asynStatus setClosedLoop(bool closedLoop); + asynStatus setEncoderRatio(double ratio); + + virtual epicsUInt32 setStatusParam(int index, int value); + virtual void setPositionParam(int index, double value); + +private: + ScriptMotorController *pC_; /**< Pointer to the asynMotorController to which this axis belongs. + * Abbreviated because it is used very frequently */ + int axisIndex_; + + std::string params; + + lua_State* state; + + void initState(const char* script_file); + void config(const char* params); + void logError(); + +friend class ScriptMotorController; +}; + +class epicsShareClass ScriptMotorController : public asynMotorController { +public: + ScriptMotorController(const char *asyn_port, int max_axes, const char* script_file, const char* params); + + virtual asynStatus setIntegerParam(int list, int function, int value); + virtual asynStatus setDoubleParam(int list, int function, double value); + + virtual asynStatus writeInt32(asynUser *pasynUser, epicsInt32 value); + + void report(FILE *fp, int level); + ScriptMotorAxis* getAxis(asynUser *pasynUser); + ScriptMotorAxis* getAxis(int axisNo); + + void configAxis(int axisNo, const char* params); + + void reload(); + +protected: + int ScriptMotorReload; + +private: + std::string script; + std::string init_params; + +friend class ScriptMotorAxis; +}; From 4b926bf094677f72999639a4024094ef1c0e83ee Mon Sep 17 00:00:00 2001 From: Keenan Lang Date: Wed, 14 Sep 2016 15:24:50 -0500 Subject: [PATCH 03/15] Added reload screen --- motorApp/op/adl/ScriptMotorReload.adl | 140 ++++++++++++++++++++++++++ 1 file changed, 140 insertions(+) create mode 100644 motorApp/op/adl/ScriptMotorReload.adl diff --git a/motorApp/op/adl/ScriptMotorReload.adl b/motorApp/op/adl/ScriptMotorReload.adl new file mode 100644 index 00000000..6f76c4a8 --- /dev/null +++ b/motorApp/op/adl/ScriptMotorReload.adl @@ -0,0 +1,140 @@ + +file { + name="/home/oxygen40/KLANG/Documents/Projects/Repository/git/motor/motorApp/op/adl/ScriptMotorReload.adl" + version=030107 +} +display { + object { + x=663 + y=227 + width=220 + height=75 + } + clr=14 + bclr=4 + cmap="" + gridSpacing=5 + gridOn=0 + snapToGrid=0 +} +"color map" { + ncolors=65 + colors { + ffffff, + ececec, + dadada, + c8c8c8, + bbbbbb, + aeaeae, + 9e9e9e, + 919191, + 858585, + 787878, + 696969, + 5a5a5a, + 464646, + 2d2d2d, + 000000, + 00d800, + 1ebb00, + 339900, + 2d7f00, + 216c00, + fd0000, + de1309, + be190b, + a01207, + 820400, + 5893ff, + 597ee1, + 4b6ec7, + 3a5eab, + 27548d, + fbf34a, + f9da3c, + eeb62b, + e19015, + cd6100, + ffb0ff, + d67fe2, + ae4ebc, + 8b1a96, + 610a75, + a4aaff, + 8793e2, + 6a73c1, + 4d52a4, + 343386, + c7bb6d, + b79d5c, + a47e3c, + 7d5627, + 58340f, + 99ffff, + 73dfff, + 4ea5f9, + 2a63e4, + 0a00b8, + ebf1b5, + d4db9d, + bbc187, + a6a462, + 8b8239, + 73ff6b, + 52da3b, + 3cb420, + 289315, + 1a7309, + } +} +rectangle { + object { + x=0 + y=0 + width=250 + height=25 + } + "basic attribute" { + clr=29 + } +} +"message button" { + object { + x=10 + y=35 + width=200 + height=30 + } + control { + chan="$(P)$(PORT):ScriptReload" + clr=14 + bclr=62 + } + label="Reload $(PORT)" + press_msg="1" +} +rectangle { + object { + x=-7 + y=-7 + width=257 + height=32 + } + "basic attribute" { + clr=14 + fill="outline" + width=3 + } +} +text { + object { + x=5 + y=3 + width=200 + height=20 + } + "basic attribute" { + clr=0 + } + textix="Script Motor Reload" +} From 6d54f6c14af5e04e87819119ca4b85faadbb3254 Mon Sep 17 00:00:00 2001 From: Keenan Lang Date: Wed, 14 Sep 2016 16:23:42 -0500 Subject: [PATCH 04/15] Add function registrars to example binary --- motorExApp/WithAsyn/Makefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/motorExApp/WithAsyn/Makefile b/motorExApp/WithAsyn/Makefile index 7be8e650..1cf02ee5 100644 --- a/motorExApp/WithAsyn/Makefile +++ b/motorExApp/WithAsyn/Makefile @@ -39,6 +39,9 @@ ifdef BUSY endif COMMONDBDS += PI_GCS2Support.dbd COMMONDBDS += phytron.dbd +ifdef SCRIPT +COMMONDBDS += ScriptMotorDriver.dbd +endif DBD += WithAsyn.dbd WithAsyn_DBD += $(COMMONDBDS) From 12aed591ccef9efcc7e33411f86dc29a89f02306 Mon Sep 17 00:00:00 2001 From: Keenan Lang Date: Wed, 14 Sep 2016 16:26:49 -0500 Subject: [PATCH 05/15] Add necessary build libraries --- motorExApp/WithAsyn/Makefile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/motorExApp/WithAsyn/Makefile b/motorExApp/WithAsyn/Makefile index 1cf02ee5..f678e039 100644 --- a/motorExApp/WithAsyn/Makefile +++ b/motorExApp/WithAsyn/Makefile @@ -86,6 +86,10 @@ COMMONLIBS += ACRMotor COMMONLIBS += PI_GCS2Support COMMONLIBS += phytronAxisMotor COMMONLIBS += motor +ifdef SCRIPT +COMMONLIBS += ScriptMotor +COMMONLIBS += script +endif # Needed for Newport SNL programs WithAsyn_LIBS += $(COMMONLIBS) From 09718c6e02f6efbe421b0ac237b28b2d346c4d89 Mon Sep 17 00:00:00 2001 From: Keenan Lang Date: Wed, 14 Sep 2016 16:56:51 -0500 Subject: [PATCH 06/15] minor changes to make scripts work --- iocBoot/iocWithAsyn/scripts/softMotor.lua | 8 +++++++- iocBoot/iocWithAsyn/st.cmd.script | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/iocBoot/iocWithAsyn/scripts/softMotor.lua b/iocBoot/iocWithAsyn/scripts/softMotor.lua index a03e698e..0f6e8fd0 100644 --- a/iocBoot/iocWithAsyn/scripts/softMotor.lua +++ b/iocBoot/iocWithAsyn/scripts/softMotor.lua @@ -1,3 +1,4 @@ +IdlePollPeriod = 1.00 MovingPollPeriod = 0.25 lastPos = 0 @@ -26,9 +27,14 @@ end function poll() - local curr = epics.get(READBACK_PV) local MRES = asyn.getDoubleParam( DRIVER, AXIS, "MOTOR_REC_RESOLUTION") + if (MRES == 0.0) then + return true + end + + local curr = epics.get(READBACK_PV) + asyn.setDoubleParam( DRIVER, AXIS, "MOTOR_POSITION", curr / MRES) local done = 0 diff --git a/iocBoot/iocWithAsyn/st.cmd.script b/iocBoot/iocWithAsyn/st.cmd.script index 995c60a4..a113cde0 100644 --- a/iocBoot/iocWithAsyn/st.cmd.script +++ b/iocBoot/iocWithAsyn/st.cmd.script @@ -11,7 +11,7 @@ drvAsynIPPortConfigure("VMC","127.0.0.1:31337", 0, 0, 0) #ScriptControllerConfig( "PORT_NAME", num_axes, "lua_script", "PARAMS=") ScriptControllerConfig("VMC_MOTOR", 1, "vmc.lua", "PORT=VMC") -ScriptControllerConfig("SOFT_MOTOR", 1, "softMotor.lua", "DRIVE_PV='IOC:m1.VAL', READBACK_PV='IOC:m2.RBV'") +ScriptControllerConfig("SOFT_MOTOR", 1, "softMotor.lua", "DRIVE_PV='IOC:m1.VAL', READBACK_PV='IOC:m1.RBV'") dbLoadTemplate("motor.substitutions.script") From 0b4edac8386b4f4481a946aff86fc776eedb954d Mon Sep 17 00:00:00 2001 From: Keenan Lang Date: Wed, 14 Sep 2016 17:07:20 -0500 Subject: [PATCH 07/15] Add database to top level directory --- motorApp/Db/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/motorApp/Db/Makefile b/motorApp/Db/Makefile index d36a1dca..2c539228 100644 --- a/motorApp/Db/Makefile +++ b/motorApp/Db/Makefile @@ -46,6 +46,7 @@ DB += profileMoveAxisXPS.template DB += PI_Support.db PI_SupportCtrl.db DB += Phytron_motor.db Phytron_I1AM01.db Phytron_MCM01.db DB += asyn_auto_power.db +DB += ScriptMotorReload.db #---------------------------------------------------- # Declare template files which do not show up in DB From 931dc8f1c78d99d8e9a7c00cadd5e45e2d42f6d9 Mon Sep 17 00:00:00 2001 From: Keenan Lang Date: Thu, 15 Sep 2016 09:25:40 -0500 Subject: [PATCH 08/15] Changed c function name to match iocsh function. --- motorApp/ScriptMotorSrc/ScriptMotorDriver.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/motorApp/ScriptMotorSrc/ScriptMotorDriver.cpp b/motorApp/ScriptMotorSrc/ScriptMotorDriver.cpp index bea0d553..d345f8c0 100644 --- a/motorApp/ScriptMotorSrc/ScriptMotorDriver.cpp +++ b/motorApp/ScriptMotorSrc/ScriptMotorDriver.cpp @@ -79,7 +79,7 @@ void ScriptMotorController::reload() * \param[in] script_file * \param[in] params */ -extern "C" int ScriptMotorCreateController(const char* asyn_port, +extern "C" int ScriptControllerConfig(const char* asyn_port, int max_axes, const char* script_file, const char* params) @@ -282,7 +282,7 @@ void ScriptMotorAxis::setPositionParam(int index, double value) /* * */ -extern "C" int ScriptMotorCreateAxis(const char* ScriptMotorName, int axisNo, const char* params) +extern "C" int ScriptAxisConfig(const char* ScriptMotorName, int axisNo, const char* params) { static const char *functionName = "VirtualMotorCreateAxis"; @@ -826,7 +826,7 @@ static const iocshArg * const ScriptMotorCreateControllerArgs[] = {&ScriptMotorC static const iocshFuncDef ScriptMotorCreateControllerDef = {"ScriptControllerConfig", 4, ScriptMotorCreateControllerArgs}; static void ScriptMotorCreateContollerCallFunc(const iocshArgBuf *args) { - ScriptMotorCreateController(args[0].sval, args[1].ival, args[2].sval, args[3].sval); + ScriptControllerConfig(args[0].sval, args[1].ival, args[2].sval, args[3].sval); } @@ -841,7 +841,7 @@ static const iocshArg * const ScriptMotorCreateAxisArgs[] = {&ScriptMotorCreateA static const iocshFuncDef ScriptMotorCreateAxisDef = {"ScriptAxisConfig", 3, ScriptMotorCreateAxisArgs}; static void ScriptMotorCreateAxisCallFunc(const iocshArgBuf *args) { - ScriptMotorCreateAxis(args[0].sval, args[1].ival, args[2].sval); + ScriptAxisConfig(args[0].sval, args[1].ival, args[2].sval); } From c06f414554a746124ec367f3dc12d8c0bad4b792 Mon Sep 17 00:00:00 2001 From: Keenan Lang Date: Thu, 15 Sep 2016 09:43:44 -0500 Subject: [PATCH 09/15] RELEASE file to include message about script module --- configure/RELEASE | 3 +++ 1 file changed, 3 insertions(+) diff --git a/configure/RELEASE b/configure/RELEASE index 003d8fd6..d59ae099 100644 --- a/configure/RELEASE +++ b/configure/RELEASE @@ -37,6 +37,9 @@ EPICS_BASE= # Recommended IPAC release: R2-12 IPAC=$(SUPPORT)/ipac/R2-12 +# Script module needed to build ScriptMotorController +#!SCRIPT=$(SUPPORT)/script + # The following is only needed for the motor examples in iocBoot. #!MOTOR=$(TOP) From 6d114d97652a2e59259bdede928d2256586f171a Mon Sep 17 00:00:00 2001 From: Keenan Lang Date: Wed, 1 Mar 2017 16:39:12 -0600 Subject: [PATCH 10/15] script module API change --- motorApp/ScriptMotorSrc/ScriptMotorDriver.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/motorApp/ScriptMotorSrc/ScriptMotorDriver.cpp b/motorApp/ScriptMotorSrc/ScriptMotorDriver.cpp index d345f8c0..93b8e3d9 100644 --- a/motorApp/ScriptMotorSrc/ScriptMotorDriver.cpp +++ b/motorApp/ScriptMotorSrc/ScriptMotorDriver.cpp @@ -783,7 +783,7 @@ asynStatus ScriptMotorAxis::poll(bool *moving) void ScriptMotorAxis::config(const char* params) { - luaLoadParams(this->state, params); + luaLoadMacros(this->state, params); } void ScriptMotorAxis::logError() From b201e40ee3417dfefa70d9100a453934c3e6e67d Mon Sep 17 00:00:00 2001 From: Mitch D'Ewart Date: Tue, 18 Aug 2015 14:20:34 -0700 Subject: [PATCH 11/15] Changed ACCL calculation when VELO == VBAS. Previously ACCL was only calculated as (VELO-VBAS)/TIME. This could cause problems for drivers setting ACCL=0. Now if VELO == VBAS, ACCL = VELO/TIME. --- motorApp/MotorSrc/motorRecord.cc | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/motorApp/MotorSrc/motorRecord.cc b/motorApp/MotorSrc/motorRecord.cc index 919831c1..25d1930e 100644 --- a/motorApp/MotorSrc/motorRecord.cc +++ b/motorApp/MotorSrc/motorRecord.cc @@ -786,7 +786,7 @@ static long postProcess(motorRecord * pmr) double vbase = pmr->vbas / fabs(pmr->mres); double hpos = 0; double hvel = pmr->hvel / fabs(pmr->mres); - double acc = (hvel - vbase) / pmr->accl; + double acc = (hvel - vbase) > 0 ? ((hvel - vbase)/ pmr->accl): (hvel / pmr->accl); motor_cmnd command; @@ -858,7 +858,7 @@ static long postProcess(motorRecord * pmr) if (pmr->mip & MIP_JOG_STOP) { - double acc = (vel - vbase) / pmr->accl; + double acc = (vel - vbase) > 0 ? ((vel - vbase)/ pmr->accl) : (vel / pmr->accl); if (vel <= vbase) vel = vbase + 1; @@ -875,7 +875,7 @@ static long postProcess(motorRecord * pmr) else { double bvel = pmr->bvel / fabs(pmr->mres); - double bacc = (bvel - vbase) / pmr->bacc; + double bacc = (bvel - vbase) > 0 ? ((bvel - vbase)/ pmr->bacc) : (bvel / pmr->bacc); if (bvel <= vbase) bvel = vbase + 1; @@ -911,7 +911,7 @@ static long postProcess(motorRecord * pmr) /* First part of jog done. Do backlash correction. */ double bvel = pmr->bvel / fabs(pmr->mres); double vbase = pmr->vbas / fabs(pmr->mres); - double bacc = (bvel - vbase) / pmr->bacc; + double bacc = (bvel - vbase) > 0 ? ((bvel - vbase)/ pmr->bacc) : (bvel / pmr->bacc); double bpos = (pmr->dval - pmr->bdst) / pmr->mres; /* Use if encoder or ReadbackLink is in use. */ @@ -1935,7 +1935,7 @@ static RTN_STATUS do_work(motorRecord * pmr, CALLBACK_VALUE proc_ind) vbase = pmr->vbas / fabs(pmr->mres); hvel = pmr->hvel / fabs(pmr->mres); - acc = (hvel - vbase) / pmr->accl; + acc = (hvel - vbase) > 0 ? ((hvel - vbase) / pmr->accl) : (hvel / pmr->accl); hpos = 0; INIT_MSG(); @@ -2147,13 +2147,13 @@ static RTN_STATUS do_work(motorRecord * pmr, CALLBACK_VALUE proc_ind) double newpos = pmr->dval / pmr->mres; /* where to go */ double vbase = pmr->vbas / fabs(pmr->mres); /* base speed */ double vel = pmr->velo / fabs(pmr->mres); /* normal speed */ - double acc = (vel - vbase) / pmr->accl; /* normal accel. */ + double acc = (vel - vbase) > 0 ? ((vel - vbase) / pmr->accl) : (vel / pmr->accl); /* normal accel. */ /* * 'bpos' is one backlash distance away from 'newpos'. */ double bpos = (pmr->dval - pmr->bdst) / pmr->mres; double bvel = pmr->bvel / fabs(pmr->mres); /* backlash speed */ - double bacc = (bvel - vbase) / pmr->bacc; /* backlash accel. */ + double bacc = (bvel - vbase) > 0 ? ((bvel - vbase) / pmr->bacc) : (bvel / pmr->bacc); /* backlash accel. */ bool use_rel, preferred_dir, too_small; double relpos = pmr->diff / pmr->mres; double relbpos = ((pmr->dval - pmr->bdst) - pmr->drbv) / pmr->mres; From a3cd81031a4ae91243071db5fecd039031e2f300 Mon Sep 17 00:00:00 2001 From: kpetersn Date: Wed, 23 Aug 2017 15:36:12 -0500 Subject: [PATCH 12/15] Revert "Merge branch 'master' into master" This reverts commit 3ec6ec433c57165393f6a93c28c139e554cd56a3, reversing changes made to 8966aeabf292874de8c78754e95e14cde1f1c776. --- configure/RELEASE | 3 - .../iocWithAsyn/motor.substitutions.script | 15 - iocBoot/iocWithAsyn/scripts/softMotor.lua | 67 -- iocBoot/iocWithAsyn/scripts/vmc.lua | 66 -- iocBoot/iocWithAsyn/st.cmd.script | 18 - motorApp/Db/Makefile | 1 - motorApp/Db/ScriptMotorReload.db | 9 - motorApp/Makefile | 6 - motorApp/ScriptMotorSrc/Makefile | 30 - motorApp/ScriptMotorSrc/ScriptMotorDriver.cpp | 859 ------------------ motorApp/ScriptMotorSrc/ScriptMotorDriver.dbd | 1 - motorApp/ScriptMotorSrc/ScriptMotorDriver.h | 76 -- motorApp/op/adl/ScriptMotorReload.adl | 140 --- motorExApp/WithAsyn/Makefile | 7 - 14 files changed, 1298 deletions(-) delete mode 100644 iocBoot/iocWithAsyn/motor.substitutions.script delete mode 100644 iocBoot/iocWithAsyn/scripts/softMotor.lua delete mode 100644 iocBoot/iocWithAsyn/scripts/vmc.lua delete mode 100644 iocBoot/iocWithAsyn/st.cmd.script delete mode 100644 motorApp/Db/ScriptMotorReload.db delete mode 100644 motorApp/ScriptMotorSrc/Makefile delete mode 100644 motorApp/ScriptMotorSrc/ScriptMotorDriver.cpp delete mode 100644 motorApp/ScriptMotorSrc/ScriptMotorDriver.dbd delete mode 100644 motorApp/ScriptMotorSrc/ScriptMotorDriver.h delete mode 100644 motorApp/op/adl/ScriptMotorReload.adl diff --git a/configure/RELEASE b/configure/RELEASE index d59ae099..003d8fd6 100644 --- a/configure/RELEASE +++ b/configure/RELEASE @@ -37,9 +37,6 @@ EPICS_BASE= # Recommended IPAC release: R2-12 IPAC=$(SUPPORT)/ipac/R2-12 -# Script module needed to build ScriptMotorController -#!SCRIPT=$(SUPPORT)/script - # The following is only needed for the motor examples in iocBoot. #!MOTOR=$(TOP) diff --git a/iocBoot/iocWithAsyn/motor.substitutions.script b/iocBoot/iocWithAsyn/motor.substitutions.script deleted file mode 100644 index c2f63ea9..00000000 --- a/iocBoot/iocWithAsyn/motor.substitutions.script +++ /dev/null @@ -1,15 +0,0 @@ -file "$(TOP)/db/asyn_motor.db" -{ - pattern - {P, M, DTYP, PORT, ADDR, DESC, EGU, DIR, VMAX, VELO, VBAS, ACCL, BDST, BVEL, BACC, MRES, PREC, DHLM, DLLM, INIT} - {IOC:, m1, "asynMotor", VMC_MOTOR, 0, "VMCMotor", mm, Pos, 15., 3., .05, .5, 0, 1.0, 2, .025, 5, 0, 0, ""} - {IOC:, m2, "asynMotor", SOFT_MOTOR, 0, "SoftMotor", mm, Pos, 15., 3., .05, .5, 0, 1.0, 2, .025, 5, 0, 0, ""} -} - -file "$(TOP)/db/ScriptMotorReload.db" -{ - pattern - {P, PORT} - {IOC:, SOFT_MOTOR} - {IOC:, VMC_MOTOR} -} diff --git a/iocBoot/iocWithAsyn/scripts/softMotor.lua b/iocBoot/iocWithAsyn/scripts/softMotor.lua deleted file mode 100644 index 0f6e8fd0..00000000 --- a/iocBoot/iocWithAsyn/scripts/softMotor.lua +++ /dev/null @@ -1,67 +0,0 @@ -IdlePollPeriod = 1.00 -MovingPollPeriod = 0.25 - -lastPos = 0 -targetPos = 0 - -function move(position, relative, minVel, maxVel, accel) - local MRES = asyn.getDoubleParam( DRIVER, AXIS, "MOTOR_REC_RESOLUTION") - - if (relative) then - local prev = asyn.getDoubleParam( DRIVER, AXIS, "MOTOR_POSITION") - targetPos = prev + (position * MRES) - else - targetPos = (position * MRES) - end - - epics.put(DRIVE_PV, targetPos) - - if (position > 0) then - asyn.setIntegerParam( DRIVER, AXIS, "MOTOR_STATUS_DIRECTION", 1) - else - asyn.setIntegerParam( DRIVER, AXIS, "MOTOR_STATUS_DIRECTION", 0) - end - - asyn.callParamCallbacks(DRIVER, AXIS) -end - - -function poll() - local MRES = asyn.getDoubleParam( DRIVER, AXIS, "MOTOR_REC_RESOLUTION") - - if (MRES == 0.0) then - return true - end - - local curr = epics.get(READBACK_PV) - - asyn.setDoubleParam( DRIVER, AXIS, "MOTOR_POSITION", curr / MRES) - - local done = 0 - local moving = 1 - - if (curr == targetPos) then - done = 1 - moving = 0 - elseif (math.abs(curr - targetPos) <= MRES and lastPos == curr) then - done = 1 - moving = 0 - end - - lastPos = curr - - asyn.setIntegerParam( DRIVER, AXIS, "MOTOR_STATUS_DONE", done) - asyn.setIntegerParam( DRIVER, AXIS, "MOTOR_STATUS_MOVING", moving) - - asyn.callParamCallbacks(DRIVER, AXIS) - - return (done ~= 1) -end - - -function stop(acceleration) - local curr = asyn.getDoubleParam( DRIVER, AXIS, "MOTOR_POSITION") - - epics.put(DRIVE_PV, curr) - targetPos = curr -end diff --git a/iocBoot/iocWithAsyn/scripts/vmc.lua b/iocBoot/iocWithAsyn/scripts/vmc.lua deleted file mode 100644 index 46ff05fe..00000000 --- a/iocBoot/iocWithAsyn/scripts/vmc.lua +++ /dev/null @@ -1,66 +0,0 @@ -IdlePollPeriod = 1.0 -MovingPollPeriod = 0.25 -ForcedFastPolls = 2 - -InTerminator = "\r\n" -OutTerminator = "\r\n" - -function sendAccelAndVelocity(minVel, maxVel, accel) - asyn.writeread( string.format( "%d BAS %f", AXIS + 1, minVel) , PORT); - asyn.writeread( string.format( "%d VEL %f", AXIS + 1, maxVel) , PORT); - asyn.writeread( string.format( "%d ACC %f", AXIS + 1, accel ) , PORT); -end - - -function move(position, relative, minVel, maxVel, accel) - sendAccelAndVelocity( minVel, maxVel, accel) - - if (relative) then - asyn.writeread( string.format( "%d MR %d", AXIS + 1, math.floor(position) ) , PORT) - else - asyn.writeread( string.format( "%d MV %d", AXIS + 1, math.floor(position) ) , PORT) - end -end - - -function moveVelocity(minVel, maxVel, accel) - sendAccelAndVelocity( minVel, maxVel, accel) - - asyn.writeread( string.format( "%d JOG %f", AXIS + 1, maxVel) , PORT); -end - - -function poll() - asyn.write( string.format( "%d POS?", AXIS + 1) , PORT) - - asyn.setDoubleParam( DRIVER, AXIS, "MOTOR_POSITION", tonumber( asyn.read(PORT) ) ) - - asyn.write( string.format( "%d ST?", AXIS + 1) , PORT) - - local status = tonumber( asyn.read(PORT) ) - - local direction = (status & 1) - local done = (status & 2) >> 1 - local limit_high = (status & 8) >> 3 - local limit_low = (status & 16) >> 4 - - asyn.setIntegerParam( DRIVER, AXIS, "MOTOR_STATUS_DIRECTION", direction) - asyn.setIntegerParam( DRIVER, AXIS, "MOTOR_STATUS_DONE", done) - asyn.setIntegerParam( DRIVER, AXIS, "MOTOR_STATUS_MOVING", done ~ 1) - asyn.setIntegerParam( DRIVER, AXIS, "MOTOR_STATUS_HIGH_LIMIT", limit_high) - asyn.setIntegerParam( DRIVER, AXIS, "MOTOR_STATUS_LOW_LIMIT", limit_low) - - asyn.callParamCallbacks(DRIVER, AXIS) - - return (done ~= 1) -end - - -function stop(acceleration) - asyn.writeread( string.format( "%d AB", AXIS + 1) , PORT); -end - - -function setPosition(position) - asyn.writeread( string.format( "%d POS %d", AXIS + 1, math.floor(position) ) , PORT); -end diff --git a/iocBoot/iocWithAsyn/st.cmd.script b/iocBoot/iocWithAsyn/st.cmd.script deleted file mode 100644 index a113cde0..00000000 --- a/iocBoot/iocWithAsyn/st.cmd.script +++ /dev/null @@ -1,18 +0,0 @@ -< envPaths - -dbLoadDatabase("$(TOP)/dbd/WithAsyn.dbd") -WithAsyn_registerRecordDeviceDriver(pdbbase) - -epicsEnvSet("LUA_SCRIPT_PATH", "./scripts") - -# Connect to virtual motor controller server -drvAsynIPPortConfigure("VMC","127.0.0.1:31337", 0, 0, 0) - -#ScriptControllerConfig( "PORT_NAME", num_axes, "lua_script", "PARAMS=") -ScriptControllerConfig("VMC_MOTOR", 1, "vmc.lua", "PORT=VMC") - -ScriptControllerConfig("SOFT_MOTOR", 1, "softMotor.lua", "DRIVE_PV='IOC:m1.VAL', READBACK_PV='IOC:m1.RBV'") - -dbLoadTemplate("motor.substitutions.script") - -iocInit diff --git a/motorApp/Db/Makefile b/motorApp/Db/Makefile index 2c539228..d36a1dca 100644 --- a/motorApp/Db/Makefile +++ b/motorApp/Db/Makefile @@ -46,7 +46,6 @@ DB += profileMoveAxisXPS.template DB += PI_Support.db PI_SupportCtrl.db DB += Phytron_motor.db Phytron_I1AM01.db Phytron_MCM01.db DB += asyn_auto_power.db -DB += ScriptMotorReload.db #---------------------------------------------------- # Declare template files which do not show up in DB diff --git a/motorApp/Db/ScriptMotorReload.db b/motorApp/Db/ScriptMotorReload.db deleted file mode 100644 index 63904454..00000000 --- a/motorApp/Db/ScriptMotorReload.db +++ /dev/null @@ -1,9 +0,0 @@ -record(bo, "$(P)$(PORT):ScriptReload") -{ - field(DESC, "$(PORT) Script Reload") - field(DTYP, "asynInt32") - field(OUT, "@asyn($(PORT), 0, 0)RELOAD_SCRIPT") - - field(ZNAM, "Loaded") - field(ONAM, "Reload") -} diff --git a/motorApp/Makefile b/motorApp/Makefile index 78fc0593..35d18e15 100644 --- a/motorApp/Makefile +++ b/motorApp/Makefile @@ -108,12 +108,6 @@ PhytronSrc_DEPEND_DIRS = MotorSrc DIRS += AMCISrc AMCISrc_DEPEND_DIRS = MotorSrc -# The Script motor support requires the lua scripting module -ifdef SCRIPT -DIRS += ScriptMotorSrc -ScriptMotorSrc_DEPEND_DIRS = MotorSrc -endif - endif # Install the edl files diff --git a/motorApp/ScriptMotorSrc/Makefile b/motorApp/ScriptMotorSrc/Makefile deleted file mode 100644 index e27e5fd6..00000000 --- a/motorApp/ScriptMotorSrc/Makefile +++ /dev/null @@ -1,30 +0,0 @@ -# Makefile -TOP=../.. - -include $(TOP)/configure/CONFIG -#---------------------------------------- -# ADD MACRO DEFINITIONS AFTER THIS LINE -#============================= - -#================================================== -# Build an IOC support library -LIBRARY_IOC = ScriptMotor - -# motorRecord.h will be created from motorRecord.dbd -# install devMotorSoft.dbd into /dbd -DBD += ScriptMotorDriver.dbd - -INC += ScriptMotorDriver.h - -# The following are compiled and added to the Support library -ScriptMotor_SRCS += ScriptMotorDriver.cpp - -ScriptMotor_LIBS += motor -ScriptMotor_LIBS += asyn -ScriptMotor_LIBS += script -ScriptMotor_LIBS += $(EPICS_BASE_IOC_LIBS) - -include $(TOP)/configure/RULES -#---------------------------------------- -# ADD RULES AFTER THIS LINE - diff --git a/motorApp/ScriptMotorSrc/ScriptMotorDriver.cpp b/motorApp/ScriptMotorSrc/ScriptMotorDriver.cpp deleted file mode 100644 index 93b8e3d9..00000000 --- a/motorApp/ScriptMotorSrc/ScriptMotorDriver.cpp +++ /dev/null @@ -1,859 +0,0 @@ -#include -#include -#include -#include -#include - -#include -#include - -#include - -#include "asynMotorController.h" -#include "asynMotorAxis.h" - -#include -#include "ScriptMotorDriver.h" - -#define NINT(f) (int)((f)>0 ? (f)+0.5 : (f)-0.5) - - -/************************************************ - * These are the ScriptMotorController methods * - ************************************************/ - - -/** Creates a new ScriptMotorController object. - * \param[in] asyn_port The name of the asyn port that will be created for this driver - * \param[in] serial_port The name of the drvAsynSerialPort that was created previously to connect to the VirtualMotor controller - * \param[in] max_axes The number of axes that this controller supports - * \param[in] script_file - * \param[in] params - */ -ScriptMotorController::ScriptMotorController(const char* asyn_port, - int max_axes, - const char* script_file, - const char* params) - : asynMotorController(asyn_port, - max_axes, - 1, // No. ScriptMotorController asyn parameters - 0, // No. additional interfaces beyond those in base class - 0, // No. additional callback interfaces beyond those in base class - ASYN_CANBLOCK | ASYN_MULTIDEVICE, - 1, // autoconnect - 0, // Default priority - 0) // Default stack size -{ - this->script = std::string(script_file); - - if (params) { this->init_params = std::string(params); } - else { this->init_params = std::string(""); } - - this->createParam("RELOAD_SCRIPT", asynParamInt32, &this->ScriptMotorReload); - - for (int axis = 0; axis < max_axes; axis += 1) - { - new ScriptMotorAxis(this, axis, script_file, params); - } - - this->startPoller(this->movingPollPeriod_, this->idlePollPeriod_, this->forcedFastPolls_); -} - -void ScriptMotorController::reload() -{ - this->lock(); - for (int index = 0; index < this->numAxes_; index += 1) - { - ScriptMotorAxis* axis = this->getAxis(index); - axis->reload(this->script.c_str(), this->init_params.c_str()); - } - this->unlock(); - - printf("Controller %s reloaded %s.\n", this->portName, this->script.c_str()); -} - -/** Creates a new ScriptMotorController object. - * Configuration command, called directly or from iocsh - * \param[in] asyn_port The name of the asyn port that will be created for this driver - * \param[in] max_axes The number of axes that this controller supports - * \param[in] script_file - * \param[in] params - */ -extern "C" int ScriptControllerConfig(const char* asyn_port, - int max_axes, - const char* script_file, - const char* params) -{ - new ScriptMotorController(asyn_port, max_axes, script_file, params); - return(asynSuccess); -} - - -/** Reports on status of the driver - * \param[in] fp The file pointer on which report information will be written - * \param[in] level The level of report detail desired - * - * If details > 0 then information is printed about each axis. - * After printing controller-specific information it calls asynMotorController::report() - */ -void ScriptMotorController::report(FILE *fp, int level) -{ - fprintf(fp, "Script Motor Controller driver %s\n", this->portName); - fprintf(fp, " numAxes=%d\n", numAxes_); - fprintf(fp, " moving poll period=%f\n", movingPollPeriod_); - fprintf(fp, " idle poll period=%f\n", idlePollPeriod_); - - // Call the base class method - asynMotorController::report(fp, level); -} - -asynStatus ScriptMotorController::writeInt32(asynUser *pasynUser, epicsInt32 value) -{ - int function = pasynUser->reason; - - if (function == this->ScriptMotorReload) - { - if (value == 1) { this->reload(); } - return asynSuccess; - } - else - { - return asynMotorController::writeInt32(pasynUser, value); - } -} - -asynStatus ScriptMotorController::setIntegerParam(int list, int function, int value) -{ - if (function >= this->motorStatusDirection_ && function <= this->motorStatusHomed_) - { - ScriptMotorAxis* axis = (ScriptMotorAxis*) this->getAxis(list); - epicsUInt32 status = axis->setStatusParam(function, value); - asynMotorController::setIntegerParam(list, this->motorStatus_, status); - } - - return asynMotorController::setIntegerParam(list, function, value); -} - -asynStatus ScriptMotorController::setDoubleParam(int list, int function, double value) -{ - if (function == this->motorPosition_ || function == this->motorEncoderPosition_) - { - ScriptMotorAxis* axis = (ScriptMotorAxis*) this->getAxis(list); - axis->setPositionParam(function, value); - } - - return asynMotorController::setDoubleParam(list, function, value); -} - -void ScriptMotorController::configAxis(int axisNo, const char* params) -{ - ScriptMotorAxis* axis = this->getAxis(axisNo); - - if (params) { axis->params = std::string(params); } - else { axis->params = std::string(""); } - - axis->config(params); -} - -/** Returns a pointer to an ScriptMotorAxis object. - * Returns NULL if the axis number encoded in pasynUser is invalid. - * \param[in] pasynUser asynUser structure that encodes the axis index number. */ -ScriptMotorAxis* ScriptMotorController::getAxis(asynUser *pasynUser) -{ - return static_cast(asynMotorController::getAxis(pasynUser)); -} - - -/** Returns a pointer to an ScriptMotorAxis object. - * Returns NULL if the axis number encoded in pasynUser is invalid. - * \param[in] axisNo Axis index number. */ -ScriptMotorAxis* ScriptMotorController::getAxis(int axisNo) -{ - return static_cast(asynMotorController::getAxis(axisNo)); -} - - -/****************************************** - * These are the ScriptMotorAxis methods * - ******************************************/ - - -/** Creates a new ScriptMotorAxis object. - * \param[in] pC Pointer to the ScriptMotorController to which this axis belongs. - * \param[in] axisNo Index number of this axis, range 0 to pC->numAxes_-1. - * - * Initializes register numbers, etc. - */ -ScriptMotorAxis::ScriptMotorAxis(ScriptMotorController *pC, int axisNo, const char* script_file, const char* params) - : asynMotorAxis(pC, axisNo), - pC_(pC) -{ - this->initState(script_file); - this->config(params); - - int isnum; - - lua_getglobal(this->state, "MovingPollPeriod"); - double MovingPollPeriod = lua_tonumberx(this->state, -1, &isnum); - if (isnum) { pC->movingPollPeriod_ = MovingPollPeriod; } - lua_remove(this->state, -1); - - lua_getglobal(this->state, "IdlePollPeriod"); - double IdlePollPeriod = lua_tonumberx(this->state, -1, &isnum); - if (isnum) { pC->idlePollPeriod_ = IdlePollPeriod; } - lua_remove(this->state, -1); - - lua_getglobal(this->state, "ForcedFastPolls"); - double ForcedFastPolls = lua_tonumberx(this->state, -1, &isnum); - if (isnum) { pC->forcedFastPolls_ = ForcedFastPolls; } - lua_remove(this->state, -1); - - // Zero the encoder position (this only appears to be a problem on windows) - setDoubleParam(pC_->motorEncoderPosition_, 0.0); - - // Make the changed parameters take effect - callParamCallbacks(); -} - -void ScriptMotorAxis::initState(const char* script_file) -{ - this->state = luaL_newstate(); - int status = luaLoadScript(this->state, script_file); - - if (status) { printf("Error compiling script file: %s\n", script_file); } - - lua_pushstring(this->state, (const char*) this->pC_->portName); - lua_setglobal(this->state, "DRIVER"); - - lua_pushnumber(this->state, axisNo_); - lua_setglobal(this->state, "AXIS"); -} - -void ScriptMotorAxis::reload(const char* script_file, const char* controller_params) -{ - this->initState(script_file); - this->config(controller_params); - this->config(this->params.c_str()); -} - -epicsUInt32 ScriptMotorAxis::setStatusParam(int index, int value) -{ - if (index >= pC_->motorStatusDirection_ && index <= pC_->motorStatusHomed_) - { - epicsUInt32 status = status_.status; - int mask = 1 << (index - pC_->motorStatusDirection_); - - if (value) { status |= mask; } - else { status &= ~mask; } - - if (status != status_.status) - { - status_.status = status; - statusChanged_ = 1; - } - - return status; - } - - return 0; -} - -void ScriptMotorAxis::setPositionParam(int index, double value) -{ - if (index == pC_->motorPosition_) - { - if (value != status_.position) - { - statusChanged_ = 1; - status_.position = value; - } - } - else if (index == pC_->motorEncoderPosition_) - { - if (value != status_.encoderPosition) - { - statusChanged_ = 1; - status_.encoderPosition = value; - } - } -} - - -/* - * - */ -extern "C" int ScriptAxisConfig(const char* ScriptMotorName, int axisNo, const char* params) -{ - static const char *functionName = "VirtualMotorCreateAxis"; - - ScriptMotorController *pC = (ScriptMotorController*) findAsynPortDriver(ScriptMotorName); - if (!pC) - { - printf("Error port %s not found\n", ScriptMotorName); - return asynError; - } - - pC->lock(); - pC->configAxis(axisNo, params); - pC->unlock(); - - return asynSuccess; -} - - -/** Reports on status of the axis - * \param[in] fp The file pointer on which report information will be written - * \param[in] level The level of report detail desired - * - * After printing device-specific information calls asynMotorAxis::report() - */ -void ScriptMotorAxis::report(FILE *fp, int level) -{ - if (level > 0) { - fprintf(fp, " Axis #%d\n", axisNo_); - fprintf(fp, " axisIndex_=%d\n", axisIndex_); - } - - // Call the base class method - asynMotorAxis::report(fp, level); -} - - -/* - * move() is called by asynMotor device support when an absolute or a relative move is requested. - * It can be called multiple times if BDST > 0 or RTRY > 0. - * - * Arguments in terms of motor record fields: - * position (steps) = RVAL = DVAL / MRES - * baseVelocity (steps/s) = VBAS / abs(MRES) - * velocity (step/s) = VELO / abs(MRES) - * acceleration (step/s/s) = (velocity - baseVelocity) / ACCL - */ -asynStatus ScriptMotorAxis::move(double position, int relative, double minVelocity, double maxVelocity, double acceleration) -{ - asynStatus status; - // static const char *functionName = "ScriptMotorAxis::move"; - - int result = lua_getglobal(this->state, "move"); - if (result != LUA_TFUNCTION) - { - // No function in script - } - else - { - lua_pushnumber(this->state, position); - lua_pushboolean(this->state, relative); - lua_pushnumber(this->state, minVelocity); - lua_pushnumber(this->state, maxVelocity); - lua_pushnumber(this->state, acceleration); - - if (lua_pcall(this->state, 5, 1, 0)) - { - this->logError(); - return asynError; - } - - int rettype = lua_type(this->state, -1); - - // Do something with returned value - - lua_pop(this->state, 1); - } - - return asynSuccess; -} - - -/* - * home() is called by asynMotor device support when a home is requested. - * Note: forwards is set by device support, NOT by the motor record. - * - * Arguments in terms of motor record fields: - * minVelocity (steps/s) = VBAS / abs(MRES) - * maxVelocity (step/s) = HVEL / abs(MRES) - * acceleration (step/s/s) = (maxVelocity - minVelocity) / ACCL - * forwards = 1 if HOMF was pressed, 0 if HOMR was pressed - */ - -asynStatus ScriptMotorAxis::home(double minVelocity, double maxVelocity, double acceleration, int forwards) -{ - int result = lua_getglobal(this->state, "home"); - if (result != LUA_TFUNCTION) - { - // No function in script - } - else - { - lua_pushnumber(this->state, minVelocity); - lua_pushnumber(this->state, maxVelocity); - lua_pushnumber(this->state, acceleration); - lua_pushboolean(this->state, forwards); - - if (lua_pcall(this->state, 4, 1, 0)) - { - this->logError(); - return asynError; - } - - int rettype = lua_type(this->state, -1); - - // Do something with returned value - - lua_pop(this->state, 1); - } - - return asynSuccess; -} - - - -/* - * moveVelocity() is called by asynMotor device support when a jog is requested. - * If a controller doesn't have a jog command (or jog commands), this a jog can be simulated here. - * - * Arguments in terms of motor record fields: - * minVelocity (steps/s) = VBAS / abs(MRES) - * maxVelocity (step/s) = (jog_direction == forward) ? JVEL * DIR / MRES : -1 * JVEL * DIR / MRES - * acceleration (step/s/s) = JAR / abs(EGU) - */ -asynStatus ScriptMotorAxis::moveVelocity(double minVelocity, double maxVelocity, double acceleration) -{ - int result = lua_getglobal(this->state, "moveVelocity"); - if (result != LUA_TFUNCTION) - { - // No function in script - } - else - { - lua_pushnumber(this->state, minVelocity); - lua_pushnumber(this->state, maxVelocity); - lua_pushnumber(this->state, acceleration); - - if (lua_pcall(this->state, 3, 1, 0)) - { - this->logError(); - return asynError; - } - - int rettype = lua_type(this->state, -1); - - // Do something with returned value - - lua_pop(this->state, 1); - } - - return asynSuccess; -} - - -/* - * stop() is called by asynMotor device support whenever a user presses the stop button. - * It is also called when the jog button is released. - * - * Arguments in terms of motor record fields: - * acceleration = ??? - */ -asynStatus ScriptMotorAxis::stop(double acceleration) -{ - int result = lua_getglobal(this->state, "stop"); - if (result != LUA_TFUNCTION) - { - // No function in script - } - else - { - lua_pushnumber(this->state, acceleration); - - if (lua_pcall(this->state, 1, 1, 0)) - { - this->logError(); - return asynError; - } - - int rettype = lua_type(this->state, -1); - - // Do something with returned value - - lua_pop(this->state, 1); - } - - return asynSuccess; -} - - -/* - * setPosition() is called by asynMotor device support when a position is redefined. - * It is also required for autosave to restore a position to the controller at iocInit. - * - * Arguments in terms of motor record fields: - * position (steps) = DVAL / MRES = RVAL - */ -asynStatus ScriptMotorAxis::setPosition(double position) -{ - int result = lua_getglobal(this->state, "setPosition"); - if (result != LUA_TFUNCTION) - { - // No function in script - } - else - { - lua_pushnumber(this->state, position); - - if (lua_pcall(this->state, 1, 1, 0)) - { - this->logError(); - return asynError; - } - - int rettype = lua_type(this->state, -1); - - // Do something with returned value - - lua_pop(this->state, 1); - } - - return asynSuccess; -} - -asynStatus ScriptMotorAxis::setEncoderPosition(double position) -{ - int result = lua_getglobal(this->state, "setEncoderPosition"); - if (result != LUA_TFUNCTION) - { - // No function in script - } - else - { - lua_pushnumber(this->state, position); - - if (lua_pcall(this->state, 1, 1, 0)) - { - this->logError(); - return asynError; - } - - int rettype = lua_type(this->state, -1); - - // Do something with returned value - - lua_pop(this->state, 1); - } - - return asynSuccess; -} - -asynStatus ScriptMotorAxis::setHighLimit(double highLimit) -{ - int result = lua_getglobal(this->state, "setHighLimit"); - if (result != LUA_TFUNCTION) - { - // No function in script - } - else - { - lua_pushnumber(this->state, highLimit); - - if (lua_pcall(this->state, 1, 1, 0)) - { - this->logError(); - return asynError; - } - - int rettype = lua_type(this->state, -1); - - // Do something with returned value - - lua_pop(this->state, 1); - } - - return asynSuccess; -} - -asynStatus ScriptMotorAxis::setLowLimit(double lowLimit) -{ - int result = lua_getglobal(this->state, "setLowLimit"); - if (result != LUA_TFUNCTION) - { - // No function in script - } - else - { - lua_pushnumber(this->state, lowLimit); - - if (lua_pcall(this->state, 1, 1, 0)) - { - this->logError(); - return asynError; - } - - int rettype = lua_type(this->state, -1); - - // Do something with returned value - - lua_pop(this->state, 1); - } - - return asynSuccess; -} - - -asynStatus ScriptMotorAxis::setPGain(double PGain) -{ - int result = lua_getglobal(this->state, "setPGain"); - if (result != LUA_TFUNCTION) - { - // No function in script - } - else - { - lua_pushnumber(this->state, PGain); - - if (lua_pcall(this->state, 1, 1, 0)) - { - this->logError(); - return asynError; - } - - int rettype = lua_type(this->state, -1); - - // Do something with returned value - - lua_pop(this->state, 1); - } - - return asynSuccess; -} - -asynStatus ScriptMotorAxis::setIGain(double IGain) -{ - int result = lua_getglobal(this->state, "setIGain"); - if (result != LUA_TFUNCTION) - { - // No function in script - } - else - { - lua_pushnumber(this->state, IGain); - - if (lua_pcall(this->state, 1, 1, 0)) - { - this->logError(); - return asynError; - } - - int rettype = lua_type(this->state, -1); - - // Do something with returned value - - lua_pop(this->state, 1); - } - - return asynSuccess; -} - -asynStatus ScriptMotorAxis::setDGain(double DGain) -{ - int result = lua_getglobal(this->state, "setDGain"); - if (result != LUA_TFUNCTION) - { - // No function in script - } - else - { - lua_pushnumber(this->state, DGain); - - if (lua_pcall(this->state, 1, 1, 0)) - { - this->logError(); - return asynError; - } - - int rettype = lua_type(this->state, -1); - - // Do something with returned value - - lua_pop(this->state, 1); - } - - return asynSuccess; -} - -/* - * setClosedLoop() is called by asynMotor device support when a user enables or disables torque, - * usually from the motorx_all.adl, but only for drivers that set the following params to 1: - * pC->motorStatusGainSupport_ - * pC->motorStatusHasEncoder_ - * What is actually implemented here varies greatly based on the specfics of the controller. - * - * Arguments in terms of motor record fields: - * closedLoop = CNEN - */ - -asynStatus ScriptMotorAxis::setClosedLoop(bool closedLoop) -{ - int result = lua_getglobal(this->state, "setClosedLoop"); - if (result != LUA_TFUNCTION) - { - // No function in script - } - else - { - lua_pushboolean(this->state, (int) closedLoop); - - if (lua_pcall(this->state, 1, 1, 0)) - { - this->logError(); - return asynError; - } - - int rettype = lua_type(this->state, -1); - - // Do something with returned value - - lua_pop(this->state, 1); - } - - return asynSuccess; -} - -asynStatus ScriptMotorAxis::setEncoderRatio(double EncoderRatio) -{ - int result = lua_getglobal(this->state, "setEncoderRatio"); - if (result != LUA_TFUNCTION) - { - // No function in script - } - else - { - lua_pushnumber(this->state, EncoderRatio); - - if (lua_pcall(this->state, 1, 1, 0)) - { - this->logError(); - return asynError; - } - - int rettype = lua_type(this->state, -1); - - // Do something with returned value - - lua_pop(this->state, 1); - } - - return asynSuccess; -} - - - -/** Polls the axis. - * This function reads the motor position, the limit status, the home status, the moving status, - * and the drive power-on status. - * It calls setIntegerParam() and setDoubleParam() for each item that it polls, - * and then calls callParamCallbacks() at the end. - * \param[out] moving A flag that is set indicating that the axis is moving (true) or done (false). */ -asynStatus ScriptMotorAxis::poll(bool *moving) -{ - int result = lua_getglobal(this->state, "poll"); - if (result != LUA_TFUNCTION) - { - // No function in script - } - else - { - if (lua_pcall(this->state, 0, 1, 0)) - { - this->logError(); - return asynError; - } - - int rettype = lua_type(this->state, -1); - - if (rettype == LUA_TBOOLEAN) - { - if (lua_toboolean(this->state, -1)) { *moving = true; } - else { *moving = false; } - } - - lua_pop(this->state, 1); - } - - this->callParamCallbacks(); - return asynSuccess; -} - -void ScriptMotorAxis::config(const char* params) -{ - luaLoadMacros(this->state, params); -} - -void ScriptMotorAxis::logError() -{ - std::string err(lua_tostring(this->state, -1)); - lua_pop(this->state, 1); - - printf("%s\n", err.c_str()); -} - -void ScriptMotorReload(const char* port) -{ - ScriptMotorController* controller = (ScriptMotorController*) findAsynPortDriver(port); - - if (controller != NULL) { controller->reload(); } -} - - -/** Code for iocsh registration */ -static const iocshArg ScriptMotorReloadArg0 = {"Motor Port name", iocshArgString}; - -static const iocshArg* const ScriptMotorReloadArgs[] = {&ScriptMotorReloadArg0}; - -static const iocshFuncDef ScriptMotorReloadDef = {"ScriptMotorReload", 1, ScriptMotorReloadArgs}; - -static void ScriptMotorReloadCallFunc(const iocshArgBuf *args) -{ - ScriptMotorReload(args[0].sval); -} - - -static const iocshArg ScriptMotorCreateControllerArg0 = {"Motor Port name", iocshArgString}; -static const iocshArg ScriptMotorCreateControllerArg1 = {"Number of axes", iocshArgInt}; -static const iocshArg ScriptMotorCreateControllerArg2 = {"Control Script", iocshArgString}; -static const iocshArg ScriptMotorCreateControllerArg3 = {"Parameters", iocshArgString}; -static const iocshArg * const ScriptMotorCreateControllerArgs[] = {&ScriptMotorCreateControllerArg0, - &ScriptMotorCreateControllerArg1, - &ScriptMotorCreateControllerArg2, - &ScriptMotorCreateControllerArg3}; -static const iocshFuncDef ScriptMotorCreateControllerDef = {"ScriptControllerConfig", 4, ScriptMotorCreateControllerArgs}; -static void ScriptMotorCreateContollerCallFunc(const iocshArgBuf *args) -{ - ScriptControllerConfig(args[0].sval, args[1].ival, args[2].sval, args[3].sval); -} - - -static const iocshArg ScriptMotorCreateAxisArg0 = {"Controller port name", iocshArgString}; -static const iocshArg ScriptMotorCreateAxisArg1 = {"Axis number", iocshArgInt}; -static const iocshArg ScriptMotorCreateAxisArg2 = {"Parameters", iocshArgString}; - -static const iocshArg * const ScriptMotorCreateAxisArgs[] = {&ScriptMotorCreateAxisArg0, - &ScriptMotorCreateAxisArg1, - &ScriptMotorCreateAxisArg2}; - -static const iocshFuncDef ScriptMotorCreateAxisDef = {"ScriptAxisConfig", 3, ScriptMotorCreateAxisArgs}; -static void ScriptMotorCreateAxisCallFunc(const iocshArgBuf *args) -{ - ScriptAxisConfig(args[0].sval, args[1].ival, args[2].sval); -} - - - -static void ScriptMotorRegister(void) -{ - iocshRegister(&ScriptMotorReloadDef, ScriptMotorReloadCallFunc); - iocshRegister(&ScriptMotorCreateControllerDef, ScriptMotorCreateContollerCallFunc); - iocshRegister(&ScriptMotorCreateAxisDef, ScriptMotorCreateAxisCallFunc); -} - - -extern "C" { -epicsExportRegistrar(ScriptMotorRegister); -} diff --git a/motorApp/ScriptMotorSrc/ScriptMotorDriver.dbd b/motorApp/ScriptMotorSrc/ScriptMotorDriver.dbd deleted file mode 100644 index 8f5bbc23..00000000 --- a/motorApp/ScriptMotorSrc/ScriptMotorDriver.dbd +++ /dev/null @@ -1 +0,0 @@ -registrar(ScriptMotorRegister) diff --git a/motorApp/ScriptMotorSrc/ScriptMotorDriver.h b/motorApp/ScriptMotorSrc/ScriptMotorDriver.h deleted file mode 100644 index efa010cd..00000000 --- a/motorApp/ScriptMotorSrc/ScriptMotorDriver.h +++ /dev/null @@ -1,76 +0,0 @@ -#include "asynMotorController.h" -#include "asynMotorAxis.h" - -#include -#include "epicsScript.h" - -class epicsShareClass ScriptMotorAxis : public asynMotorAxis -{ -public: - /* These are the methods we override from the base class */ - ScriptMotorAxis(class ScriptMotorController *pC, int axisNo, const char* script_file, const char* params); - - void reload(const char* script, const char* params); - - void report(FILE *fp, int level); - - asynStatus move(double position, int relative, double min_velocity, double max_velocity, double acceleration); - asynStatus moveVelocity(double min_velocity, double max_velocity, double acceleration); - asynStatus home(double min_velocity, double max_velocity, double acceleration, int forwards); - asynStatus stop(double acceleration); - asynStatus poll(bool *moving); - asynStatus setPosition(double position); - asynStatus setEncoderPosition(double position); - asynStatus setHighLimit(double highLimit); - asynStatus setLowLimit(double lowLimit); - asynStatus setPGain(double pGain); - asynStatus setIGain(double iGain); - asynStatus setDGain(double dGain); - asynStatus setClosedLoop(bool closedLoop); - asynStatus setEncoderRatio(double ratio); - - virtual epicsUInt32 setStatusParam(int index, int value); - virtual void setPositionParam(int index, double value); - -private: - ScriptMotorController *pC_; /**< Pointer to the asynMotorController to which this axis belongs. - * Abbreviated because it is used very frequently */ - int axisIndex_; - - std::string params; - - lua_State* state; - - void initState(const char* script_file); - void config(const char* params); - void logError(); - -friend class ScriptMotorController; -}; - -class epicsShareClass ScriptMotorController : public asynMotorController { -public: - ScriptMotorController(const char *asyn_port, int max_axes, const char* script_file, const char* params); - - virtual asynStatus setIntegerParam(int list, int function, int value); - virtual asynStatus setDoubleParam(int list, int function, double value); - - virtual asynStatus writeInt32(asynUser *pasynUser, epicsInt32 value); - - void report(FILE *fp, int level); - ScriptMotorAxis* getAxis(asynUser *pasynUser); - ScriptMotorAxis* getAxis(int axisNo); - - void configAxis(int axisNo, const char* params); - - void reload(); - -protected: - int ScriptMotorReload; - -private: - std::string script; - std::string init_params; - -friend class ScriptMotorAxis; -}; diff --git a/motorApp/op/adl/ScriptMotorReload.adl b/motorApp/op/adl/ScriptMotorReload.adl deleted file mode 100644 index 6f76c4a8..00000000 --- a/motorApp/op/adl/ScriptMotorReload.adl +++ /dev/null @@ -1,140 +0,0 @@ - -file { - name="/home/oxygen40/KLANG/Documents/Projects/Repository/git/motor/motorApp/op/adl/ScriptMotorReload.adl" - version=030107 -} -display { - object { - x=663 - y=227 - width=220 - height=75 - } - clr=14 - bclr=4 - cmap="" - gridSpacing=5 - gridOn=0 - snapToGrid=0 -} -"color map" { - ncolors=65 - colors { - ffffff, - ececec, - dadada, - c8c8c8, - bbbbbb, - aeaeae, - 9e9e9e, - 919191, - 858585, - 787878, - 696969, - 5a5a5a, - 464646, - 2d2d2d, - 000000, - 00d800, - 1ebb00, - 339900, - 2d7f00, - 216c00, - fd0000, - de1309, - be190b, - a01207, - 820400, - 5893ff, - 597ee1, - 4b6ec7, - 3a5eab, - 27548d, - fbf34a, - f9da3c, - eeb62b, - e19015, - cd6100, - ffb0ff, - d67fe2, - ae4ebc, - 8b1a96, - 610a75, - a4aaff, - 8793e2, - 6a73c1, - 4d52a4, - 343386, - c7bb6d, - b79d5c, - a47e3c, - 7d5627, - 58340f, - 99ffff, - 73dfff, - 4ea5f9, - 2a63e4, - 0a00b8, - ebf1b5, - d4db9d, - bbc187, - a6a462, - 8b8239, - 73ff6b, - 52da3b, - 3cb420, - 289315, - 1a7309, - } -} -rectangle { - object { - x=0 - y=0 - width=250 - height=25 - } - "basic attribute" { - clr=29 - } -} -"message button" { - object { - x=10 - y=35 - width=200 - height=30 - } - control { - chan="$(P)$(PORT):ScriptReload" - clr=14 - bclr=62 - } - label="Reload $(PORT)" - press_msg="1" -} -rectangle { - object { - x=-7 - y=-7 - width=257 - height=32 - } - "basic attribute" { - clr=14 - fill="outline" - width=3 - } -} -text { - object { - x=5 - y=3 - width=200 - height=20 - } - "basic attribute" { - clr=0 - } - textix="Script Motor Reload" -} diff --git a/motorExApp/WithAsyn/Makefile b/motorExApp/WithAsyn/Makefile index f678e039..7be8e650 100644 --- a/motorExApp/WithAsyn/Makefile +++ b/motorExApp/WithAsyn/Makefile @@ -39,9 +39,6 @@ ifdef BUSY endif COMMONDBDS += PI_GCS2Support.dbd COMMONDBDS += phytron.dbd -ifdef SCRIPT -COMMONDBDS += ScriptMotorDriver.dbd -endif DBD += WithAsyn.dbd WithAsyn_DBD += $(COMMONDBDS) @@ -86,10 +83,6 @@ COMMONLIBS += ACRMotor COMMONLIBS += PI_GCS2Support COMMONLIBS += phytronAxisMotor COMMONLIBS += motor -ifdef SCRIPT -COMMONLIBS += ScriptMotor -COMMONLIBS += script -endif # Needed for Newport SNL programs WithAsyn_LIBS += $(COMMONLIBS) From 6ccf596162c473901566e78ea80a52f2ef0c1bd8 Mon Sep 17 00:00:00 2001 From: Pete Jemian Date: Thu, 24 Aug 2017 07:20:21 -0500 Subject: [PATCH 13/15] additional panels used by USAXS --- motorApp/op/ui/motor2xU.ui | 60 ++++++++++++++ motorApp/op/ui/motor3xU.ui | 76 ++++++++++++++++++ motorApp/op/ui/motor4xU.ui | 92 ++++++++++++++++++++++ motorApp/op/ui/motor5xU.ui | 108 +++++++++++++++++++++++++ motorApp/op/ui/motor6xU.ui | 124 +++++++++++++++++++++++++++++ motorApp/op/ui/motor7xU.ui | 140 +++++++++++++++++++++++++++++++++ motorApp/op/ui/motor8xU.ui | 156 +++++++++++++++++++++++++++++++++++++ 7 files changed, 756 insertions(+) create mode 100644 motorApp/op/ui/motor2xU.ui create mode 100644 motorApp/op/ui/motor3xU.ui create mode 100644 motorApp/op/ui/motor4xU.ui create mode 100644 motorApp/op/ui/motor5xU.ui create mode 100644 motorApp/op/ui/motor6xU.ui create mode 100644 motorApp/op/ui/motor7xU.ui create mode 100644 motorApp/op/ui/motor8xU.ui diff --git a/motorApp/op/ui/motor2xU.ui b/motorApp/op/ui/motor2xU.ui new file mode 100644 index 00000000..826a681c --- /dev/null +++ b/motorApp/op/ui/motor2xU.ui @@ -0,0 +1,60 @@ + + + MainWindow + + + + 0 + 0 + 352 + 282 + + + + MainWindow + + + + + + 0 + 0 + 176 + 282 + + + + P=$(P),M=$(M1) + + + motorxU.ui + + + + + + 176 + 0 + 176 + 282 + + + + P=$(P),M=$(M2) + + + motorxU.ui + + + + + + + caInclude + QWidget +
caInclude
+
+
+ + +
diff --git a/motorApp/op/ui/motor3xU.ui b/motorApp/op/ui/motor3xU.ui new file mode 100644 index 00000000..13cee664 --- /dev/null +++ b/motorApp/op/ui/motor3xU.ui @@ -0,0 +1,76 @@ + + + MainWindow + + + + 0 + 0 + 528 + 282 + + + + MainWindow + + + + + + 0 + 0 + 176 + 282 + + + + P=$(P),M=$(M1) + + + motorxU.ui + + + + + + 176 + 0 + 176 + 282 + + + + P=$(P),M=$(M2) + + + motorxU.ui + + + + + + 352 + 0 + 176 + 282 + + + + P=$(P),M=$(M3) + + + motorxU.ui + + + + + + + caInclude + QWidget +
caInclude
+
+
+ + +
diff --git a/motorApp/op/ui/motor4xU.ui b/motorApp/op/ui/motor4xU.ui new file mode 100644 index 00000000..147d9e81 --- /dev/null +++ b/motorApp/op/ui/motor4xU.ui @@ -0,0 +1,92 @@ + + + MainWindow + + + + 0 + 0 + 704 + 282 + + + + MainWindow + + + + + + 0 + 0 + 176 + 282 + + + + P=$(P),M=$(M1) + + + motorxU.ui + + + + + + 176 + 0 + 176 + 282 + + + + P=$(P),M=$(M2) + + + motorxU.ui + + + + + + 352 + 0 + 176 + 282 + + + + P=$(P),M=$(M3) + + + motorxU.ui + + + + + + 528 + 0 + 176 + 282 + + + + P=$(P),M=$(M4) + + + motorxU.ui + + + + + + + caInclude + QWidget +
caInclude
+
+
+ + +
diff --git a/motorApp/op/ui/motor5xU.ui b/motorApp/op/ui/motor5xU.ui new file mode 100644 index 00000000..ca45d7d4 --- /dev/null +++ b/motorApp/op/ui/motor5xU.ui @@ -0,0 +1,108 @@ + + + MainWindow + + + + 0 + 0 + 880 + 282 + + + + MainWindow + + + + + + 0 + 0 + 176 + 282 + + + + P=$(P),M=$(M1) + + + motorxU.ui + + + + + + 176 + 0 + 176 + 282 + + + + P=$(P),M=$(M2) + + + motorxU.ui + + + + + + 352 + 0 + 176 + 282 + + + + P=$(P),M=$(M3) + + + motorxU.ui + + + + + + 528 + 0 + 176 + 282 + + + + P=$(P),M=$(M5) + + + motorxU.ui + + + + + + 704 + 0 + 176 + 282 + + + + P=$(P),M=$(M5) + + + motorxU.ui + + + + + + + caInclude + QWidget +
caInclude
+
+
+ + +
diff --git a/motorApp/op/ui/motor6xU.ui b/motorApp/op/ui/motor6xU.ui new file mode 100644 index 00000000..2de5181c --- /dev/null +++ b/motorApp/op/ui/motor6xU.ui @@ -0,0 +1,124 @@ + + + MainWindow + + + + 0 + 0 + 528 + 564 + + + + MainWindow + + + + + + 0 + 0 + 176 + 282 + + + + P=$(P),M=$(M1) + + + motorxU.ui + + + + + + 176 + 0 + 176 + 282 + + + + P=$(P),M=$(M2) + + + motorxU.ui + + + + + + 352 + 0 + 176 + 282 + + + + P=$(P),M=$(M3) + + + motorxU.ui + + + + + + 0 + 282 + 176 + 282 + + + + P=$(P),M=$(M4) + + + motorxU.ui + + + + + + 176 + 282 + 176 + 282 + + + + P=$(P),M=$(M5) + + + motorxU.ui + + + + + + 352 + 282 + 176 + 282 + + + + P=$(P),M=$(M6) + + + motorxU.ui + + + + + + + caInclude + QWidget +
caInclude
+
+
+ + +
diff --git a/motorApp/op/ui/motor7xU.ui b/motorApp/op/ui/motor7xU.ui new file mode 100644 index 00000000..f29081c9 --- /dev/null +++ b/motorApp/op/ui/motor7xU.ui @@ -0,0 +1,140 @@ + + + MainWindow + + + + 0 + 0 + 704 + 564 + + + + MainWindow + + + + + + 0 + 0 + 176 + 282 + + + + P=$(P),M=$(M1) + + + motorxU.ui + + + + + + 176 + 0 + 176 + 282 + + + + P=$(P),M=$(M2) + + + motorxU.ui + + + + + + 352 + 0 + 176 + 282 + + + + P=$(P),M=$(M3) + + + motorxU.ui + + + + + + 528 + 0 + 176 + 282 + + + + P=$(P),M=$(M4) + + + motorxU.ui + + + + + + 0 + 282 + 176 + 282 + + + + P=$(P),M=$(M5) + + + motorxU.ui + + + + + + 176 + 282 + 176 + 282 + + + + P=$(P),M=$(M6) + + + motorxU.ui + + + + + + 352 + 282 + 176 + 282 + + + + P=$(P),M=$(M7) + + + motorxU.ui + + + + + + + caInclude + QWidget +
caInclude
+
+
+ + +
diff --git a/motorApp/op/ui/motor8xU.ui b/motorApp/op/ui/motor8xU.ui new file mode 100644 index 00000000..8a6d0447 --- /dev/null +++ b/motorApp/op/ui/motor8xU.ui @@ -0,0 +1,156 @@ + + + MainWindow + + + + 0 + 0 + 704 + 564 + + + + MainWindow + + + + + + 0 + 0 + 176 + 282 + + + + P=$(P),M=$(M1) + + + motorxU.ui + + + + + + 176 + 0 + 176 + 282 + + + + P=$(P),M=$(M2) + + + motorxU.ui + + + + + + 352 + 0 + 176 + 282 + + + + P=$(P),M=$(M3) + + + motorxU.ui + + + + + + 528 + 0 + 176 + 282 + + + + P=$(P),M=$(M4) + + + motorxU.ui + + + + + + 0 + 282 + 176 + 282 + + + + P=$(P),M=$(M5) + + + motorxU.ui + + + + + + 176 + 282 + 176 + 282 + + + + P=$(P),M=$(M6) + + + motorxU.ui + + + + + + 352 + 282 + 176 + 282 + + + + P=$(P),M=$(M7) + + + motorxU.ui + + + + + + 528 + 282 + 176 + 282 + + + + P=$(P),M=$(M8) + + + motorxU.ui + + + + + + + caInclude + QWidget +
caInclude
+
+
+ + +
From 468a96c5064d428a30a4215237a6389f21968194 Mon Sep 17 00:00:00 2001 From: Pete Jemian Date: Thu, 24 Aug 2017 10:43:45 -0500 Subject: [PATCH 14/15] fixes #73 --- motorApp/op/ui/{ => autoconvert}/16motor_form.ui | 0 motorApp/op/ui/{ => autoconvert}/4motor_form.ui | 0 motorApp/op/ui/{ => autoconvert}/8motor_form.ui | 0 motorApp/op/ui/{ => autoconvert}/ACRAux.ui | 0 motorApp/op/ui/{ => autoconvert}/ACRTop.ui | 0 motorApp/op/ui/{ => autoconvert}/EnsemblePSOFly.ui | 0 motorApp/op/ui/{ => autoconvert}/EnsemblePSOFly_graphic.ui | 0 motorApp/op/ui/{ => autoconvert}/EnsemblePSOFly_more.ui | 0 motorApp/op/ui/{ => autoconvert}/EnsemblePVErr.ui | 0 motorApp/op/ui/{ => autoconvert}/HXP.ui | 0 motorApp/op/ui/{ => autoconvert}/HXP_coordSys.ui | 0 motorApp/op/ui/{ => autoconvert}/HXP_extra.ui | 0 motorApp/op/ui/{ => autoconvert}/HXP_motors.ui | 0 motorApp/op/ui/{ => autoconvert}/HXP_moveAll.ui | 0 motorApp/op/ui/{ => autoconvert}/MAX_trajectoryPlot.ui | 0 motorApp/op/ui/{ => autoconvert}/MAX_trajectoryPlot2.ui | 0 motorApp/op/ui/{ => autoconvert}/MAX_trajectoryScan.ui | 0 motorApp/op/ui/{ => autoconvert}/MAX_trajectoryScan1.ui | 0 motorApp/op/ui/{ => autoconvert}/MAX_trajectoryScan2.ui | 0 motorApp/op/ui/{ => autoconvert}/MAX_trajectoryScanDebug.ui | 0 motorApp/op/ui/{ => autoconvert}/MAX_trajectoryScanSpeed.ui | 0 motorApp/op/ui/{ => autoconvert}/PSOarrayPlot.ui | 0 motorApp/op/ui/{ => autoconvert}/XPSAux.ui | 0 motorApp/op/ui/{ => autoconvert}/XPSAuxBi_more.ui | 0 motorApp/op/ui/{ => autoconvert}/XPSAuxTest.ui | 0 motorApp/op/ui/{ => autoconvert}/XPSExtra.ui | 0 motorApp/op/ui/{ => autoconvert}/XPSTest.ui | 0 motorApp/op/ui/{ => autoconvert}/XPSTop.ui | 0 motorApp/op/ui/{ => autoconvert}/motor2x.ui | 0 motorApp/op/ui/{ => autoconvert}/motor3x.ui | 0 motorApp/op/ui/{ => autoconvert}/motor4x.ui | 0 motorApp/op/ui/{ => autoconvert}/motor5x.ui | 0 motorApp/op/ui/{ => autoconvert}/motor6x.ui | 0 motorApp/op/ui/{ => autoconvert}/motor8x.ui | 0 motorApp/op/ui/{ => autoconvert}/motorStatus104.ui | 0 motorApp/op/ui/{ => autoconvert}/motorStatus16.ui | 0 motorApp/op/ui/{ => autoconvert}/motorStatus24.ui | 0 motorApp/op/ui/{ => autoconvert}/motorStatus32.ui | 0 motorApp/op/ui/{ => autoconvert}/motorStatus40.ui | 0 motorApp/op/ui/{ => autoconvert}/motorStatus48.ui | 0 motorApp/op/ui/{ => autoconvert}/motorStatus56.ui | 0 motorApp/op/ui/{ => autoconvert}/motorStatus64.ui | 0 motorApp/op/ui/{ => autoconvert}/motorStatus72.ui | 0 motorApp/op/ui/{ => autoconvert}/motorStatus8.ui | 0 motorApp/op/ui/{ => autoconvert}/motorStatus80.ui | 0 motorApp/op/ui/{ => autoconvert}/motorStatus88.ui | 0 motorApp/op/ui/{ => autoconvert}/motors.ui | 0 motorApp/op/ui/{ => autoconvert}/motors_s.ui | 0 motorApp/op/ui/{ => autoconvert}/motorx.ui | 0 motorApp/op/ui/{ => autoconvert}/motorxU.ui | 0 motorApp/op/ui/{ => autoconvert}/motorx_all.ui | 0 motorApp/op/ui/{ => autoconvert}/motorx_bare.ui | 0 motorApp/op/ui/{ => autoconvert}/motorx_help.ui | 0 motorApp/op/ui/{ => autoconvert}/motorx_more.ui | 0 motorApp/op/ui/{ => autoconvert}/motorx_msta_detail.ui | 0 motorApp/op/ui/{ => autoconvert}/motorx_setup.ui | 0 motorApp/op/ui/{ => autoconvert}/motorx_tiny.ui | 0 motorApp/op/ui/{ => autoconvert}/profileMove.ui | 0 motorApp/op/ui/{ => autoconvert}/profileMoveXPS.ui | 0 motorApp/op/ui/{ => autoconvert}/topMotors4.ui | 0 motorApp/op/ui/{ => autoconvert}/topMotors8.ui | 0 motorApp/op/ui/{ => autoconvert}/topMotors8_more.ui | 0 motorApp/op/ui/{ => autoconvert}/trajectoryPlot.ui | 0 motorApp/op/ui/{ => autoconvert}/trajectoryScan.ui | 0 motorApp/op/ui/{ => autoconvert}/trajectoryScanDebug.ui | 0 motorApp/op/ui/{ => autoconvert}/trajectoryScan_Ensemble.ui | 0 motorApp/op/ui/{ => autoconvert}/trajectoryScan_MAXv.ui | 0 67 files changed, 0 insertions(+), 0 deletions(-) rename motorApp/op/ui/{ => autoconvert}/16motor_form.ui (100%) rename motorApp/op/ui/{ => autoconvert}/4motor_form.ui (100%) rename motorApp/op/ui/{ => autoconvert}/8motor_form.ui (100%) rename motorApp/op/ui/{ => autoconvert}/ACRAux.ui (100%) rename motorApp/op/ui/{ => autoconvert}/ACRTop.ui (100%) rename motorApp/op/ui/{ => autoconvert}/EnsemblePSOFly.ui (100%) rename motorApp/op/ui/{ => autoconvert}/EnsemblePSOFly_graphic.ui (100%) rename motorApp/op/ui/{ => autoconvert}/EnsemblePSOFly_more.ui (100%) rename motorApp/op/ui/{ => autoconvert}/EnsemblePVErr.ui (100%) rename motorApp/op/ui/{ => autoconvert}/HXP.ui (100%) rename motorApp/op/ui/{ => autoconvert}/HXP_coordSys.ui (100%) rename motorApp/op/ui/{ => autoconvert}/HXP_extra.ui (100%) rename motorApp/op/ui/{ => autoconvert}/HXP_motors.ui (100%) rename motorApp/op/ui/{ => autoconvert}/HXP_moveAll.ui (100%) rename motorApp/op/ui/{ => autoconvert}/MAX_trajectoryPlot.ui (100%) rename motorApp/op/ui/{ => autoconvert}/MAX_trajectoryPlot2.ui (100%) rename motorApp/op/ui/{ => autoconvert}/MAX_trajectoryScan.ui (100%) rename motorApp/op/ui/{ => autoconvert}/MAX_trajectoryScan1.ui (100%) rename motorApp/op/ui/{ => autoconvert}/MAX_trajectoryScan2.ui (100%) rename motorApp/op/ui/{ => autoconvert}/MAX_trajectoryScanDebug.ui (100%) rename motorApp/op/ui/{ => autoconvert}/MAX_trajectoryScanSpeed.ui (100%) rename motorApp/op/ui/{ => autoconvert}/PSOarrayPlot.ui (100%) rename motorApp/op/ui/{ => autoconvert}/XPSAux.ui (100%) rename motorApp/op/ui/{ => autoconvert}/XPSAuxBi_more.ui (100%) rename motorApp/op/ui/{ => autoconvert}/XPSAuxTest.ui (100%) rename motorApp/op/ui/{ => autoconvert}/XPSExtra.ui (100%) rename motorApp/op/ui/{ => autoconvert}/XPSTest.ui (100%) rename motorApp/op/ui/{ => autoconvert}/XPSTop.ui (100%) rename motorApp/op/ui/{ => autoconvert}/motor2x.ui (100%) rename motorApp/op/ui/{ => autoconvert}/motor3x.ui (100%) rename motorApp/op/ui/{ => autoconvert}/motor4x.ui (100%) rename motorApp/op/ui/{ => autoconvert}/motor5x.ui (100%) rename motorApp/op/ui/{ => autoconvert}/motor6x.ui (100%) rename motorApp/op/ui/{ => autoconvert}/motor8x.ui (100%) rename motorApp/op/ui/{ => autoconvert}/motorStatus104.ui (100%) rename motorApp/op/ui/{ => autoconvert}/motorStatus16.ui (100%) rename motorApp/op/ui/{ => autoconvert}/motorStatus24.ui (100%) rename motorApp/op/ui/{ => autoconvert}/motorStatus32.ui (100%) rename motorApp/op/ui/{ => autoconvert}/motorStatus40.ui (100%) rename motorApp/op/ui/{ => autoconvert}/motorStatus48.ui (100%) rename motorApp/op/ui/{ => autoconvert}/motorStatus56.ui (100%) rename motorApp/op/ui/{ => autoconvert}/motorStatus64.ui (100%) rename motorApp/op/ui/{ => autoconvert}/motorStatus72.ui (100%) rename motorApp/op/ui/{ => autoconvert}/motorStatus8.ui (100%) rename motorApp/op/ui/{ => autoconvert}/motorStatus80.ui (100%) rename motorApp/op/ui/{ => autoconvert}/motorStatus88.ui (100%) rename motorApp/op/ui/{ => autoconvert}/motors.ui (100%) rename motorApp/op/ui/{ => autoconvert}/motors_s.ui (100%) rename motorApp/op/ui/{ => autoconvert}/motorx.ui (100%) rename motorApp/op/ui/{ => autoconvert}/motorxU.ui (100%) rename motorApp/op/ui/{ => autoconvert}/motorx_all.ui (100%) rename motorApp/op/ui/{ => autoconvert}/motorx_bare.ui (100%) rename motorApp/op/ui/{ => autoconvert}/motorx_help.ui (100%) rename motorApp/op/ui/{ => autoconvert}/motorx_more.ui (100%) rename motorApp/op/ui/{ => autoconvert}/motorx_msta_detail.ui (100%) rename motorApp/op/ui/{ => autoconvert}/motorx_setup.ui (100%) rename motorApp/op/ui/{ => autoconvert}/motorx_tiny.ui (100%) rename motorApp/op/ui/{ => autoconvert}/profileMove.ui (100%) rename motorApp/op/ui/{ => autoconvert}/profileMoveXPS.ui (100%) rename motorApp/op/ui/{ => autoconvert}/topMotors4.ui (100%) rename motorApp/op/ui/{ => autoconvert}/topMotors8.ui (100%) rename motorApp/op/ui/{ => autoconvert}/topMotors8_more.ui (100%) rename motorApp/op/ui/{ => autoconvert}/trajectoryPlot.ui (100%) rename motorApp/op/ui/{ => autoconvert}/trajectoryScan.ui (100%) rename motorApp/op/ui/{ => autoconvert}/trajectoryScanDebug.ui (100%) rename motorApp/op/ui/{ => autoconvert}/trajectoryScan_Ensemble.ui (100%) rename motorApp/op/ui/{ => autoconvert}/trajectoryScan_MAXv.ui (100%) diff --git a/motorApp/op/ui/16motor_form.ui b/motorApp/op/ui/autoconvert/16motor_form.ui similarity index 100% rename from motorApp/op/ui/16motor_form.ui rename to motorApp/op/ui/autoconvert/16motor_form.ui diff --git a/motorApp/op/ui/4motor_form.ui b/motorApp/op/ui/autoconvert/4motor_form.ui similarity index 100% rename from motorApp/op/ui/4motor_form.ui rename to motorApp/op/ui/autoconvert/4motor_form.ui diff --git a/motorApp/op/ui/8motor_form.ui b/motorApp/op/ui/autoconvert/8motor_form.ui similarity index 100% rename from motorApp/op/ui/8motor_form.ui rename to motorApp/op/ui/autoconvert/8motor_form.ui diff --git a/motorApp/op/ui/ACRAux.ui b/motorApp/op/ui/autoconvert/ACRAux.ui similarity index 100% rename from motorApp/op/ui/ACRAux.ui rename to motorApp/op/ui/autoconvert/ACRAux.ui diff --git a/motorApp/op/ui/ACRTop.ui b/motorApp/op/ui/autoconvert/ACRTop.ui similarity index 100% rename from motorApp/op/ui/ACRTop.ui rename to motorApp/op/ui/autoconvert/ACRTop.ui diff --git a/motorApp/op/ui/EnsemblePSOFly.ui b/motorApp/op/ui/autoconvert/EnsemblePSOFly.ui similarity index 100% rename from motorApp/op/ui/EnsemblePSOFly.ui rename to motorApp/op/ui/autoconvert/EnsemblePSOFly.ui diff --git a/motorApp/op/ui/EnsemblePSOFly_graphic.ui b/motorApp/op/ui/autoconvert/EnsemblePSOFly_graphic.ui similarity index 100% rename from motorApp/op/ui/EnsemblePSOFly_graphic.ui rename to motorApp/op/ui/autoconvert/EnsemblePSOFly_graphic.ui diff --git a/motorApp/op/ui/EnsemblePSOFly_more.ui b/motorApp/op/ui/autoconvert/EnsemblePSOFly_more.ui similarity index 100% rename from motorApp/op/ui/EnsemblePSOFly_more.ui rename to motorApp/op/ui/autoconvert/EnsemblePSOFly_more.ui diff --git a/motorApp/op/ui/EnsemblePVErr.ui b/motorApp/op/ui/autoconvert/EnsemblePVErr.ui similarity index 100% rename from motorApp/op/ui/EnsemblePVErr.ui rename to motorApp/op/ui/autoconvert/EnsemblePVErr.ui diff --git a/motorApp/op/ui/HXP.ui b/motorApp/op/ui/autoconvert/HXP.ui similarity index 100% rename from motorApp/op/ui/HXP.ui rename to motorApp/op/ui/autoconvert/HXP.ui diff --git a/motorApp/op/ui/HXP_coordSys.ui b/motorApp/op/ui/autoconvert/HXP_coordSys.ui similarity index 100% rename from motorApp/op/ui/HXP_coordSys.ui rename to motorApp/op/ui/autoconvert/HXP_coordSys.ui diff --git a/motorApp/op/ui/HXP_extra.ui b/motorApp/op/ui/autoconvert/HXP_extra.ui similarity index 100% rename from motorApp/op/ui/HXP_extra.ui rename to motorApp/op/ui/autoconvert/HXP_extra.ui diff --git a/motorApp/op/ui/HXP_motors.ui b/motorApp/op/ui/autoconvert/HXP_motors.ui similarity index 100% rename from motorApp/op/ui/HXP_motors.ui rename to motorApp/op/ui/autoconvert/HXP_motors.ui diff --git a/motorApp/op/ui/HXP_moveAll.ui b/motorApp/op/ui/autoconvert/HXP_moveAll.ui similarity index 100% rename from motorApp/op/ui/HXP_moveAll.ui rename to motorApp/op/ui/autoconvert/HXP_moveAll.ui diff --git a/motorApp/op/ui/MAX_trajectoryPlot.ui b/motorApp/op/ui/autoconvert/MAX_trajectoryPlot.ui similarity index 100% rename from motorApp/op/ui/MAX_trajectoryPlot.ui rename to motorApp/op/ui/autoconvert/MAX_trajectoryPlot.ui diff --git a/motorApp/op/ui/MAX_trajectoryPlot2.ui b/motorApp/op/ui/autoconvert/MAX_trajectoryPlot2.ui similarity index 100% rename from motorApp/op/ui/MAX_trajectoryPlot2.ui rename to motorApp/op/ui/autoconvert/MAX_trajectoryPlot2.ui diff --git a/motorApp/op/ui/MAX_trajectoryScan.ui b/motorApp/op/ui/autoconvert/MAX_trajectoryScan.ui similarity index 100% rename from motorApp/op/ui/MAX_trajectoryScan.ui rename to motorApp/op/ui/autoconvert/MAX_trajectoryScan.ui diff --git a/motorApp/op/ui/MAX_trajectoryScan1.ui b/motorApp/op/ui/autoconvert/MAX_trajectoryScan1.ui similarity index 100% rename from motorApp/op/ui/MAX_trajectoryScan1.ui rename to motorApp/op/ui/autoconvert/MAX_trajectoryScan1.ui diff --git a/motorApp/op/ui/MAX_trajectoryScan2.ui b/motorApp/op/ui/autoconvert/MAX_trajectoryScan2.ui similarity index 100% rename from motorApp/op/ui/MAX_trajectoryScan2.ui rename to motorApp/op/ui/autoconvert/MAX_trajectoryScan2.ui diff --git a/motorApp/op/ui/MAX_trajectoryScanDebug.ui b/motorApp/op/ui/autoconvert/MAX_trajectoryScanDebug.ui similarity index 100% rename from motorApp/op/ui/MAX_trajectoryScanDebug.ui rename to motorApp/op/ui/autoconvert/MAX_trajectoryScanDebug.ui diff --git a/motorApp/op/ui/MAX_trajectoryScanSpeed.ui b/motorApp/op/ui/autoconvert/MAX_trajectoryScanSpeed.ui similarity index 100% rename from motorApp/op/ui/MAX_trajectoryScanSpeed.ui rename to motorApp/op/ui/autoconvert/MAX_trajectoryScanSpeed.ui diff --git a/motorApp/op/ui/PSOarrayPlot.ui b/motorApp/op/ui/autoconvert/PSOarrayPlot.ui similarity index 100% rename from motorApp/op/ui/PSOarrayPlot.ui rename to motorApp/op/ui/autoconvert/PSOarrayPlot.ui diff --git a/motorApp/op/ui/XPSAux.ui b/motorApp/op/ui/autoconvert/XPSAux.ui similarity index 100% rename from motorApp/op/ui/XPSAux.ui rename to motorApp/op/ui/autoconvert/XPSAux.ui diff --git a/motorApp/op/ui/XPSAuxBi_more.ui b/motorApp/op/ui/autoconvert/XPSAuxBi_more.ui similarity index 100% rename from motorApp/op/ui/XPSAuxBi_more.ui rename to motorApp/op/ui/autoconvert/XPSAuxBi_more.ui diff --git a/motorApp/op/ui/XPSAuxTest.ui b/motorApp/op/ui/autoconvert/XPSAuxTest.ui similarity index 100% rename from motorApp/op/ui/XPSAuxTest.ui rename to motorApp/op/ui/autoconvert/XPSAuxTest.ui diff --git a/motorApp/op/ui/XPSExtra.ui b/motorApp/op/ui/autoconvert/XPSExtra.ui similarity index 100% rename from motorApp/op/ui/XPSExtra.ui rename to motorApp/op/ui/autoconvert/XPSExtra.ui diff --git a/motorApp/op/ui/XPSTest.ui b/motorApp/op/ui/autoconvert/XPSTest.ui similarity index 100% rename from motorApp/op/ui/XPSTest.ui rename to motorApp/op/ui/autoconvert/XPSTest.ui diff --git a/motorApp/op/ui/XPSTop.ui b/motorApp/op/ui/autoconvert/XPSTop.ui similarity index 100% rename from motorApp/op/ui/XPSTop.ui rename to motorApp/op/ui/autoconvert/XPSTop.ui diff --git a/motorApp/op/ui/motor2x.ui b/motorApp/op/ui/autoconvert/motor2x.ui similarity index 100% rename from motorApp/op/ui/motor2x.ui rename to motorApp/op/ui/autoconvert/motor2x.ui diff --git a/motorApp/op/ui/motor3x.ui b/motorApp/op/ui/autoconvert/motor3x.ui similarity index 100% rename from motorApp/op/ui/motor3x.ui rename to motorApp/op/ui/autoconvert/motor3x.ui diff --git a/motorApp/op/ui/motor4x.ui b/motorApp/op/ui/autoconvert/motor4x.ui similarity index 100% rename from motorApp/op/ui/motor4x.ui rename to motorApp/op/ui/autoconvert/motor4x.ui diff --git a/motorApp/op/ui/motor5x.ui b/motorApp/op/ui/autoconvert/motor5x.ui similarity index 100% rename from motorApp/op/ui/motor5x.ui rename to motorApp/op/ui/autoconvert/motor5x.ui diff --git a/motorApp/op/ui/motor6x.ui b/motorApp/op/ui/autoconvert/motor6x.ui similarity index 100% rename from motorApp/op/ui/motor6x.ui rename to motorApp/op/ui/autoconvert/motor6x.ui diff --git a/motorApp/op/ui/motor8x.ui b/motorApp/op/ui/autoconvert/motor8x.ui similarity index 100% rename from motorApp/op/ui/motor8x.ui rename to motorApp/op/ui/autoconvert/motor8x.ui diff --git a/motorApp/op/ui/motorStatus104.ui b/motorApp/op/ui/autoconvert/motorStatus104.ui similarity index 100% rename from motorApp/op/ui/motorStatus104.ui rename to motorApp/op/ui/autoconvert/motorStatus104.ui diff --git a/motorApp/op/ui/motorStatus16.ui b/motorApp/op/ui/autoconvert/motorStatus16.ui similarity index 100% rename from motorApp/op/ui/motorStatus16.ui rename to motorApp/op/ui/autoconvert/motorStatus16.ui diff --git a/motorApp/op/ui/motorStatus24.ui b/motorApp/op/ui/autoconvert/motorStatus24.ui similarity index 100% rename from motorApp/op/ui/motorStatus24.ui rename to motorApp/op/ui/autoconvert/motorStatus24.ui diff --git a/motorApp/op/ui/motorStatus32.ui b/motorApp/op/ui/autoconvert/motorStatus32.ui similarity index 100% rename from motorApp/op/ui/motorStatus32.ui rename to motorApp/op/ui/autoconvert/motorStatus32.ui diff --git a/motorApp/op/ui/motorStatus40.ui b/motorApp/op/ui/autoconvert/motorStatus40.ui similarity index 100% rename from motorApp/op/ui/motorStatus40.ui rename to motorApp/op/ui/autoconvert/motorStatus40.ui diff --git a/motorApp/op/ui/motorStatus48.ui b/motorApp/op/ui/autoconvert/motorStatus48.ui similarity index 100% rename from motorApp/op/ui/motorStatus48.ui rename to motorApp/op/ui/autoconvert/motorStatus48.ui diff --git a/motorApp/op/ui/motorStatus56.ui b/motorApp/op/ui/autoconvert/motorStatus56.ui similarity index 100% rename from motorApp/op/ui/motorStatus56.ui rename to motorApp/op/ui/autoconvert/motorStatus56.ui diff --git a/motorApp/op/ui/motorStatus64.ui b/motorApp/op/ui/autoconvert/motorStatus64.ui similarity index 100% rename from motorApp/op/ui/motorStatus64.ui rename to motorApp/op/ui/autoconvert/motorStatus64.ui diff --git a/motorApp/op/ui/motorStatus72.ui b/motorApp/op/ui/autoconvert/motorStatus72.ui similarity index 100% rename from motorApp/op/ui/motorStatus72.ui rename to motorApp/op/ui/autoconvert/motorStatus72.ui diff --git a/motorApp/op/ui/motorStatus8.ui b/motorApp/op/ui/autoconvert/motorStatus8.ui similarity index 100% rename from motorApp/op/ui/motorStatus8.ui rename to motorApp/op/ui/autoconvert/motorStatus8.ui diff --git a/motorApp/op/ui/motorStatus80.ui b/motorApp/op/ui/autoconvert/motorStatus80.ui similarity index 100% rename from motorApp/op/ui/motorStatus80.ui rename to motorApp/op/ui/autoconvert/motorStatus80.ui diff --git a/motorApp/op/ui/motorStatus88.ui b/motorApp/op/ui/autoconvert/motorStatus88.ui similarity index 100% rename from motorApp/op/ui/motorStatus88.ui rename to motorApp/op/ui/autoconvert/motorStatus88.ui diff --git a/motorApp/op/ui/motors.ui b/motorApp/op/ui/autoconvert/motors.ui similarity index 100% rename from motorApp/op/ui/motors.ui rename to motorApp/op/ui/autoconvert/motors.ui diff --git a/motorApp/op/ui/motors_s.ui b/motorApp/op/ui/autoconvert/motors_s.ui similarity index 100% rename from motorApp/op/ui/motors_s.ui rename to motorApp/op/ui/autoconvert/motors_s.ui diff --git a/motorApp/op/ui/motorx.ui b/motorApp/op/ui/autoconvert/motorx.ui similarity index 100% rename from motorApp/op/ui/motorx.ui rename to motorApp/op/ui/autoconvert/motorx.ui diff --git a/motorApp/op/ui/motorxU.ui b/motorApp/op/ui/autoconvert/motorxU.ui similarity index 100% rename from motorApp/op/ui/motorxU.ui rename to motorApp/op/ui/autoconvert/motorxU.ui diff --git a/motorApp/op/ui/motorx_all.ui b/motorApp/op/ui/autoconvert/motorx_all.ui similarity index 100% rename from motorApp/op/ui/motorx_all.ui rename to motorApp/op/ui/autoconvert/motorx_all.ui diff --git a/motorApp/op/ui/motorx_bare.ui b/motorApp/op/ui/autoconvert/motorx_bare.ui similarity index 100% rename from motorApp/op/ui/motorx_bare.ui rename to motorApp/op/ui/autoconvert/motorx_bare.ui diff --git a/motorApp/op/ui/motorx_help.ui b/motorApp/op/ui/autoconvert/motorx_help.ui similarity index 100% rename from motorApp/op/ui/motorx_help.ui rename to motorApp/op/ui/autoconvert/motorx_help.ui diff --git a/motorApp/op/ui/motorx_more.ui b/motorApp/op/ui/autoconvert/motorx_more.ui similarity index 100% rename from motorApp/op/ui/motorx_more.ui rename to motorApp/op/ui/autoconvert/motorx_more.ui diff --git a/motorApp/op/ui/motorx_msta_detail.ui b/motorApp/op/ui/autoconvert/motorx_msta_detail.ui similarity index 100% rename from motorApp/op/ui/motorx_msta_detail.ui rename to motorApp/op/ui/autoconvert/motorx_msta_detail.ui diff --git a/motorApp/op/ui/motorx_setup.ui b/motorApp/op/ui/autoconvert/motorx_setup.ui similarity index 100% rename from motorApp/op/ui/motorx_setup.ui rename to motorApp/op/ui/autoconvert/motorx_setup.ui diff --git a/motorApp/op/ui/motorx_tiny.ui b/motorApp/op/ui/autoconvert/motorx_tiny.ui similarity index 100% rename from motorApp/op/ui/motorx_tiny.ui rename to motorApp/op/ui/autoconvert/motorx_tiny.ui diff --git a/motorApp/op/ui/profileMove.ui b/motorApp/op/ui/autoconvert/profileMove.ui similarity index 100% rename from motorApp/op/ui/profileMove.ui rename to motorApp/op/ui/autoconvert/profileMove.ui diff --git a/motorApp/op/ui/profileMoveXPS.ui b/motorApp/op/ui/autoconvert/profileMoveXPS.ui similarity index 100% rename from motorApp/op/ui/profileMoveXPS.ui rename to motorApp/op/ui/autoconvert/profileMoveXPS.ui diff --git a/motorApp/op/ui/topMotors4.ui b/motorApp/op/ui/autoconvert/topMotors4.ui similarity index 100% rename from motorApp/op/ui/topMotors4.ui rename to motorApp/op/ui/autoconvert/topMotors4.ui diff --git a/motorApp/op/ui/topMotors8.ui b/motorApp/op/ui/autoconvert/topMotors8.ui similarity index 100% rename from motorApp/op/ui/topMotors8.ui rename to motorApp/op/ui/autoconvert/topMotors8.ui diff --git a/motorApp/op/ui/topMotors8_more.ui b/motorApp/op/ui/autoconvert/topMotors8_more.ui similarity index 100% rename from motorApp/op/ui/topMotors8_more.ui rename to motorApp/op/ui/autoconvert/topMotors8_more.ui diff --git a/motorApp/op/ui/trajectoryPlot.ui b/motorApp/op/ui/autoconvert/trajectoryPlot.ui similarity index 100% rename from motorApp/op/ui/trajectoryPlot.ui rename to motorApp/op/ui/autoconvert/trajectoryPlot.ui diff --git a/motorApp/op/ui/trajectoryScan.ui b/motorApp/op/ui/autoconvert/trajectoryScan.ui similarity index 100% rename from motorApp/op/ui/trajectoryScan.ui rename to motorApp/op/ui/autoconvert/trajectoryScan.ui diff --git a/motorApp/op/ui/trajectoryScanDebug.ui b/motorApp/op/ui/autoconvert/trajectoryScanDebug.ui similarity index 100% rename from motorApp/op/ui/trajectoryScanDebug.ui rename to motorApp/op/ui/autoconvert/trajectoryScanDebug.ui diff --git a/motorApp/op/ui/trajectoryScan_Ensemble.ui b/motorApp/op/ui/autoconvert/trajectoryScan_Ensemble.ui similarity index 100% rename from motorApp/op/ui/trajectoryScan_Ensemble.ui rename to motorApp/op/ui/autoconvert/trajectoryScan_Ensemble.ui diff --git a/motorApp/op/ui/trajectoryScan_MAXv.ui b/motorApp/op/ui/autoconvert/trajectoryScan_MAXv.ui similarity index 100% rename from motorApp/op/ui/trajectoryScan_MAXv.ui rename to motorApp/op/ui/autoconvert/trajectoryScan_MAXv.ui From 8a16af5067802c3a5bf353c07837de1845d5aa10 Mon Sep 17 00:00:00 2001 From: K Lauer Date: Wed, 23 Aug 2017 15:02:04 -0700 Subject: [PATCH 15/15] Add TravisCI configuration --- .ci/travis-prepare.sh | 164 ++++++++++++++++++++++++++++++++++++++++++ .travis.yml | 27 +++++++ 2 files changed, 191 insertions(+) create mode 100755 .ci/travis-prepare.sh create mode 100644 .travis.yml diff --git a/.ci/travis-prepare.sh b/.ci/travis-prepare.sh new file mode 100755 index 00000000..7f2a6ceb --- /dev/null +++ b/.ci/travis-prepare.sh @@ -0,0 +1,164 @@ +#!/bin/sh +set -e -x + +SUPPORT=$HOME/.cache/support + +install -d $SUPPORT + +# Conditionally build IPAC +if [ -n "$IPAC" ]; then + IPAC_PATH=$SUPPORT/ipac +else + IPAC_PATH= +fi + +RELEASE_PATH=$TRAVIS_BUILD_DIR/configure/RELEASE +EPICS_BASE=$SUPPORT/epics-base + +cat << EOF > $RELEASE_PATH +IPAC=$IPAC_PATH +SNCSEQ=$SUPPORT/seq +ASYN=$SUPPORT/asyn +EPICS_BASE=$SUPPORT/epics-base +EOF + +# use default selection for MSI +sed -i -e '/MSI/d' configure/CONFIG_SITE + +if [ ! -e "$EPICS_BASE/built" ] +then + + git clone --depth 10 --branch $BASE https://github.com/epics-base/epics-base.git $EPICS_BASE + + EPICS_HOST_ARCH=`sh $EPICS_BASE/startup/EpicsHostArch` + + case "$STATIC" in + static) + cat << EOF >> "$EPICS_BASE/configure/CONFIG_SITE" +SHARED_LIBRARIES=NO +STATIC_BUILD=YES +EOF + ;; + *) ;; + esac + + case "$CMPLR" in + clang) + echo "Host compiler is clang" + cat << EOF >> $EPICS_BASE/configure/os/CONFIG_SITE.Common.$EPICS_HOST_ARCH +GNU = NO +CMPLR_CLASS = clang +CC = clang +CCC = clang++ +EOF + ;; + *) echo "Host compiler is default";; + esac + + # requires wine and g++-mingw-w64-i686 + if [ "$WINE" = "32" ] + then + echo "Cross mingw32" + sed -i -e '/CMPLR_PREFIX/d' $EPICS_BASE/configure/os/CONFIG_SITE.linux-x86.win32-x86-mingw + cat << EOF >> $EPICS_BASE/configure/os/CONFIG_SITE.linux-x86.win32-x86-mingw +CMPLR_PREFIX=i686-w64-mingw32- +EOF + cat << EOF >> $EPICS_BASE/configure/CONFIG_SITE +CROSS_COMPILER_TARGET_ARCHS+=win32-x86-mingw +EOF + fi + + # set RTEMS to eg. "4.9" or "4.10" + if [ -n "$RTEMS" ] + then + echo "Cross RTEMS${RTEMS} for pc386" + install -d /home/travis/.cache + curl -L "https://github.com/mdavidsaver/rsb/releases/download/travis-20160306-2/rtems${RTEMS}-i386-trusty-20190306-2.tar.gz" \ + | tar -C /home/travis/.cache -xj + + sed -i -e '/^RTEMS_VERSION/d' -e '/^RTEMS_BASE/d' $EPICS_BASE/configure/os/CONFIG_SITE.Common.RTEMS + cat << EOF >> $EPICS_BASE/configure/os/CONFIG_SITE.Common.RTEMS +RTEMS_VERSION=$RTEMS +RTEMS_BASE=/home/travis/.cache/rtems${RTEMS}-i386 +EOF + cat << EOF >> $EPICS_BASE/configure/CONFIG_SITE +CROSS_COMPILER_TARGET_ARCHS+=RTEMS-pc386 +EOF + + fi + + make -C "$EPICS_BASE" -j2 + # get MSI for 3.14 + case "$BASE" in + 3.14*) + echo "Build MSI" + install -d "$HOME/msi/extensions/src" + curl https://www.aps.anl.gov/epics/download/extensions/extensionsTop_20120904.tar.gz | tar -C "$HOME/msi" -xvz + curl https://www.aps.anl.gov/epics/download/extensions/msi1-7.tar.gz | tar -C "$HOME/msi/extensions/src" -xvz + mv "$HOME/msi/extensions/src/msi1-7" "$HOME/msi/extensions/src/msi" + + cat << EOF > "$HOME/msi/extensions/configure/RELEASE" +EPICS_BASE=$EPICS_BASE +EPICS_EXTENSIONS=\$(TOP) +EOF + make -C "$HOME/msi/extensions" + cp "$HOME/msi/extensions/bin/$EPICS_HOST_ARCH/msi" "$EPICS_BASE/bin/$EPICS_HOST_ARCH/" + echo 'MSI:=$(EPICS_BASE)/bin/$(EPICS_HOST_ARCH)/msi' >> "$EPICS_BASE/configure/CONFIG_SITE" + + cat <> configure/CONFIG_SITE +MSI = \$(EPICS_BASE)/bin/\$(EPICS_HOST_ARCH)/msi +EOF + + ;; + *) echo "Use MSI from Base" + ;; + esac + + touch $EPICS_BASE/built +else + echo "Using cached epics-base!" +fi + +# IPAC +if [ -n "$IPAC" ]; then + if [ ! -e "$SUPPORT/ipac/built" ]; then + echo "Build ipac" + install -d $SUPPORT/ipac + git clone --depth 10 --branch $IPAC https://github.com/epics-modules/ipac.git $SUPPORT/ipac + cat << EOF > $SUPPORT/ipac/configure/RELEASE +EPICS_BASE=$SUPPORT/epics-base +EOF + make -C $SUPPORT/ipac + touch $SUPPORT/ipac/built + else + echo "Using cached ipac" + fi +else + echo "Skipping ipac" +fi + + +# sequencer +if [ ! -e "$SUPPORT/seq/built" ]; then + echo "Build sequencer" + install -d $SUPPORT/seq + curl -L "http://www-csr.bessy.de/control/SoftDist/sequencer/releases/seq-${SEQ}.tar.gz" | tar -C $SUPPORT/seq -xvz --strip-components=1 + cp $RELEASE_PATH $SUPPORT/seq/configure/RELEASE + make -C $SUPPORT/seq + touch $SUPPORT/seq/built +else + echo "Using cached seq" +fi + + +# asyn +if [ ! -e "$SUPPORT/asyn/built" ]; then + echo "Build asyn" + install -d $SUPPORT/asyn + curl -L "https://www.aps.anl.gov/epics/download/modules/asyn${ASYN}.tar.gz" | tar -C $SUPPORT/asyn -xvz --strip-components=1 + cp $RELEASE_PATH $SUPPORT/asyn/configure/RELEASE + make -C "$SUPPORT/asyn" -j2 + touch $SUPPORT/asyn/built +else + echo "Using cached asyn" +fi diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..a0973db0 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,27 @@ +sudo: false +dist: trusty +language: c +compiler: + - gcc +cache: + directories: + - $HOME/.cache +addons: + apt: + packages: + - libreadline6-dev + - libncurses5-dev + - perl + - clang + - g++-mingw-w64-i686 + - re2c +env: + - BASE=3.14 STATIC=shared SEQ=2.2.4 ASYN=4-31 IPAC=2.14 + - BASE=3.14 STATIC=static SEQ=2.2.4 ASYN=4-31 IPAC=2.14 + - BASE=3.15 STATIC=shared SEQ=2.2.4 ASYN=4-31 IPAC=2.14 + - BASE=3.15 STATIC=static SEQ=2.2.4 ASYN=4-31 IPAC=2.14 + - BASE=3.16 STATIC=shared RTEMS=4.10 SEQ=2.2.4 ASYN=4-31 IPAC=2.14 + - BASE=3.16 STATIC=shared CMPLR=clang WINE=32 SEQ=2.2.4 ASYN=4-31 IPAC= + - BASE=3.16 STATIC=static WINE=32 SEQ=2.2.4 ASYN=4-31 IPAC= +install: ./.ci/travis-prepare.sh +script: make