Esempio n. 1
0
void __fastcall TAddMachine::SaveClick(TObject *Sender)
{
	std::pair< TDate, TDate > dates( dtpValidFrom -> Date, dtpValidTo -> Date );
	bool validDate = (dates.second > dates.first
				 && dates.second > Now() && dates.first < Now());

	if( rgStatus -> ItemIndex == RGS_ACTIVE && !validDate )
		Application->MessageBox( "Invalid from/to dates", NULL, MB_OK);

	else if( MachineName->Text.IsEmpty() )
		Application->MessageBox( "Invalid machine name", NULL, MB_OK );

	else if( Location->Text.IsEmpty() )
		Application->MessageBox( "Location must have a value", NULL, MB_OK );
	else
	{	LCDbAnalyser theMachine( analyserID );
		theMachine.setName( MachineName->Text );
		theMachine.setDescription( Description->Text.SubString( 1, 64 ) );
		theMachine.setValidDates( dates );
		theMachine.setLocation( Location->Text );
		theMachine.setActive( rgStatus -> ItemIndex == RGS_ACTIVE );

		const LCDbObject * cluster = LCDbObjects::records().find( cbxCluster -> Text, LCDbObject::CLUSTER );
		theMachine.setClusterID( cluster == NULL ? 0 : cluster -> getID() );
		theMachine.saveRecord( QueryCentral );
		Close();
	}
}
Esempio n. 2
0
int
main(int argc, char **argv)
{
  FEM_ObjectBrokerAllClasses theBroker;
  MPI_MachineBroker theMachine(&theBroker, argc, argv);
  theMachineBroker = &theMachine;
  OPS_MACHINE = &theMachine;

  rank = theMachine.getPID();
  np = theMachine.getNP();

  if (rank == 0) {
    OPS_theChannels = new Channel *[np-1];
    theChannels = OPS_theChannels;
    numChannels = np-1;
  } else {
    OPS_theChannels = new Channel *[1];
    theChannels = OPS_theChannels;
    numChannels = 1;
  }

  //
  // if rank 0 we send all args
  //

  int numArg = 0;
  int sizeArg = 0;
  char **args = 0;
  char *dataArgs = 0;

  if (rank == 0) {

    for (int i=0; i<argc; i++)
      if (argv[i] == NULL) {
	i = argc+1;
      } else {
	numArg ++;
	sizeArg += strlen(argv[i])+1;
      }

    static ID data(2);
    data(0) = numArg;
    data(1) = sizeArg;

    dataArgs = new char[sizeArg];
    int loc = 0;
    for (int i=0; i<numArg; i++) {
      int lengthArg = strlen(argv[i]);
      strncpy(&dataArgs[loc], argv[i],lengthArg+1);
      loc+=lengthArg+1;
    }

    Message msgChar(dataArgs, sizeArg);

    for (int j=0; j<np-1; j++) {
      Channel *otherChannel = theMachine.getRemoteProcess();
      OPS_theChannels[j] = otherChannel;
      otherChannel->sendID(0,0,data);
      otherChannel->sendMsg(0,0,msgChar);
    }
      
  } else {

    static ID data(2);    

    Channel *myChannel = theMachine.getMyChannel();
    OPS_theChannels[0] = myChannel;
    myChannel->recvID(0,0,data);
    numArg = data(0);
    sizeArg = data(1);
    dataArgs = new char[sizeArg];
    Message msgChar(dataArgs, sizeArg);
    
    myChannel->recvMsg(0,0,msgChar);
  }

  args = new char *[numArg];
  args[0] = dataArgs;
  int argCount = 1;
  for (int j=1; j<sizeArg-1; j++)
    if (dataArgs[j] == '\0') {
      args[argCount] = &dataArgs[j+1];
      argCount++;
    }

  OpenSeesParseArgv(argc, argv);  

#ifndef TCL_LOCAL_APPINIT
#define TCL_LOCAL_APPINIT Tcl_AppInit    
#endif

#ifdef TCL_LOCAL_MAIN_HOOK
  extern int TCL_LOCAL_MAIN_HOOK _ANSI_ARGS_((int *argc, char ***argv));
#endif
    
#ifdef TCL_XT_TEST
  XtToolkitInitialize();
#endif
    
#ifdef TCL_LOCAL_MAIN_HOOK
  TCL_LOCAL_MAIN_HOOK(&argc, &argv);
#endif

  g3TclMain(numArg, args, TCL_LOCAL_APPINIT, rank, np);

  // some clean up to shut the remotes down if still running
  //  theDomain.clearAll();
  
  // shutdown the remote machines
  //  theMachine.shutdown();

  //
  // mpi clean up
  //

  fprintf(stderr, "Process Terminating %d\n", rank);
  
  return 0;
}
Esempio n. 3
0
int
main(int argc, char **argv)
{
  FEM_ObjectBroker theBroker;
  MPI_MachineBroker theMachine(&theBroker, argc, argv);
  theMachineBroker = &theMachine;

  int rank = theMachine.getPID();
  int np = theMachine.getNP();

  //
  // depending on rank we do something
  //
  if (rank != 0) {

    //
    // on slave processes we spin waiting to create & run actors
    //
    fprintf(stderr, "Slave Process Running\n");
    theMachine.runActors();

  } else {

    //
    // on process 0 we create some ShadowSubdomains & then start the OpenSees interpreter
    //
    fprintf(stderr, "Master Process Running OpenSees Interpreter\n");   

    //
    // set some global parameters
    //
    OPS_OBJECT_BROKER = &theBroker;
    OPS_MACHINE = &theMachine;
    OPS_PARALLEL_PROCESSING = np;
    OPS_NUM_SUBDOMAINS = np - 1;
    OPS_PARTITIONED    = false;
    Channel  **OPS_theChannels = 0;
    OPS_theChannels = new Channel *[OPS_NUM_SUBDOMAINS];
    Subdomain **OPS_theSubdomains = 0;
    OPS_theSubdomains = new Subdomain *[OPS_NUM_SUBDOMAINS];

    // start the remote actors
    for (int i=1; i<=OPS_NUM_SUBDOMAINS; i++) {
      ShadowSubdomain *theSubdomain = new ShadowSubdomain(i, 
							  *OPS_MACHINE, 
							  *OPS_OBJECT_BROKER);
      theDomain.addSubdomain(theSubdomain);
      OPS_theChannels[i-1] = theSubdomain->getChannelPtr();
      OPS_theSubdomains[i-1] = theSubdomain;
    }

    Subdomain *theSubdomain = OPS_theSubdomains[0];
    Node *node1 = new Node(1, 2,   0.0,  0.0);
    Node *node2 = new Node(2, 2, 144.0,  0.0);
    Node *node3 = new Node(3, 2, 168.0,  0.0);    
    Node *node4 = new Node(4, 2,  72.0, 96.0);        
    Matrix mass(2,2); mass(0,0)=1.0; mass(1,1)=2.0;
    node1->setMass(mass);
    node2->setMass(mass);

    theSubdomain->addNode(node1);
    theSubdomain->addExternalNode(node2);
    //    theDomain.addNode(node2);
    theDomain.addNode(node3);
    theDomain.addNode(node4);
    theDomain.Print(opserr);

    // some clean up to shut the remotes down if still running
    theDomain.clearAll();

    // test that everything is shutting down correctly
  }

  //
  // mpi clean up
  //

  theMachine.shutdown();

  fprintf(stderr, "Process Terminating %d\n", rank);

  return 0;
}