Exemplo n.º 1
0
        //ecapsulate union information in artificial lines containing Union objects
        private static void buildUnions(List<Line> lines)
        {
            bool[] loadStates = new bool[16]; //keeps track of which properties have already occured

            bool readyUnion = false; //union header has been seen (offsets block recognition by 1, leaves union headers, destroys EndUnion footer)
            bool inUnion = false; //first keyword duplication has been reached, begin submitting data
            bool createdLine = false; //lets the line remover know if the loop counter needs decrementing
            Line line = null; //current line
            Union union = new Union(); //currently building union

            for (int i = 0; i < lines.Count; i++)
            {
                line = lines[i];
                createdLine = false;

                //Debug.WriteLine(line.original + "   =   " + inUnion.ToString());

                //set as ready if these states are detected
                if (line.typeValue == ControlType.Union) { readyUnion = true; }
                else if (line.typeValue == ControlType.EndUnion) { readyUnion = true; }

                //block recognition
                if ((line.keyword.found() && loadStates[line.keyword.index]) || (line.keyword.index == 15))
                {
                    //this keyword has been loaded before, check and submit whatever was loaded

                    if (readyUnion && !inUnion) //switch inUnion ON
                    {
                        readyUnion = false;
                        inUnion = true;
                    }
                    else if (readyUnion && inUnion) //switch inUnion OFF
                    {
                        readyUnion = false;
                        inUnion = false;
                    }

                    //submit a continuous union block
                    if (inUnion && (union.type == ControlType.Continuous))
                    {
                        Line newLine = new Line();
                        newLine.unionValue = union;
                        union = new Union();
                        newLine.type = valueType.UNION;
                        //Debug.WriteLine("[INSERT CONT]");
                        lines.Insert(i, newLine);
                        createdLine = true;
                    }

                    //always clear loadStates
                    for (int k = 0; k < loadStates.Length; k++)
                    {
                        loadStates[k] = false;
                    }
                    //ready for next block
                }

                //store applicable keywords in the corresponding union location
                switch (line.keyword.index)
                {
                    case 1:
                        union.name = line.stringValue;
                        loadStates[1] = true;//mark this property as loaded
                        break;
                    case 2:
                        union.type = line.typeValue;
                        loadStates[2] = true;//mark this property as loaded
                        break;
                    case 12:
                        union.max = line.intValue;
                        loadStates[12] = true;//mark this property as loaded
                        break;
                    case 13:
                        union.min = line.intValue;
                        loadStates[13] = true;//mark this property as loaded
                        break;
                    case 14:
                        if (inUnion) //index in a union, submit on the spot (all in one line)
                        {
                            //Debug.WriteLine("[INSERT INDEX]");
                            Line newLine = new Line();
                            Union indexUnion = new Union();
                            indexUnion.name = line.indexValue.name;
                            indexUnion.min = line.indexValue.value;
                            indexUnion.type = ControlType.Indexed;
                            newLine.unionValue = indexUnion;
                            newLine.type = valueType.UNION;
                            lines.Insert(i, newLine);
                            createdLine = true;
                        }
                        break;
                }

                if (inUnion)
                {
                    lines.Remove(line); //always remove union lines (since they've been converted)
                    if (!createdLine) { i--; } //don't need to decrement if a lines already been added
                }
            }//end line loop
        }
Exemplo n.º 2
0
 public Union clone()
 {
     Union union = new Union();
     union.name = this.name;
     union.type = this.type;
     union.min = this.min;
     union.max = this.max;
     return union;
 }
Exemplo n.º 3
0
 //called by form UnionGenerator.cs
 public static void genUnion(Trait trait, bool cont, int count, int start, int span, int seperation, String prefix)
 {
     if (cont)
     {
         span--;
         for (int i = 0; i < count; i++)
         {
             Union union = new Union();
             union.name = prefix + " " + (i + 1).ToString();
             union.type = ControlType.Continuous;
             union.min = start + ((span + seperation) * i);
             union.max = union.min + span;
             trait.union.Add(union);
         }
     }
     else
     {
         for (int i = 0; i < count; i++)
         {
             Union union = new Union();
             union.name = prefix + " " + (i + 1).ToString();
             union.type = ControlType.Indexed;
             union.min = start + (seperation * i);
             trait.union.Add(union);
         }
     }
 }
