Main Page Namespace List Class Hierarchy Alphabetical List Compound List File List Namespace Members Compound Members File Members Related Pages

cmd_imd.C

Go to the documentation of this file.
00001 /***************************************************************************
00002 *cr
00003 *cr (C) Copyright 1995-2019 The Board of Trustees of the
00004 *cr University of Illinois
00005 *cr All Rights Reserved
00006 *cr
00007 ***************************************************************************/
00008 
00009 /***************************************************************************
00010 * RCS INFORMATION:
00011 *
00012 * $RCSfile: cmd_imd.C,v $
00013 * $Author: johns $ $Locker: $ $State: Exp $
00014 * $Revision: 1.27 $ $Date: 2019年01月17日 21:21:03 $
00015 *
00016 ***************************************************************************
00017 * DESCRIPTION:
00018 * text commands for interactive MD simulation connection control
00019 ***************************************************************************/
00020 
00021 #ifdef VMDIMD
00022 #include "CmdIMD.h"
00023 #endif
00024 
00025 #include "IMDMgr.h"
00026 #include "CommandQueue.h"
00027 #include "VMDApp.h"
00028 #include "MoleculeList.h"
00029 #include "utilities.h"
00030 #include "config.h" // for CMDLEN
00031 #include <stdlib.h>
00032 #include <tcl.h>
00033 
00034 int text_cmd_imd(ClientData cd, Tcl_Interp *interp, int argc,
00035 const char *argv[]) {
00036 
00037 #ifdef VMDIMD
00038 VMDApp *app = (VMDApp *)cd;
00039 CommandQueue *cmdQueue = app->commandQueue; 
00040 
00041 if (argc == 1) {
00042 Tcl_AppendResult(interp, 
00043 "Need parameters for 'imd' command. Possibilities include: \n",
00044 "pause [on|off|toggle]\n", 
00045 "detach\n",
00046 "kill\n",
00047 "connect <hostname> <port>\n",
00048 "transfer <rate>\n",
00049 "keep <rate>\n",
00050 "copyunitcell <on|off>\n",
00051 NULL);
00052 return TCL_ERROR;
00053 
00054 } else if (!strupncmp(argv[1], "pause", CMDLEN)) { 
00055 if ((argc == 3) && (!strupncmp(argv[2], "toggle", CMDLEN))) { //"imd pause"
00056 app->imdMgr->togglepause();
00057 cmdQueue->runcommand(new CmdIMDSim(CmdIMDSim::PAUSE_TOGGLE));
00058 }
00059 else if ((argc == 3) && (!strupncmp(argv[2], "on", CMDLEN))) { //"imd pause on"
00060 app->imdMgr->pause();
00061 cmdQueue->runcommand(new CmdIMDSim(CmdIMDSim::PAUSE_ON)); 
00062 } 
00063 else if ((argc == 3) && (!strupncmp(argv[2], "off", CMDLEN))) { //"imd pause off"
00064 app->imdMgr->unpause();
00065 cmdQueue->runcommand(new CmdIMDSim(CmdIMDSim::PAUSE_OFF)); 
00066 } 
00067 else {
00068 Tcl_AppendResult(interp, "Wrong arguments: imd pause <on|off|toggle>", NULL); 
00069 return TCL_ERROR;
00070 }
00071 
00072 if (!app->imdMgr->connected()) { 
00073 Tcl_AppendResult(interp, "No IMD connection available.", NULL);
00074 return TCL_ERROR;
00075 }
00076 
00077 } else if ((argc == 4) && (!strupncmp(argv[1], "connect", CMDLEN)) ) {
00078 int port = atoi(argv[3]);
00079 Molecule *mol = app->moleculeList->top();
00080 if (!mol) {
00081 Tcl_AppendResult(interp, 
00082 "Can't connect, no molecule loaded", NULL); 
00083 return TCL_ERROR;
00084 }
00085 if (app->imdMgr->connected()) {
00086 char buf[500];
00087 sprintf(buf, "Can't connect; already connected to simulation running on"
00088 "host %s over port %d", app->imdMgr->gethost(), 
00089 app->imdMgr->getport());
00090 Tcl_SetResult(interp, buf, TCL_VOLATILE);
00091 return TCL_ERROR;
00092 }
00093 if (!app->imd_connect(mol->id(), argv[2], port)) {
00094 Tcl_AppendResult(interp, "Unable to connect to host ", argv[2], 
00095 " on port ", argv[3], NULL);
00096 return TCL_ERROR;
00097 }
00098 
00099 } else if (argc == 2) {
00100 if (!app->imdMgr->connected()) {
00101 Tcl_AppendResult(interp, "No IMD connection available.", NULL);
00102 return TCL_ERROR;
00103 }
00104 else if (!strupncmp(argv[1], "detach", CMDLEN)) {
00105 app->imdMgr->detach();
00106 cmdQueue->runcommand(new CmdIMDSim(CmdIMDSim::DETACH));
00107 } else if (!strupncmp(argv[1], "kill", CMDLEN)) {
00108 app->imdMgr->kill();
00109 cmdQueue->runcommand(new CmdIMDSim(CmdIMDSim::KILL));
00110 } else {
00111 Tcl_AppendResult(interp, 
00112 "Usage: imd [pause | detach | kill]", NULL); 
00113 return TCL_ERROR; 
00114 }
00115 
00116 } else if ((argc == 3) && (!strupncmp(argv[1], "transfer", CMDLEN)) ) {
00117 int rate = atoi(argv[2]);
00118 app->imdMgr->set_trans_rate(rate);
00119 cmdQueue->runcommand(new CmdIMDRate(CmdIMDRate::TRANSFER, rate));
00120 
00121 } else if ((argc == 3) && (!strupncmp(argv[1], "keep", CMDLEN)) ) {
00122 int rate = atoi(argv[2]);
00123 app->imdMgr->set_keep_rate(rate);
00124 cmdQueue->runcommand(new CmdIMDRate(CmdIMDRate::KEEP, rate));
00125 
00126 } else if ((argc == 3) && (!strupncmp(argv[1], "copyunitcell", CMDLEN)) ) {
00127 if (!strupncmp(argv[2], "on", CMDLEN)) {
00128 app->imdMgr->set_copyunitcell(1);
00129 cmdQueue->runcommand(new CmdIMDCopyUnitCell(CmdIMDCopyUnitCell::COPYCELL_ON));
00130 } else {
00131 app->imdMgr->set_copyunitcell(0);
00132 cmdQueue->runcommand(new CmdIMDCopyUnitCell(CmdIMDCopyUnitCell::COPYCELL_OFF));
00133 }
00134 } else {
00135 return TCL_ERROR;
00136 }
00137 
00138 return TCL_OK; // No error
00139 #else
00140 Tcl_AppendResult(interp,
00141 "IMD functionality not present. Recompile with IMD enabled.", NULL);
00142 return TCL_ERROR;
00143 #endif
00144 }
00145 
00146 

Generated on Mon Nov 17 02:45:35 2025 for VMD (current) by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002

AltStyle によって変換されたページ (->オリジナル) /