/// <summary>
 ///  Recursively load data into the tuple current being loaded.
 /// </summary>
 /// <param name="handler">The handler constructing the current element.</param>
 /// <param name="schema">Schema of tuple being constructed.</param>
 /// <param name="row">Data source for tuple to construct.</param>
 /// <param name="absIndex">Absolute index into <code>row</code> for the next column to process.</param>
 /// <returns>The updated absolute index.</returns>
 private int fillTuple(OplDataHandler handler, ITupleSchema schema, IRow row, int absIndex)
 {
     handler.StartTuple();
     for (int i = 0; i < schema.Size; ++i)
     {
         if (schema.IsTuple(i))
         {
             ILOG.Opl_Core.Cppimpl.IloTupleSchema s = (ILOG.Opl_Core.Cppimpl.IloTupleSchema)schema;
             absIndex = fillTuple(handler, s.getTupleColumn(i), row, absIndex);
             continue;
         }
         if (schema.IsNum(i))
         {
             SET_FLOAT(handler, row, absIndex);
         }
         else if (schema.IsInt(i))
         {
             SET_INT(handler, row, absIndex);
         }
         else if (schema.IsSymbol(i))
         {
             SET_STRING(handler, row, absIndex);
         }
         else
         {
             throw new NotImplementedException("tuple element type not supported");
         }
         ++absIndex;
     }
     handler.EndTuple();
     return(absIndex);
 }
Exemplo n.º 2
0
            private void GetCostWeights(OplDataHandler handler)
            {
                // initialize the tuple set 'CostFunctionWeights'
                handler.StartElement("CostFunctionWeights");
                handler.StartSet();

                // Add tuple
                handler.StartTuple();
                handler.AddStringItem("a");
                handler.AddNumItem(LithographyArea.WeightA);
                handler.EndTuple();

                // Add tuple
                handler.StartTuple();
                handler.AddStringItem("b");
                handler.AddNumItem(LithographyArea.WeightB);
                handler.EndTuple();

                // Add tuple
                handler.StartTuple();
                handler.AddStringItem("c");
                handler.AddNumItem(LithographyArea.WeightC);
                handler.EndTuple();

                handler.EndSet();
                handler.EndElement();
            }
Exemplo n.º 3
0
        /// <summary>
        /// Reads a table and inject it as a tuple set in OPL.
        /// </summary>
        /// <param name="name">The name of the Data Set</param>
        /// <param name="reader">The SqlDataReader to read from</param>
        private void ReadTupleSet(String name, DbDataReader reader)
        {
            OplDataHandler handler = DataHandler;

            OplElement   element = handler.getElement(name);
            ITupleSchema schema  = element.AsTupleSet().Schema;
            int          size    = schema.Size;

            String[] oplFieldsName = new String[size];
            OplElementDefinitionType.Type[] oplFieldsType = new OplElementDefinitionType.Type[size];

            this.FillNamesAndTypes(schema, oplFieldsName, oplFieldsType);

            handler.StartElement(name);
            handler.StartSet();
            while (reader.Read())
            {
                handler.StartTuple();
                for (int column = 0; column < oplFieldsName.Length; column++)
                {
                    String columnName = oplFieldsName[column];
                    HandleColumnValue(handler, oplFieldsType[column], reader[columnName]);
                }
                handler.EndTuple();
            }
            handler.EndSet();
        }
 /// <summary>
 ///  Load an element that is just a value.
 /// </summary>
 private void loadPrimitive(OplDataHandler handler, string name, IEnumerator <IRow> rows, Action <OplDataHandler, IRow, int> setValue)
 {
     handler.StartElement(name);
     rows.MoveNext();
     setValue(handler, rows.Current, 0);
     handler.EndElement();
 }
    public override void CustomRead()
    {
        OplDataHandler handler = DataHandler;

        // Get the element of the predefined name.
        // If no such element is defined then exit early.
        // The element must be either a tuple or a set of tuples.
        // Any custom load specification specified by the element is then processed.
        OplElement spec = handler.getElement(ELEM_NAME);

        if (spec == null)
        {
            return;
        }
        if (spec.ElementType == OplElementType.Type.TUPLE)
        {
            loadSpec(handler, spec.AsTuple());
        }
        else if (spec.ElementType == OplElementType.Type.SET_TUPLE)
        {
            foreach (ITuple tuple in spec.AsTupleSet())
            {
                loadSpec(handler, tuple);
            }
        }
        else
        {
            throw new NotImplementedException(ELEM_NAME + " must be (set of) tuple");
        }
    }
Exemplo n.º 6
0
            private void GetOrders(OplDataHandler handler)
            {
                // initialize the tuple set 'Products'
                handler.StartElement("Orders");
                handler.StartSet();

                // Loop through queue
                for (int i = 0; i < Queue.Length; i++)
                {
                    // Peek next lot in queue
                    Lot peekLot = Queue.PeekAt(i);

                    bool eligible = false;

                    // Check if elible on any machine (not Down)
                    foreach (Machine machine in LithographyArea.Machines)
                    {
                        // Check if machine is Down
                        if (LithographyArea.MachineStates[machine.Name] == "Down")
                        {
                            continue;
                        }

                        // Get needed recipe for the lot
                        string recipe    = CPDispatcher.GetRecipe(peekLot, machine);
                        string recipeKey = machine.Name + "__" + recipe;

                        // Check if needed recipe is eligible on machine
                        bool recipeEligible = CPDispatcher.CheckMachineEligibility(recipeKey);

                        // Check if processingTime is known
                        bool processingTimeKnown = CPDispatcher.CheckProcessingTimeKnown(peekLot, machine, recipe);

                        if (recipeEligible && processingTimeKnown)
                        {
                            eligible = true;
                            break;
                        }
                    }

                    if (eligible)
                    {
                        // Add tuple
                        handler.StartTuple();
                        handler.AddStringItem(peekLot.Id.ToString()); //handler.AddStringItem(peekLot.Id.ToString());
                        handler.AddIntItem(ProductNameToID[peekLot.MasksetLayer_RecipeStepCluster]);
                        handler.AddIntItem(peekLot.LotQty);

                        handler.AddNumItem(CPDispatcher.GetDueDateWeight(peekLot));
                        handler.AddNumItem(CPDispatcher.GetWIPBalanceWeight(peekLot));

                        handler.EndTuple();
                    }
                }

                handler.EndSet();
                handler.EndElement();
            }