Exemplo n.º 4
0
        public static void addUnion(Trait trait)
        {
            Union union = new Union();

            if (trait.union.Count > 0)
            {
                //if there are things in the list, use the last type (better workflow)
                union.type = trait.union[trait.union.Count - 1].type;
            }
            else
            {
                union.type = ControlType.Continuous;
            }

            trait.union.Add(union);
            union.name = "Union " + trait.union.Count;
            union.min = 0;
            union.max = 255;
        }
Exemplo n.º 5
0
        } //end buildTraits()

        //ecapsulate union information in artificial lines containing Union objects
        private static void buildUnions(List <Line> lines)
        {
            bool[] loadStates = new bool[16]; //keeps track of which properties have already occured

            bool  readyUnion  = false;        //union header has been seen (offsets block recognition by 1, leaves union headers, destroys EndUnion footer)
            bool  inUnion     = false;        //first keyword duplication has been reached, begin submitting data
            bool  createdLine = false;        //lets the line remover know if the loop counter needs decrementing
            Line  line        = null;         //current line
            Union union       = new Union();  //currently building union

            for (int i = 0; i < lines.Count; i++)
            {
                line        = lines[i];
                createdLine = false;

                //Debug.WriteLine(line.original + "   =   " + inUnion.ToString());

                //set as ready if these states are detected
                if (line.typeValue == ControlType.Union)
                {
                    readyUnion = true;
                }
                else if (line.typeValue == ControlType.EndUnion)
                {
                    readyUnion = true;
                }

                //block recognition
                if ((line.keyword.found() && loadStates[line.keyword.index]) || (line.keyword.index == 15))
                {
                    //this keyword has been loaded before, check and submit whatever was loaded

                    if (readyUnion && !inUnion) //switch inUnion ON
                    {
                        readyUnion = false;
                        inUnion    = true;
                    }
                    else if (readyUnion && inUnion) //switch inUnion OFF
                    {
                        readyUnion = false;
                        inUnion    = false;
                    }

                    //submit a continuous union block
                    if (inUnion && (union.type == ControlType.Continuous))
                    {
                        Line newLine = new Line();
                        newLine.unionValue = union;
                        union        = new Union();
                        newLine.type = valueType.UNION;
                        //Debug.WriteLine("[INSERT CONT]");
                        lines.Insert(i, newLine);
                        createdLine = true;
                    }

                    //always clear loadStates
                    for (int k = 0; k < loadStates.Length; k++)
                    {
                        loadStates[k] = false;
                    }
                    //ready for next block
                }

                //store applicable keywords in the corresponding union location
                switch (line.keyword.index)
                {
                case 1:
                    union.name    = line.stringValue;
                    loadStates[1] = true;    //mark this property as loaded
                    break;

                case 2:
                    union.type    = line.typeValue;
                    loadStates[2] = true;    //mark this property as loaded
                    break;

                case 12:
                    union.max      = line.intValue;
                    loadStates[12] = true;    //mark this property as loaded
                    break;

                case 13:
                    union.min      = line.intValue;
                    loadStates[13] = true;    //mark this property as loaded
                    break;

                case 14:
                    if (inUnion)     //index in a union, submit on the spot (all in one line)
                    {
                        //Debug.WriteLine("[INSERT INDEX]");
                        Line  newLine    = new Line();
                        Union indexUnion = new Union();
                        indexUnion.name    = line.indexValue.name;
                        indexUnion.min     = line.indexValue.value;
                        indexUnion.type    = ControlType.Indexed;
                        newLine.unionValue = indexUnion;
                        newLine.type       = valueType.UNION;
                        lines.Insert(i, newLine);
                        createdLine = true;
                    }
                    break;
                }

                if (inUnion)
                {
                    lines.Remove(line); //always remove union lines (since they've been converted)
                    if (!createdLine)
                    {
                        i--;
                    }                          //don't need to decrement if a lines already been added
                }
            }//end line loop
        } //end buildUnions()
