/// <summary>
 /// Execute the action.
 /// </summary>
 /// <param name="element">Parameter to remove!</param>
 /// <param name="project">Project where the action must be executed.</param>
 /// <param name="system">System used to execute the digital commands.</param>
 public override void Execute(ElementBase element, Project project, Rwm.Otc.Systems.IDigitalSystem system)
 {
     try
     {
         if (project.Elements.ContainsKey(this.ElementID))
         {
             IAccessory accElement = project.Elements[this.ElementID] as IAccessory;
             if (accElement != null)
             {
                 accElement.SetAccessoryStatus(this.Status, true);
             }
         }
         else
         {
             Logger.LogWarning(this,
                               "Cannot execute SetAccessoryStatusAction #{0}: element #{1} not found in project",
                               this.ID, this.ElementID);
         }
     }
     catch (Exception ex)
     {
         Logger.LogError(this, ex);
         throw;
     }
 }
예제 #2
0
        /// <summary>
        /// Check if a element is controlled as an accessory.
        /// </summary>
        /// <param name="element">Element to check.</param>
        /// <returns><c>true</c> if the element can be controlled as an accesory or <c>false</c> in all other cases.</returns>
        public static int GetAccessoryStatus(ElementBase element)
        {
            IAccessory accElement = element as IAccessory;

            if (accElement != null)
            {
                return(accElement.GetAccessoryStatus());
            }

            return(ElementBase.STATUS_UNDEFINED);
        }
예제 #3
0
        /// <summary>
        /// Returns a new instance of <see cref="RouteElement"/>.
        /// </summary>
        /// <param name="element">Element that contains the information to initialize the route element.</param>
        public RouteElement(ElementBase element)
        {
            Initialize();

            this.ElementID = element.ID;

            IAccessory accElement = element as IAccessory;

            if (accElement != null)
            {
                this.AccessoryStatus = accElement.GetAccessoryStatus();
            }
        }
        /// <summary>
        /// Update the specified connection.
        /// </summary>
        /// <param name="connectionId">Connection unique identifier (DB).</param>
        /// <param name="connectionIndex">Index of the connection in the control.</param>
        /// <param name="element">Element unique identifier (DB).</param>
        public void Assign(int connectionId, int connectionIndex, IAccessory element)
        {
            string sql = string.Empty;

            Logger.LogDebug(this, "[CLASS].Assign({0}, {1}, {2})", connectionId, connectionIndex, element.ID);

            try
            {
                Connect();

                sql = @"UPDATE 
                        " + ControlModuleConnectionManager.SQL_TABLE + @" 
                    SET 
                        blockid = @blockid, 
                        [index] = @index, 
                        out1    = @out1
                    WHERE 
                        id = @id";

                SetParameter("blockid", element.ID);
                SetParameter("index", connectionIndex);
                SetParameter("out1", element.GetDefaultConnectionMap(connectionIndex).Map);
                SetParameter("id", connectionId);

                ExecuteNonQuery(sql);
            }
            catch (Exception ex)
            {
                Logger.LogError(this, ex);

                throw;
            }
            finally
            {
                Disconnect();
            }
        }
예제 #5
0
파일: Box.cs 프로젝트: WhiteShadow13/KitBox
 public void RemoveAccessory(IAccessory c)
 {
     m_Accessories.Remove(c);
 }
예제 #6
0
파일: Box.cs 프로젝트: WhiteShadow13/KitBox
 public void AddAccessory(IAccessory c)
 {
     m_Accessories.Add(c);
 }
예제 #7
0
 /// <summary>
 /// Update the specified connection.
 /// </summary>
 /// <param name="connection">Device connection.</param>
 /// <param name="connectionIndex">Index of the connection in the control.</param>
 /// <param name="element">Element unique identifier (DB).</param>
 public void AssignDeviceConnection(DeviceConnection connection, int connectionIndex, IAccessory element)
 {
     OTCProject.LayoutManager.DeviceConnectionDAO.Assign(connection.ID, connectionIndex, element);
 }