Exemplo n.º 7
0
        public override void CustomRead()
        {
            int _nbConfs   = 7;
            int _nbOptions = 5;

            OplDataHandler handler = getDataHandler();

            handler.StartElement("nbConfs");
            handler.AddIntItem(_nbConfs);
            handler.EndElement();
            handler.StartElement("nbOptions");
            handler.AddIntItem(_nbOptions);
            handler.EndElement();

            int[] _demand = { 5, 5, 10, 10, 10, 10, 5 };
            handler.StartElement("demand");
            handler.StartArray();
            for (int i = 0; i < _nbConfs; i++)
            {
                handler.AddIntItem(_demand[i]);
            }
            handler.EndArray();
            handler.EndElement();

            int[,] _option = { { 1, 0, 0, 0, 1, 1, 0 },
                               { 0, 0, 1, 1, 0, 1, 0 },
                               { 1, 0, 0, 0, 1, 0, 0 },
                               { 1, 1, 0, 1, 0, 0, 0 },
                               { 0, 0, 1, 0, 0, 0, 0 } };
            handler.StartElement("option");
            handler.StartArray();
            for (int i = 0; i < _nbOptions; i++)
            {
                handler.StartArray();
                for (int j = 0; j < _nbConfs; j++)
                {
                    handler.AddIntItem(_option[i, j]);
                }
                handler.EndArray();
            }
            handler.EndArray();
            handler.EndElement();

            int[,] _capacity = { { 1, 2 }, { 2, 3 }, { 1, 3 }, { 2, 5 }, { 1, 5 } };
            handler.StartElement("capacity");
            handler.StartArray();
            for (int i = 0; i < _nbOptions; i++)
            {
                handler.StartTuple();
                for (int j = 0; j <= 1; j++)
                {
                    handler.AddIntItem(_capacity[i, j]);
                }
                handler.EndTuple();
            }
            handler.EndArray();
            handler.EndElement();
        }
    /// <summary>
    ///  Load an element that is a plain tuple.
    /// </summary>
    private void loadTuple(OplDataHandler handler, string name, IEnumerator <IRow> rows)
    {
        OplElement elem  = handler.getElement(name);
        ITuple     tuple = elem.AsTuple();

        handler.StartElement(name);
        rows.MoveNext();
        fillTuple(handler, tuple.Schema, rows.Current, 0);
        handler.EndElement();
    }
 /// <summary>
 ///  Load a collection of tuples types.
 /// </summary>
 private void loadTupleCollection(OplDataHandler handler, string name, IEnumerator <IRow> rows, ITupleSchema schema, Action <OplDataHandler> startCollection, Action <OplDataHandler> endCollection)
 {
     handler.StartElement(name);
     startCollection(handler);
     while (rows.MoveNext())
     {
         fillTuple(handler, schema, rows.Current, 0);
     }
     endCollection(handler);
     handler.EndElement();
 }
 /// <summary>
 ///  Load a collection or array of primitive types.
 /// </summary>
 private void loadPrimitiveCollection(OplDataHandler handler, string name, IEnumerator <IRow> rows, Action <OplDataHandler> startCollection, Action <OplDataHandler> endCollection, Action <OplDataHandler, IRow, int> setValue)
 {
     handler.StartElement(name);
     startCollection(handler);
     while (rows.MoveNext())
     {
         setValue(handler, rows.Current, 0);
     }
     endCollection(handler);
     handler.EndElement();
 }
Exemplo n.º 11
0
            private void GetProductAuxResources(OplDataHandler handler)
            {
                // initialize the tuple set 'Products'
                handler.StartElement("ProductAuxResources");
                handler.StartSet();

                List <Lot> allLots = new List <Lot>();

                // Loop through queue
                for (int i = 0; i < Queue.Length; i++)
                {
                    // Peek next lot in queue
                    Lot peekLot = Queue.PeekAt(i);
                    allLots.Add(peekLot);
                }
                foreach (Machine machine in LithographyArea.Machines)
                {
                    if (machine.Queue.Length > 0)
                    {
                        Lot lotAtMachine = machine.Queue.PeekFirst();
                        allLots.Add(lotAtMachine);
                    }
                }

                List <string> productNames = new List <string>();

                // Loop through queue
                foreach (Lot lot in allLots)
                {
                    string productName = lot.MasksetLayer_RecipeStepCluster;

                    if (!productNames.Contains(productName))
                    {
                        // Add tuple
                        handler.StartTuple();
                        handler.AddIntItem(ProductNameToID[productName]);
                        handler.AddStringItem(lot.ReticleID1);
                        handler.EndTuple();

                        // Add tuple
                        handler.StartTuple();
                        handler.AddIntItem(ProductNameToID[productName]);
                        handler.AddStringItem(lot.IrdName);
                        handler.EndTuple();

                        productNames.Add(productName);
                    }
                }

                handler.EndSet();
                handler.EndElement();
            }
