Exemplo n.º 1
0
 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);
 }
Exemplo n.º 2
0
 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);
   }
 }
Exemplo n.º 3
0
 public IRecord getRunningRecord(int i) {
   return dbManager.getRecord(i);
 }
Exemplo n.º 4
0
 public IStatus getStartupStatus(int i) {
   IStatus status = new Status();
   status = dbManager.getStatus(i);
   System.out.println("appServer getStartupStatus: " + status.getId());
   return status;
 }