Example #1
0
        /// <summary>
        /// Create Object representations of Cues, CueItems, and Motors from the associated database
        /// and store the Cues into CueList
        /// </summary>
        public void InitObjects()
        {
            try
            {
                data.Connect();

                DataTable CueTable = data.GetCues();
                foreach (DataRow CueRow in CueTable.Rows)
                {
                    Cue       NewCue       = new Cue(CueRow["Name"].ToString(), CueRow["Description"].ToString());
                    DataTable CueItemTable = data.GetAllFromCueMotor(NewCue.Name);
                    foreach (DataRow CueItemRow in CueItemTable.Rows)
                    {
                        Motor CueMotor = new Motor(CueItemRow["IPAddress"].ToString(),
                                                   CueItemRow["MotorName"].ToString(),
                                                   CueItemRow["Description"].ToString(),
                                                   (int)CueItemRow["LimitMaxVelocity"],
                                                   (int)CueItemRow["LimitMaxAcceleration"],
                                                   (int)CueItemRow["LimitMaxDeceleration"],
                                                   (int)CueItemRow["LimitMaxNegPosition"],
                                                   (int)CueItemRow["LimitMaxPosPosition"]);

                        CueItem Item = new CueItem(Double.Parse(CueItemRow["DelayBefore"].ToString()),
                                                   Double.Parse(CueItemRow["RunTime"].ToString()),
                                                   CueMotor,
                                                   (int)CueItemRow["SetVelocity"],
                                                   (int)CueItemRow["SetAcceleration"],
                                                   (int)CueItemRow["SetDeceleration"],
                                                   Convert.ToBoolean(CueItemRow["CounterClockwise"]),
                                                   (int)CueItemRow["SetPosition"]);

                        NewCue.Add(Item);
                        Console.WriteLine("Added Item");
                    }
                    CueList.Add(NewCue);
                }
                data.Disconnect();
                foreach (Cue c in CueList)
                {
                    Console.WriteLine(c.Name);
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }
        }