Exemplo n.º 12
0
        public override void CustomRead()
        {
            int _nbOrders = 12;
            int _nbSlabs  = 12;
            int _nbColors = 8;
            int _nbCap    = 20;

            OplDataHandler handler = getDataHandler();

            handler.StartElement("nbOrders");
            handler.AddIntItem(_nbOrders);
            handler.EndElement();
            handler.StartElement("nbSlabs");
            handler.AddIntItem(_nbSlabs);
            handler.EndElement();
            handler.StartElement("nbColors");
            handler.AddIntItem(_nbColors);
            handler.EndElement();
            handler.StartElement("nbCap");
            handler.AddIntItem(_nbCap);
            handler.EndElement();

            int[] _capacity = { 0, 11, 13, 16, 17, 19, 20, 23, 24, 25, 26, 27, 28, 29, 30, 33, 34, 40, 43, 45 };
            handler.StartElement("capacities");
            handler.StartArray();
            for (int i = 0; i < _nbCap; i++)
            {
                handler.AddIntItem(_capacity[i]);
            }
            handler.EndArray();
            handler.EndElement();

            int[] _weight = { 22, 9, 9, 8, 8, 6, 5, 3, 3, 3, 2, 2 };
            handler.StartElement("weight");
            handler.StartArray();
            for (int i = 0; i < _nbOrders; i++)
            {
                handler.AddIntItem(_weight[i]);
            }
            handler.EndArray();
            handler.EndElement();

            int[] _colors = { 5, 3, 4, 5, 7, 3, 6, 0, 2, 3, 1, 5 };
            handler.StartElement("colors");
            handler.StartArray();
            for (int i = 0; i < _nbOrders; i++)
            {
                handler.AddIntItem(_colors[i]);
            }
            handler.EndArray();
            handler.EndElement();
        }
Exemplo n.º 13
0
            private void GetProductIDs(OplDataHandler handler)
            {
                ProductNameToID = new Dictionary <string, int>();

                // initialize the tuple set 'Products'
                handler.StartElement("Products");
                handler.StartSet();

                List <Lot> allLots = new List <Lot>();

                // Loop through queue
                for (int i = 0; i < Queue.Length; i++)
                {
                    // Peek next lot in queue
                    Lot peekLot = Queue.PeekAt(i);
                    allLots.Add(peekLot);
                }
                foreach (Machine machine in LithographyArea.Machines)
                {
                    if (machine.Queue.Length > 0)
                    {
                        Lot lotAtMachine = machine.Queue.PeekFirst();
                        allLots.Add(lotAtMachine);
                    }
                }

                int productID = 0;

                // Loop through queue
                foreach (Lot lot in allLots)
                {
                    string productName = lot.MasksetLayer_RecipeStepCluster;

                    if (!ProductNameToID.ContainsKey(productName))
                    {
                        // Add tuple
                        handler.StartTuple();
                        handler.AddIntItem(productID);
                        handler.AddStringItem(productName);
                        handler.EndTuple();

                        ProductNameToID.Add(productName, productID);

                        productID += 1;
                    }
                }

                handler.EndSet();
                handler.EndElement();
            }
Exemplo n.º 14
0
            public override void CustomRead()
            {
                OplDataHandler handler = DataHandler;

                GetComputationalSettings(handler);
                GetCostWeights(handler);
                GetProductIDs(handler);
                GetOrders(handler);
                GetResources(handler);
                GetAuxResources(handler);
                GetProductAuxResources(handler);
                GetModes(handler);
                GetSetups(handler);
            }
Exemplo n.º 15
0
        /// <summary>
        /// Reads a table and inject the value as a Set in OPL.
        /// </summary>
        /// <param name="type">The type of the Set elements</param>
        /// <param name="name">The name of the Set</param>
        /// <param name="reader">The SqlDataReader to read from</param>
        private void ReadSet(OplElementDefinitionType.Type type, String name, DbDataReader reader)
        {
            OplDataHandler handler = DataHandler;

            handler.StartElement(name);
            handler.StartSet();

            while (reader.Read())
            {
                HandleColumnValue(handler, type, reader.GetValue(0));
            }

            handler.EndSet();
        }
Exemplo n.º 16
0
 /// <summary>
 /// Add a new item (field) to the Set currently in the Data handler.
 ///
 /// The value of the field is converted and added depending on fieldType.
 /// </summary>
 /// <param name="handler">The OPL data handler</param>
 /// <param name="fieldType">The type of the field to add</param>
 /// <param name="value">The value to convert</param>
 private void HandleColumnValue(OplDataHandler handler, OplElementDefinitionType.Type fieldType, object value)
 {
     if (fieldType == OplElementDefinitionType.Type.INTEGER)
     {
         handler.AddIntItem(Convert.ToInt32(value));
     }
     else if (fieldType == OplElementDefinitionType.Type.FLOAT)
     {
         handler.AddNumItem(Convert.ToDouble(value));
     }
     else if (fieldType == OplElementDefinitionType.Type.STRING)
     {
         handler.AddStringItem(Convert.ToString(value));
     }
 }
