示例#1
0
 private void SetNextEnum(SequenceCollections coll, int iterator)
 {
     lock (this)
     {
         int nextIterator = iterator + 1;
         if (nextIterator == coll.NodeList.Count)
         {
             carrieroperation = CarrierOperations.Load;
         }
         else
         {
             Node n = coll.NodeList[nextIterator];
             carrieroperation = n.OperationName;
         }
     }
 }
示例#2
0
    public void Exceute(Parameters p)
    {
        Form1 f = new Form1();

        testParams = p;
        SequenceCollections coll = p.NodeValues;
        int iterator             = 0;
        int PortID = 1;

        carrieroperation = CarrierOperations.Load;
        try
        {
            int threadid = Thread.CurrentThread.ManagedThreadId;
            for (iterator = 0; iterator < coll.NodeList.Count; iterator++)
            {
                lock (this)
                {
                    coll.processcompleted.Reset();
                    PortID = coll.NodeList[iterator].LoadPortID;
                }
                switch (carrieroperation)
                {
                case CarrierOperations.Load:
                    Console.WriteLine(threadid + "  : Thread Load port ID " + coll.NodeList[iterator].LoadPortID);
                    if (PortID == p.LoadPorts)
                    {
                        lock (this)
                        {
                            Console.WriteLine("Entered Load operation for LP:" + p.LoadPorts.ToString());
                            Thread.Sleep(5000);
                            SetNextEnum(coll, iterator);
                            coll.SetEkvent();
                        }
                    }
                    else
                    {
                        Console.WriteLine(threadid + "  : " + "Enter (Wait) Load operation for LP:" + p.LoadPorts.ToString() + System.DateTime.Now.Second.ToString());

                        if (!coll.processcompleted.WaitOne())
                        {
                        }
                        Console.WriteLine(threadid + "  : " + " Exit (wait) Load operation for LP:" + p.LoadPorts.ToString() + System.DateTime.Now.Second.ToString());
                        //Console.WriteLine(threadid + "    Exited from Wait Load operation for LP:" + p.LoadPorts.ToString());
                    }
                    Thread.Sleep(200);
                    //coll.processcompleted.Set();
                    break;

                case CarrierOperations.PRJobCreate:
                    Console.WriteLine(threadid + "  : Thread Load port ID " + coll.NodeList[iterator].LoadPortID);
                    if (PortID == p.LoadPorts)
                    {
                        lock (this)
                        {
                            Console.WriteLine("Entered PRJobCreate operation for LP:" + p.LoadPorts.ToString());
                            Thread.Sleep(1000);
                            SetNextEnum(coll, iterator);
                            coll.SetEkvent();
                        }
                    }
                    else
                    {
                        Console.WriteLine(threadid + "  : " + "Enter (Wait) Load operation for LP:" + p.LoadPorts.ToString() + System.DateTime.Now.Second.ToString());

                        if (!coll.processcompleted.WaitOne())
                        {
                        }
                        Console.WriteLine(threadid + "  : " + " Exit (wait) Load operation for LP:" + p.LoadPorts.ToString() + System.DateTime.Now.Second.ToString());
                    }
                    Thread.Sleep(200);
                    // coll.processcompleted.Set();
                    break;

                case CarrierOperations.CJCreate:
                    Console.WriteLine(threadid + "  : Thread Load port ID " + coll.NodeList[iterator].LoadPortID);
                    if (PortID == p.LoadPorts)
                    {
                        lock (this)
                        {
                            Console.WriteLine("Entered CJCreate operation for LP:" + p.LoadPorts.ToString());
                            Thread.Sleep(1000);
                            SetNextEnum(coll, iterator);
                            coll.SetEkvent();
                        }
                    }
                    else
                    {
                        Console.WriteLine(threadid + "  : " + "Enter (Wait) Load operation for LP:" + p.LoadPorts.ToString() + System.DateTime.Now.Second.ToString());

                        if (!coll.processcompleted.WaitOne())
                        {
                        }
                        Console.WriteLine(threadid + "  : " + " Exit (wait) Load operation for LP:" + p.LoadPorts.ToString() + System.DateTime.Now.Second.ToString());
                    }
                    Thread.Sleep(200);
                    // coll.processcompleted.Set();
                    break;
                }
            }
        }
        catch (Exception ex)
        {
            Console.WriteLine("From Execute" + ex.Message.ToString());
        }
    }
示例#3
0
 public Node(CarrierOperations _s, int _v)
 {
     _string = _s;
     _int    = _v;
 }