Beispiel #1
0
        public void run(int count)
        {
            //for (int count=0; count < maxReq & blocks.Count>0; count++) {
            if (queue.Count > 0)
            {
                //Take out and remove first logic block
                LogicProcess currentLogic = queue[0];
                queue.RemoveAt(0);

                //run the logic block
                object output = currentLogic.run();
                myLogger.Info("AMA logic " + (count + 1) + "/" + maxReq + ": Activated - Logic info: " + currentLogic.ToString());
                //blocks.Add(currentLogic);


                //decide where to put the logicProcess in the list
                if (currentLogic.queue == LogicQueue.last)
                {
                    queue.Add(currentLogic);
                    myLogger.Info("AMA logic " + (count + 1) + "/" + maxReq + ": Moved to end of queue");
                }
                else if (currentLogic.queue == LogicQueue.first)
                {
                    queue.Insert(0, currentLogic);
                    myLogger.Info("AMA logic " + (count + 1) + "/" + maxReq + ": Moved to start of queue");
                }
                else
                {
                    myLogger.Info("AMA logic " + (count + 1) + "/" + maxReq + ": Discarded");
                }
            }
        }
Beispiel #2
0
 public override void add(LogicProcess block)
 {
     if (this.queue.Count >= maxLogics)
     {
         throw new Exception("Reached maximum logic capacity for User AMA");
     }
     else
     {
         queue.Add(block);
     }
 }
Beispiel #3
0
 private void next(LogicProcess process, bool success)
 {
     if (success)
     {
         process.queue = LogicQueue.first;
         process.step(0);
     }
     else
     {
         process.queue = LogicQueue.last;
         process.step(1);
     }
 }
Beispiel #4
0
        public object run(LogicProcess process)
        {
            IMarketResponse response = process.comm.SendQueryBuySellRequest(process.id);
            bool            success  = (response.getType() != ResponseType.qReq);

            if (!success)
            {
                process.id = -1;
            }

            next(process, success);
            return(response);
        }
Beispiel #5
0
 public virtual void next(LogicProcess process, bool success)
 {
     if (success)
     {
         process.queue = LogicQueue.last;
         process.step(1);
     }
     else
     {
         process.queue = LogicQueue.last;
         process.step(1);
     }
 }
Beispiel #6
0
        public object run(LogicProcess process)
        {
            bool success = false;

            IMarketResponse response = process.comm.SendQueryMarketRequest(process.commodity);

            if (response.getType() == ResponseType.qCommodity)
            {
                MQCommodity resp = (MQCommodity)response;
                success = resp.getAsk() <= resp.getBid();
                next(process, success);
            }
            return(response);
        }
Beispiel #7
0
        public object run(LogicProcess process)
        {
            bool            success  = false;
            IMarketResponse response = process.comm.SendSellRequest(process.price, process.commodity, process.amount);

            if (response.getType() == ResponseType.buySell)
            {
                success = true;
                MBuySell resp = (MBuySell)response;
                process.id = resp.getID();
            }
            next(process, success);
            return(response);
        }
Beispiel #8
0
        public object run(LogicProcess process)
        {
            bool            success  = false;
            IMarketResponse response = process.comm.SendQueryUserRequest();

            if (response.getType() == ResponseType.qUser)
            {
                MQUser resp = (MQUser)response;
                Dictionary <string, int> commodityList = resp.getCommodities();
                int currAmount = commodityList[process.commodity.ToString()];
                success = (currAmount > 0);
            }
            next(process, success);
            return(response);
        }
Beispiel #9
0
        public object run(LogicProcess process)
        {
            bool success = false;

            IMarketResponse response = process.comm.SendQueryMarketRequest(process.commodity);

            //myLogger.Info("BidCompare: Sent query");

            if (response.getType() == ResponseType.qCommodity)
            {
                MQCommodity resp = (MQCommodity)response;
                success = resp.getBid() >= process.price;
                next(process, success);
            }
            return(response);
        }
Beispiel #10
0
 public virtual void add(LogicProcess block)
 {
     queue.Add(block);
 }