Exemplo n.º 17
0
            private void GetComputationalSettings(OplDataHandler handler)
            {
                // initialize the tuple set
                handler.StartElement("ComputationalSettings");
                handler.StartSet();

                // Add tuple
                handler.StartTuple();
                handler.AddStringItem("timeLimit");
                handler.AddIntItem(CPDispatcher.TimeLimit);
                handler.EndTuple();

                handler.EndSet();
                handler.EndElement();
            }
Exemplo n.º 18
0
        /// <summary>
        /// Overrides the CustomRead() method in the CustomOplDataSource.
        ///
        /// This is the method called for populating the tables when opl.Generate() is called.
        /// </summary>
        public override void CustomRead()
        {
            OplDataHandler handler = DataHandler;

            using (DbConnection con = DbUtils.CreateConnection(this.configuration))
            {
                con.Open();
                // read queries
                foreach (KeyValuePair <string, string> query in this.configuration.ReadQueries)
                {
                    Console.WriteLine("Reading table " + query.Key + " with query " + query.Value);
                    DbCommand command = con.CreateCommand();
                    command.CommandText = query.Value;
                    using (DbDataReader reader = command.ExecuteReader()) {
                        this.ReadSetOrTuple(query.Key, reader);
                    }
                }
            }
        }
Exemplo n.º 19
0
        public override void CustomRead()
        {
            OplDataHandler handler = DataHandler;

            handler.StartElement("nbWarehouses");
            handler.AddIntItem(_nbWarehouses);
            handler.EndElement();

            handler.StartElement("nbStores");
            handler.AddIntItem(_nbStores);
            handler.EndElement();

            handler.StartElement("fixed");
            handler.AddIntItem(_fixed);
            handler.EndElement();

            handler.StartElement("disaggregate");
            handler.AddIntItem(_disaggregate);
            handler.EndElement();
        }
Exemplo n.º 20
0
            private void GetAuxResources(OplDataHandler handler)
            {
                // initialize the tuple set 'Products'
                handler.StartElement("AuxResources");
                handler.StartSet();

                List <Lot> allLots = new List <Lot>();

                // Loop through queue
                for (int i = 0; i < Queue.Length; i++)
                {
                    // Peek next lot in queue
                    Lot peekLot = Queue.PeekAt(i);
                    allLots.Add(peekLot);
                }
                foreach (Machine machine in LithographyArea.Machines)
                {
                    if (machine.Queue.Length > 0)
                    {
                        Lot lotAtMachine = machine.Queue.PeekFirst();
                        allLots.Add(lotAtMachine);
                    }
                }

                // Get Reticles

                List <string> allReticles = new List <string>();

                // Loop through queue
                foreach (Lot lot in allLots)
                {
                    if (!allReticles.Contains(lot.ReticleID1))
                    {
                        if (lot.ReticleID1 == "4106")
                        {
                            // Add tuple
                            handler.StartTuple();
                            handler.AddStringItem(lot.ReticleID1);
                            handler.AddIntItem(2);
                            handler.EndTuple();
                        }
                        else
                        {
                            // Add tuple
                            handler.StartTuple();
                            handler.AddStringItem(lot.ReticleID1);
                            handler.AddIntItem(1);
                            handler.EndTuple();
                        }
                        allReticles.Add(lot.ReticleID1);
                    }
                }

                // Get IRDNames

                List <string> allIRDNames = new List <string>();

                // Loop through queue
                foreach (Lot lot in allLots)
                {
                    if (!allIRDNames.Contains(lot.IrdName))
                    {
                        // Add tuple
                        handler.StartTuple();
                        handler.AddStringItem(lot.IrdName);
                        int capacity = 2;
                        if (CPDispatcher.AvailableResources.ContainsKey(lot.IrdName))
                        {
                            capacity = CPDispatcher.AvailableResources[lot.IrdName];
                        }
                        handler.AddIntItem(capacity);
                        handler.EndTuple();

                        allIRDNames.Add(lot.IrdName);
                    }
                }

                handler.EndSet();
                handler.EndElement();
            }
