示例#1
0
 /**Retrieves a given resource based on the index supplied.
  * The resource maybe removed from the list if so desired;
  * */
 public static Resource GetResource(int index, bool isRemove)
 {
     Resource[] rsc = new Resource[resources.Count];
     resources.CopyTo(rsc, 0);
     Resource temp = rsc[index];
     if (isRemove)
     {
         resources.Remove(temp);
     }
     return temp;
 }
示例#2
0
 /** Enlists all the resources available for the PCB's to use
  * */
 public static void Initialize()
 {
     Resource rsc = null;
     rsc = new Resource(resources.Count, "Lights");
     resources.AddLast(rsc);
     rsc = new Resource(resources.Count, "Sounds");
     resources.AddLast(rsc);
     rsc = new Resource(resources.Count, "Aircon");
     resources.AddLast(rsc);
     rsc = new Resource(resources.Count, "Oven");
     resources.AddLast(rsc);
     rsc = new Resource(resources.Count, "Blender");
     resources.AddLast(rsc);
     rsc = new Resource(resources.Count, "Television");
     resources.AddLast(rsc);
     rsc = new Resource(resources.Count, "Stereo");
     resources.AddLast(rsc);
     rsc = new Resource(resources.Count, "Fan");
     resources.AddLast(rsc);
     rsc = new Resource(resources.Count, "Refrigerator");
     resources.AddLast(rsc);
     rsc = new Resource(resources.Count, "Rice Cooker");
     resources.AddLast(rsc);
 }
示例#3
0
 private Resource UseResource()
 {
     int luck = (int)(new Random().NextDouble() * 100);
     Resource rsc = null;
     switch (luck)
     {
         case 0:
             rsc = new Resource(0, "Lights Controller");
             break;
         case 1:
             rsc = new Resource(1, "Doors Controller");
             break;
         case 2:
             rsc = new Resource(2, "Sounds Controller");
             break;
         default:
             rsc = null;
             break;
     }
     return rsc;
 }
 /**Starts the timer controlling this PCB's waiting time.
  * */
 public void TimeResource(Resource rsc, int deviceTime)
 {
     this.deviceTime = deviceTime;
     TimerCallback tc = new TimerCallback(this.CheckStatus);
     timer = new System.Threading.Timer(tc, null, 1000, 1000);
 }