private void update(int i, int sleepTime) {
   // Now we do the job requested by the app client.
   //  called with: record.getPosIndex() == endOfCycle
   //  where endOfCycle = maxPosIndex for forward and 0 for reverse
   aRecord = dbManager.getRecord(i);
   //  Reset the posIndex
   aRecord.setPosIndex(0); // depending on direction
   // increment the colour index
   aRecord.incColorIndex();
   if (aRecord.getColorIndex() == aStatus.getMaxColorIndex()) {
     // also may depend on app
     // if all colours done, start again
     aRecord.setColorIndex(0);
     // if ((record).incCount|2 == 0){
     // (record).setDirection(true)}
     // else (record).setDirection(false);
   }
   try {
     Thread.sleep(sleepTime);
   } catch (InterruptedException e) {
     System.out.println("Interrupted sleep");
   }
   dbManager.setRecord(i, aRecord);
   System.out.println("appServer cycleEnded: " + i);
 }
 public AppServer(String[] args) {
   dbManager = new DBManager(clientCount);
   aStatus = new Status();
   aRecord = new Record();
   // Now interpret the required mode
   try {
     sysMode = Integer.parseInt(args[0]);
     if (sysMode > 3) {
       sysMode = 0;
     }
   } catch (NumberFormatException e) {
     System.out.println("Invalid format -- select 0");
     sysMode = 0;
   }
   for (int i = 0; i < clientCount; i++) {
     makeSetup(i);
     dbManager.saveSetup(i, aStatus, aRecord);
   }
 }
 public IRecord getRunningRecord(int i) {
   return dbManager.getRecord(i);
 }
 public IStatus getStartupStatus(int i) {
   IStatus status = new Status();
   status = dbManager.getStatus(i);
   System.out.println("appServer getStartupStatus: " + status.getId());
   return status;
 }