Exemplo n.º 21
0
            private void GetSetups(OplDataHandler handler)
            {
                // initialize the tuple set 'Products'
                handler.StartElement("Setups");
                handler.StartSet();

                List <Lot> allLots = new List <Lot>();

                // Loop through queue
                for (int i = 0; i < Queue.Length; i++)
                {
                    // Peek next lot in queue
                    Lot peekLot = Queue.PeekAt(i);
                    allLots.Add(peekLot);
                }
                foreach (Machine machine in LithographyArea.Machines)
                {
                    if (machine.Queue.Length > 0)
                    {
                        Lot lotAtMachine = machine.Queue.PeekFirst();
                        allLots.Add(lotAtMachine);
                    }
                }

                List <string> productNamesFrom = new List <string>();

                // Loop through queue
                foreach (Lot lotFrom in allLots)
                {
                    if (!productNamesFrom.Contains(lotFrom.MasksetLayer_RecipeStepCluster))
                    {
                        List <string> productNamesTo = new List <string>();

                        // Loop through queue
                        foreach (Lot lotTo in allLots)
                        {
                            if (!productNamesTo.Contains(lotTo.MasksetLayer_RecipeStepCluster))
                            {
                                if (lotFrom.ReticleID1 == lotTo.ReticleID1)
                                {
                                    // Add tuple
                                    handler.StartTuple();
                                    handler.AddStringItem("MTRX_ARMS");
                                    handler.AddIntItem(ProductNameToID[lotFrom.MasksetLayer_RecipeStepCluster]);
                                    handler.AddIntItem(ProductNameToID[lotTo.MasksetLayer_RecipeStepCluster]);
                                    handler.AddIntItem((int)LithographyArea.DeterministicNonProductiveTimesARMS["SameReticle"]);
                                    handler.EndTuple();

                                    // Add tuple
                                    handler.StartTuple();
                                    handler.AddStringItem("MTRX_RMS");
                                    handler.AddIntItem(ProductNameToID[lotFrom.MasksetLayer_RecipeStepCluster]);
                                    handler.AddIntItem(ProductNameToID[lotTo.MasksetLayer_RecipeStepCluster]);
                                    handler.AddIntItem((int)LithographyArea.DeterministicNonProductiveTimesRMS["SameReticle"]);
                                    handler.EndTuple();
                                }
                                else if (lotFrom.ReticleID1 != lotTo.ReticleID1 && lotFrom.IrdName == lotTo.IrdName)
                                {
                                    // Add tuple
                                    handler.StartTuple();
                                    handler.AddStringItem("MTRX_ARMS");
                                    handler.AddIntItem(ProductNameToID[lotFrom.MasksetLayer_RecipeStepCluster]);
                                    handler.AddIntItem(ProductNameToID[lotTo.MasksetLayer_RecipeStepCluster]);
                                    handler.AddIntItem((int)LithographyArea.DeterministicNonProductiveTimesARMS["DifferentReticle"]);
                                    handler.EndTuple();

                                    // Add tuple
                                    handler.StartTuple();
                                    handler.AddStringItem("MTRX_RMS");
                                    handler.AddIntItem(ProductNameToID[lotFrom.MasksetLayer_RecipeStepCluster]);
                                    handler.AddIntItem(ProductNameToID[lotTo.MasksetLayer_RecipeStepCluster]);
                                    handler.AddIntItem((int)LithographyArea.DeterministicNonProductiveTimesRMS["DifferentReticle"]);
                                    handler.EndTuple();
                                }
                                else
                                {
                                    // Add tuple
                                    handler.StartTuple();
                                    handler.AddStringItem("MTRX_ARMS");
                                    handler.AddIntItem(ProductNameToID[lotFrom.MasksetLayer_RecipeStepCluster]);
                                    handler.AddIntItem(ProductNameToID[lotTo.MasksetLayer_RecipeStepCluster]);
                                    handler.AddIntItem((int)LithographyArea.DeterministicNonProductiveTimesARMS["DifferentIRD"]);
                                    handler.EndTuple();

                                    // Add tuple
                                    handler.StartTuple();
                                    handler.AddStringItem("MTRX_RMS");
                                    handler.AddIntItem(ProductNameToID[lotFrom.MasksetLayer_RecipeStepCluster]);
                                    handler.AddIntItem(ProductNameToID[lotTo.MasksetLayer_RecipeStepCluster]);
                                    handler.AddIntItem((int)LithographyArea.DeterministicNonProductiveTimesRMS["DifferentIRD"]);
                                    handler.EndTuple();
                                }
                                productNamesTo.Add(lotTo.MasksetLayer_RecipeStepCluster);
                            }
                        }
                        productNamesFrom.Add(lotFrom.MasksetLayer_RecipeStepCluster);
                    }
                }
                handler.EndSet();
                handler.EndElement();
            }
Exemplo n.º 22
0
            private void GetModes(OplDataHandler handler)
            {
                // initialize the tuple set 'Products'
                handler.StartElement("Modes");
                handler.StartSet();

                List <Lot> allLots = new List <Lot>();

                // Loop through queue
                for (int i = 0; i < Queue.Length; i++)
                {
                    // Peek next lot in queue
                    Lot peekLot = Queue.PeekAt(i);
                    allLots.Add(peekLot);
                }
                foreach (Machine machine in LithographyArea.Machines)
                {
                    if (machine.Queue.Length > 0)
                    {
                        Lot lotAtMachine = machine.Queue.PeekFirst();
                        allLots.Add(lotAtMachine);
                    }
                }

                List <string> productNames = new List <string>();

                // Loop through queue
                foreach (Lot lot in allLots)
                {
                    if (!productNames.Contains(lot.MasksetLayer_RecipeStepCluster))
                    {
                        int modeNr = 0;

                        foreach (Machine machine in LithographyArea.Machines)
                        {
                            // Check if machine is Down
                            if (LithographyArea.MachineStates[machine.Name] == "Down")
                            {
                                continue;
                            }

                            // Get needed recipe for the lot
                            string recipe    = CPDispatcher.GetRecipe(lot, machine);
                            string recipeKey = machine.Name + "__" + recipe;

                            // Check if needed recipe is eligible on machine
                            bool recipeEligible = CPDispatcher.CheckMachineEligibility(recipeKey);

                            // Check if processingTime is known
                            bool processingTimeKnown = CPDispatcher.CheckProcessingTimeKnown(lot, machine, recipe);

                            if (recipeEligible && processingTimeKnown)
                            {
                                int?processingTime = null;

                                processingTime = (int)machine.GetDeterministicProcessingTimeFullLot(lot);

                                // Add tuple
                                handler.StartTuple();
                                handler.AddIntItem(ProductNameToID[lot.MasksetLayer_RecipeStepCluster]);
                                handler.AddIntItem(modeNr);
                                handler.AddStringItem(machine.Name);
                                handler.AddIntItem((int)processingTime);

                                handler.EndTuple();

                                modeNr += 1;
                            }
                        }
                        productNames.Add(lot.MasksetLayer_RecipeStepCluster);
                    }
                }

                handler.EndSet();
                handler.EndElement();
            }