Exemplo n.º 6
0
        //Internal Functions//////////////////////////////////////////////////////////////


        /*
         *  function for compiling information stored in Data.Traits
         *  returns string of finished DDL
         */
        private static String export()
        {
            String DDL = "";

            //Header
            DDL += ";*************************************************" + n;
            DDL += ";      Fixture: " + Data.fixture + n;
            DDL += ";      Brand: " + Data.manufacturer + n;
            DDL += ";      Channels: " + maxChannel().ToString() + n;
            DDL += ";      Notes: " + Data.notes + n;
            DDL += ";      Created by " + Data.creator + n;
            DDL += ";      Created on " + DateTime.Now.ToString("M/d/yyyy") + n;
            DDL += ";      Made using DDL Creator (TM)" + n;
            DDL += ";      (c)2008-2013 WindWorks Design" + n;
            DDL += ";      www.windworksdesign.com" + n;
            DDL += ";*************************************************" + n + n;

            //Device name
            DDL += "Device " + Data.fixture + n + n;

            //Trait definitions
            for (int t = 0; t < Data.traits.Count; t++)
            {
                Trait trait = Data.traits[t];

                switch (trait.type)
                {
                case ControlType.Continuous:     /////////////////
                    DDL += "           Trait " + trait.name + n;
                    DDL += "            Type " + trait.type.ToString() + n;
                    DDL += "         Channel " + trait.channel.ToString() + n;
                    DDL += "            Size " + sizeToString(trait.size) + n;
                    DDL += "          Invert " + boolToString(trait.invert) + n;
                    DDL += "           XAxis " + boolToString(trait.x) + n;
                    DDL += "           YAxis " + boolToString(trait.y) + n;
                    DDL += "           Black " + boolToString(trait.black) + n;
                    DDL += "         BoValue " + trait.blackValue.ToString() + n;
                    DDL += "          Master " + boolToString(trait.grand) + n;
                    DDL += "         Default " + trait.defaultValue.ToString() + n;
                    DDL += "         Maximum " + trait.max.ToString() + n;
                    DDL += "         Minimum " + trait.min.ToString() + n;
                    break;

                case ControlType.Indexed:     /////////////////
                    DDL += "           Trait " + trait.name + n;
                    DDL += "            Type " + trait.type.ToString() + n;
                    DDL += "         Channel " + trait.channel.ToString() + n;
                    DDL += "           Black " + boolToString(trait.black) + n;
                    DDL += "         BoValue " + trait.blackValue.ToString() + n;
                    DDL += "         Default " + trait.defaultValue.ToString() + n;
                    for (int i = 0; i < trait.index.Count; i++)
                    {
                        DDL += "           Index " + trait.index[i].name + "," + trait.index[i].value + n;
                    }
                    break;

                case ControlType.Union:     /////////////////
                    DDL += "           Trait " + trait.name + n;
                    DDL += "            Type " + trait.type.ToString() + n;
                    DDL += "         Channel " + trait.channel.ToString() + n;
                    DDL += "           Black " + boolToString(trait.black) + n;
                    DDL += "         BoValue " + trait.blackValue.ToString() + n;
                    DDL += "         Default " + trait.defaultValue.ToString() + n;
                    for (int u = 0; u < trait.union.Count; u++)
                    {
                        Union union = trait.union[u];
                        switch (union.type)
                        {
                        case ControlType.Continuous:
                            DDL += n;
                            DDL += "           Trait " + union.name + n;
                            DDL += "            Type Continuous" + n;
                            DDL += "         Maximum " + union.max.ToString() + n;
                            DDL += "         Minimum " + union.min.ToString() + n;
                            break;

                        case ControlType.Indexed:
                            //create new sub-type header based on previous entry
                            if ((u == 0) || (trait.union[u - 1].type == ControlType.Continuous))
                            {
                                DDL += n;
                                DDL += "           Trait " + trait.name + n;
                                DDL += "            Type Indexed" + n;
                            }
                            DDL += "           Index " + union.name + "," + union.min + n;
                            break;
                        }
                    }
                    DDL += n;
                    DDL += "           Trait " + trait.name + n;
                    DDL += "            Type EndUnion" + n;

                    break;
                } //type switch
                DDL += n + n;
            }     //trait loop

            DDL += "End";

            return(DDL);
        }