Exemplo n.º 23
0
            public override void CustomRead()
            {
                OplDataHandler handler = DataHandler;

                // initialize the int 'simpleInt'
                handler.StartElement("anInt");
                handler.AddIntItem(3);
                handler.EndElement();

                // initialize the int array 'simpleIntArray'
                handler.StartElement("anIntArray");
                handler.StartArray();
                handler.AddIntItem(1);
                handler.AddIntItem(2);
                handler.AddIntItem(3);
                handler.EndArray();
                handler.EndElement();

                // initialize int array indexed by float 'anArrayIndexedByFloat'
                handler.StartElement("anArrayIndexedByFloat");
                handler.StartIndexedArray();
                handler.SetItemNumIndex(2.0);
                handler.AddIntItem(1);
                handler.SetItemNumIndex(2.5);
                handler.AddIntItem(2);
                handler.SetItemNumIndex(1.0);
                handler.AddIntItem(3);
                handler.SetItemNumIndex(1.5);
                handler.AddIntItem(4);
                handler.EndIndexedArray();
                handler.EndElement();

                // initialize int array indexed by string 'anArrayIndexedByString'
                handler.StartElement("anArrayIndexedByString");
                handler.StartIndexedArray();
                handler.SetItemStringIndex("idx1");
                handler.AddIntItem(1);
                handler.SetItemStringIndex("idx2");
                handler.AddIntItem(2);
                handler.EndIndexedArray();
                handler.EndElement();

                // initialize a tuple in the order the components are declared
                handler.StartElement("aTuple");
                handler.StartTuple();
                handler.AddIntItem(1);
                handler.AddNumItem(2.3);
                handler.AddStringItem("not named tuple");
                handler.EndTuple();
                handler.EndElement();

                // initialize a tuple using tuple component names.
                handler.StartElement("aNamedTuple");
                handler.StartNamedTuple();
                handler.SetItemName("f");
                handler.AddNumItem(3.45);
                handler.SetItemName("s");
                handler.AddStringItem("named tuple");
                handler.SetItemName("i");
                handler.AddIntItem(99);
                handler.EndNamedTuple();
                handler.EndElement();

                // initialize the tuple set 'simpleTupleSet'
                handler.StartElement("aTupleSet");
                handler.StartSet();
                // first tuple
                handler.StartTuple();
                handler.AddIntItem(1);
                handler.AddNumItem(2.5);
                handler.AddStringItem("a");
                handler.EndTuple();
                // second element
                handler.StartTuple();
                handler.AddIntItem(3);
                handler.AddNumItem(4.1);
                handler.AddStringItem("b");
                handler.EndTuple();
                handler.EndSet();
                handler.EndElement();

                // initialize element 3 and 2 of the tuple array 'simpleTupleArray' in that particular order
                handler.StartElement("aTupleArray");
                handler.StartIndexedArray();
                // initialize 3rd cell
                handler.SetItemIntIndex(3);
                handler.StartTuple();
                handler.AddIntItem(1);
                handler.AddNumItem(2.5);
                handler.AddStringItem("a");
                handler.EndTuple();
                // initialize second cell
                handler.SetItemIntIndex(2);
                handler.StartTuple();
                handler.AddIntItem(3);
                handler.AddNumItem(4.1);
                handler.AddStringItem("b");
                handler.EndTuple();
                handler.EndIndexedArray();
                handler.EndElement();

                // initialize int array indexed by tuple set 'anArrayIndexedByTuple'
                handler.StartElement("anArrayIndexedByTuple");
                handler.StartIndexedArray();
                handler.StartItemTupleIndex();
                handler.AddIntItem(3);
                handler.AddNumItem(4.1);
                handler.AddStringItem("b");
                handler.EndItemTupleIndex();
                handler.AddIntItem(1);
                handler.EndIndexedArray();
                handler.EndElement();

                // initialize a 2-dimension int array 'a2DIntArray'
                handler.StartElement("a2DIntArray");
                handler.StartArray();
                for (int i = 1; i <= 2; i++)
                {
                    handler.StartArray();
                    for (int j = 1; j <= 3; j++)
                    {
                        handler.AddIntItem(i * 10 + j);
                    }
                    handler.EndArray();
                }
                handler.EndArray();
                handler.EndElement();
            }
Exemplo n.º 24
0
        public override void CustomRead()
        {
            int    beginTime  = 1920;  //need to initialized
            int    endTime    = 2100;  //need to initialized
            String marketCity = "SHA"; //need to initialized

            /*
             * 1* FlightCode:{"1033538119", "1033538066"}
             * 2* FlightInfo:[<"738","D",1323,1800,0>,<"738","D",1341,1800,0>]
             * 3* StandCode:{"301","302"}
             * 4* StandInfo:[<"N",2>,<"N",2>]
             * 5* Stnd_fl_type:[0,1...]
             * 6* preflightcode:{"1033538119", "1033538066"}
             * 7* prestnd:
             * 8* SCAdjCon:[<"N207","N207L">,<"N207","N207R">,<"N206","N206L">]
             */

            OplDataHandler handler = getDataHandler();

            //1.FlightCode
            handler.StartElement("FlightCode");
            handler.StartSet();
            List <FlightInfo> FlightCode = new List <FlightInfo>();

            for (int i = 0; i < FlightCode.Count; i++)
            {
                handler.AddStringItem(FlightCode[i].flightCode);
            }
            handler.EndSet();
            handler.EndElement();

            //2.FlightInfo
            handler.StartElement("FlightInfo");
            handler.StartSet();
            List <FlightInfo> FlightInfo = new List <FlightInfo>();

            for (int i = 0; i < FlightInfo.Count; i++)
            {
                handler.StartTuple();
                handler.AddStringItem(FlightInfo[i].flightType);
                handler.AddStringItem(FlightInfo[i].d_or_i);
                handler.AddIntItem(int.Parse(FlightInfo[i].startTime));//是否要转为int??居飞
                handler.AddIntItem(int.Parse(FlightInfo[i].endTime));
                handler.AddIntItem(int.Parse(FlightInfo[i].isTurnArround));
                handler.EndTuple();
            }
            handler.EndSet();
            handler.EndElement();

            //3.StandCode
            handler.StartElement("StandCode");
            handler.StartSet();
            List <StandInfo> StandCode = new List <StandInfo>();

            for (int i = 0; i < StandCode.Count; i++)
            {
                handler.AddStringItem(StandCode[i].standCode);
            }
            handler.EndSet();
            handler.EndElement();

            //4.StandInfo
            handler.StartElement("StandInfo");
            handler.StartSet();
            List <StandInfo> StandInfo = new List <StandInfo>();

            for (int i = 0; i < StandInfo.Count; i++)
            {
                handler.StartTuple();
                handler.AddStringItem(StandInfo[i].near_or_far);
                handler.AddIntItem(int.Parse(StandInfo[i].priority));
                handler.EndTuple();
            }
            handler.EndSet();
            handler.EndElement();

            //5.Stnd_fl_type
            handler.StartElement("Stnd_fl_type");
            handler.StartSet();

            //6.preflightcode
            handler.StartElement("preflightcode");
            handler.StartSet();

            //7.prestnd
            handler.StartElement("prestnd");
            handler.StartSet();

            //8.SCAdjCon
            handler.StartElement("SCAdjCon");
            handler.StartSet();

            Console.WriteLine("Read Over");
        }
    /// <summary>
    ///  Process one load specification.
    /// </summary>
    /// <param name="handler">The data loader that constructs OPL elements.</param>
    /// <param name="tuple">The load specification.</param>
    private void loadSpec(OplDataHandler handler, ITuple tuple)
    {
        // Get the connection string
        // In the SimpleData implementation we don't use that string.
        // If you create a data source that is backed up by a file or
        // by a database, then this string can be used to specify
        // locations and/or credentials.
        string connection = tuple.GetStringValue(CONN_FIELD);

        connection = Interpolate(connection, handler);

        string connectionType = tryLoadField(tuple, TYPE_FIELD, "SimpleData");

        connectionType = Interpolate(connectionType, handler);
        IDataProvider provider = null;

        if (connectionType.Equals("SimpleData"))
        {
            provider = new SimpleData(connection);
        }
        else if (connectionType.Equals("SQLite"))
        {
            provider = new SQLiteData(connection);
        }
        else
        {
            provider = new GenericData(connectionType, connection);
        }

        // Process each of load specifications and load the respective
        // element.
        using (provider)
        {
            ISymbolSet  data = tuple.GetSymbolSetValue(DATA_FIELD);
            IEnumerator e    = data.GetEnumerator();
            while (e.MoveNext())
            {
                // Split specification into element name and
                // initialiation string (statement).
                string s    = Interpolate(e.Current.ToString().Trim(), handler);
                int    eq   = s.IndexOf('=');
                string name = s.Substring(0, eq).Trim();
                string stmt = s.Substring(eq + 1).Trim();

                // Inspect the type of the element and populate it.
                OplElement          elem = handler.getElement(name);
                OplElementType.Type type = elem.ElementType;
                using (IEnumerator <IRow> rows = provider.getRows(stmt))
                {
                    // (collections of) integers
                    if (type == OplElementType.Type.INT)
                    {
                        loadPrimitive(handler, name, rows, SET_INT);
                    }
                    else if (type == OplElementType.Type.SET_INT)
                    {
                        loadPrimitiveCollection(handler, name, rows, START_SET, END_SET, SET_INT);
                    }
                    else if (type == OplElementType.Type.MAP_INT)
                    {
                        loadPrimitiveCollection(handler, name, rows, START_ARRAY, END_ARRAY, SET_INT);
                    }

                    // (collections of) floating point values
                    else if (type == OplElementType.Type.NUM)
                    {
                        loadPrimitive(handler, name, rows, SET_FLOAT);
                    }
                    else if (type == OplElementType.Type.SET_NUM)
                    {
                        loadPrimitiveCollection(handler, name, rows, START_SET, END_SET, SET_FLOAT);
                    }
                    else if (type == OplElementType.Type.MAP_NUM)
                    {
                        loadPrimitiveCollection(handler, name, rows, START_ARRAY, END_ARRAY, SET_FLOAT);
                    }

                    // (collections of) tuples
                    else if (type == OplElementType.Type.STRING)
                    {
                        loadPrimitive(handler, name, rows, SET_STRING);
                    }
                    else if (type == OplElementType.Type.SET_SYMBOL)
                    {
                        loadPrimitiveCollection(handler, name, rows, START_SET, END_SET, SET_STRING);
                    }
                    else if (type == OplElementType.Type.MAP_SYMBOL)
                    {
                        loadPrimitiveCollection(handler, name, rows, START_ARRAY, END_ARRAY, SET_STRING);
                    }

                    else if (type == OplElementType.Type.TUPLE)
                    {
                        loadTuple(handler, name, rows);
                    }
                    else if (type == OplElementType.Type.SET_TUPLE)
                    {
                        loadTupleCollection(handler, name, rows, elem.AsTupleSet().Schema, START_SET, END_SET);
                    }
                    else if (type == OplElementType.Type.MAP_TUPLE)
                    {
                        loadTupleCollection(handler, name, rows, elem.AsTupleMap().Schema, START_ARRAY, END_ARRAY);
                    }
                    else
                    {
                        throw new NotImplementedException("element type " + type + " not implemented");
                    }
                }
            }
        }
    }
    /// <summary>
    /// Interpolate model elements or environment variables into a string.
    /// Character sequences like $(NAME) are replaced with the model element NAME.
    /// Character sequences like ${NAME} are replaced with the environment variable NAME.
    /// </summary>
    /// <param name="text">The text in which the replacement happens.</param>
    /// <param name="handler">The handler from which model elements are read.</param>
    /// <returns></returns>
    private static string Interpolate(string text, OplDataHandler handler)
    {
        // Return value
        StringBuilder b = new StringBuilder(text.Length);
        // The closing parenthesis we are looking for (or NUL)
        char unquote = '\0';
        // The text between open and closing parenthesis.
        StringBuilder quoted = null;
        // Was the last character a $
        bool dollar = false;

        foreach (char c in text)
        {
            if (unquote != '\0')
            {
                if (c == unquote)
                {
                    switch (unquote)
                    {
                    case ')':
                        // Interpolate model element
                        OplElement elem = handler.getElement(quoted.ToString());
                        if (elem == null)
                        {
                            throw new SystemException("undefined element " + quoted.ToString() + " referenced in " + text);
                        }
                        if (elem.ElementType.Equals(OplElementType.Type.INT))
                        {
                            b.Append(elem.AsInt());
                        }
                        else if (elem.ElementType.Equals(OplElementType.Type.NUM))
                        {
                            b.Append(elem.AsNum());
                        }
                        else if (elem.ElementType.Equals(OplElementType.Type.STRING))
                        {
                            b.Append(elem.AsString());
                        }
                        else
                        {
                            throw new SystemException("reference element " + quoted.ToString() + " has invalid type " + elem.ElementType);
                        }
                        break;

                    case '}':
                        // Interpolate environment variable.
                        string value = Environment.GetEnvironmentVariable(quoted.ToString());
                        if (value != null)
                        {
                            b.Append(value);
                        }
                        break;
                    }
                    unquote = '\0';
                    quoted  = null;
                }
                else
                {
                    quoted.Append(c);
                }
            }
            else if (c == '$')
            {
                if (dollar)
                {
                    // $$ is used to mean a literal $
                    b.Append('$');
                    dollar = false;
                }
                else
                {
                    dollar = true;
                }
            }
            else if (dollar)
            {
                // last character was a $ but current one is not: we must start a quote
                switch (c)
                {
                case '(':
                    unquote = ')';
                    quoted  = new StringBuilder();
                    break;

                case '{':
                    unquote = '}';
                    quoted  = new StringBuilder();
                    break;

                default:
                    throw new SystemException("ínvalid text " + text);
                }
                dollar = false;
            }

            else
            {
                b.Append(c);
            }
        }
        if (dollar || unquote != '\0')
        {
            throw new SystemException("bad quotes in " + text);
        }
        return(b.ToString());
    }
Exemplo n.º 27
0
            private void GetResources(OplDataHandler handler)
            {
                // initialize the tuple set 'Products'
                handler.StartElement("Resources");
                handler.StartSet();

                // Loop through queue
                foreach (Machine machine in LithographyArea.Machines)
                {
                    // Check if machine is Down
                    if (LithographyArea.MachineStates[machine.Name] == "Down")
                    {
                        continue;
                    }

                    int initialProductID        = -1;
                    int endTimeInitialProductID = 0;

                    // Check if a lot is loaded on the machine
                    if (machine.Queue.Length > 0)
                    {
                        Lot lotAtMachine = machine.Queue.PeekFirst();
                        initialProductID = ProductNameToID[lotAtMachine.MasksetLayer_RecipeStepCluster];
                        double estimatedEndTime;

                        if (machine.CurrentLot == lotAtMachine)
                        {
                            estimatedEndTime = machine.CurrentStartRun + machine.GetDeterministicProcessingTime(lotAtMachine);

                            if (estimatedEndTime > LithographyArea.GetTime)
                            {
                                endTimeInitialProductID = (int)estimatedEndTime - (int)LithographyArea.GetTime;
                            }
                        }
                        else
                        {
                            estimatedEndTime        = machine.GetDeterministicProcessingTime(lotAtMachine);
                            endTimeInitialProductID = (int)estimatedEndTime;
                        }
                    }

                    if (machine.Name.Contains("#5") || machine.Name.Contains("#7") || machine.Name.Contains("#9"))
                    {
                        // Add tuple
                        handler.StartTuple();
                        handler.AddStringItem(machine.Name);
                        handler.AddStringItem("MTRX_RMS");
                        handler.AddIntItem(initialProductID);
                        handler.AddIntItem(endTimeInitialProductID);
                        handler.EndTuple();
                    }
                    else
                    {
                        // Add tuple
                        handler.StartTuple();
                        handler.AddStringItem(machine.Name);
                        handler.AddStringItem("MTRX_ARMS");
                        handler.AddIntItem(initialProductID);
                        handler.AddIntItem(endTimeInitialProductID);
                        handler.EndTuple();
                    }
                }

                handler.EndSet();
                handler.EndElement();
            }