Beispiel #1
0
    public ModuleState CheckModuleState(float currentState, ModuleState stateCurrent)
    {
        ModuleState state = stateCurrent;

        if (currentState >= 1.0f)
        {
            state = ModuleState.FULL;
        }
        if (currentState < 1.0f && currentState >= 0.75f)
        {
            state = ModuleState.PARTIALFULL;
        }
        if (currentState >= 0.5f && currentState < 0.75f)
        {
            state = ModuleState.HALF;
        }
        if (currentState > 0f && currentState < 0.5f)
        {
            state = ModuleState.DEFICIENT;
        }
        if (currentState <= 0f)
        {
            state = ModuleState.NONE;
        }
        return(state);
    }
Beispiel #2
0
 public Perception(WorldModel model)
 {
     WM                = model;
     internalState     = ModuleState.Inactive;
     EstimatorStrategy = new SimpleEstimationStrategy(model);
     mLogger           = Logger.Logger.Instance;
 }
Beispiel #3
0
        /// <summary>
        /// Initializes the factories by passing the file source down, which is necessary for data (web/file) calls
        /// </summary>
        /// <param name="fileSource"></param>
        public virtual void Initialize(IMapReadable map, IFileSource fileSource)
        {
            _map          = map;
            _tileProgress = new Dictionary <UnwrappedTileId, int>();

            // Allow for map re-use by recycling any active tiles.
            var activeTiles = _activeTiles.Keys.ToList();

            foreach (var tile in activeTiles)
            {
                DisposeTile(tile);
            }

            State = ModuleState.Initialized;

            foreach (var factory in factories)
            {
                if (null == factory)
                {
                    Debug.LogError("AbstractMapVisualizer: Factory is NULL");
                }
                else
                {
                    factory.Initialize(fileSource);
                    UnregisterEvents(factory);
                    RegisterEvents(factory);
                }
            }
        }
Beispiel #4
0
    /// <param name="po_sConfirmOpinionList">控件名1,控件名2,控件名3,</param>
    /// <param name="pm_sInputType">Text,TextArea,TextAreaEsay,TextNum</param>
    protected ModuleState[] OpinionControlInit(string pm_sOpinionTitle, string pm_sOpinionType, string pm_sModuleName,
                                               WorkFlowFormOpinion pm_wfoOpinion, string pm_sUserCode, object pm_oInputType)
    {
        int ud_iOpinionStateCount = 2;

        ModuleState[] ud_wfmaWorkFlowModuleState = new ModuleState[ud_iOpinionStateCount];

        for (int i = 0; i < ud_iOpinionStateCount; i++)
        {
            ud_wfmaWorkFlowModuleState[i] = this.up_wftToolbar.GetModuleState(pm_sModuleName, i);
        }

        if (ud_wfmaWorkFlowModuleState[1] == ModuleState.Operable)
        {
            this.ConfirmOpinionList += pm_wfoOpinion.UniqueID + ",";
        }

        switch (pm_oInputType.ToString().ToLower())
        {
        case "text":
            pm_wfoOpinion.ControlType = "Text";
            break;

        case "textarea":
            pm_wfoOpinion.ControlType = "TextArea";
            break;

        case "textareaesay":
            pm_wfoOpinion.ControlType = "TextAreaEsay";
            break;

        case "textnum":
            pm_wfoOpinion.ControlType = "TextNum";
            break;

        default:
            break;
        }
        pm_wfoOpinion.Title           = pm_sOpinionTitle;
        pm_wfoOpinion.OpinionType     = pm_sOpinionType;
        pm_wfoOpinion.ApplicationCode = this.up_wftToolbar.ApplicationCode;
        pm_wfoOpinion.CaseCode        = this.up_wftToolbar.CaseCode;
        pm_wfoOpinion.State           = ud_wfmaWorkFlowModuleState[0];
        pm_wfoOpinion.StateConfirm    = ud_wfmaWorkFlowModuleState[1];
        pm_wfoOpinion.ProjectCode     = this.up_wftToolbar.ProjectCode;

        if (pm_sUserCode.Trim() != "")
        {
            pm_wfoOpinion.OpinionUserCode = pm_sUserCode;
        }

        pm_wfoOpinion.InitControl();

        if (ud_wfmaWorkFlowModuleState[1] == ModuleState.Operable)
        {
            this.up_wftToolbar.IsAudit = true;
        }

        return(ud_wfmaWorkFlowModuleState);
    }
Beispiel #5
0
 void MapVisualizer_OnStateChanged(ModuleState moduleState)
 {
     if (moduleState == ModuleState.Finished)
     {
         OnTileLoaded();
     }
 }
        public ModuleState Start()
        {
            // clear all old commands
            commandsQueue.Clear();
            commandsQueue.InitPosition(new double[2] {
                -1000, 0
            });
            if (bounderyConditions == null)
            {
                bounderyConditions = new PointParams();
            }
            else
            {
                bounderyConditions.Clear();
            }

            if (internalState == ModuleState.Inactive)
            {
                Guidance      = new Thread(new ThreadStart(motionGuidanceStrategy.MotionGuidance));
                internalState = ModuleState.Active;
                motionGuidanceStrategy.Activate();
                Guidance.Start();
            }
            return(internalState);
        }
Beispiel #7
0
 private void LoadModules()
 {
     System.Collections.Specialized.StringCollection modsettings = Properties.Settings.Default.Modules;
     if (modsettings != null && modsettings.Count > 0)
     {
         foreach (String mod in modsettings)
         {
             String[] modparts = mod.Split('|');
             if (modparts != null && modparts.Length >= 3 && modparts.Length <= 4)
             {
                 ListViewItem lvw = new ListViewItem();
                 lvw.Text = modparts[0];
                 for (int idx = 1; idx < modparts.Length; idx++)
                 {
                     lvw.SubItems.Add(modparts[idx]);
                 }
                 if (modparts.Length == 3)
                 {
                     lvw.SubItems.Add("");
                 }
                 ModuleState mstate = GetModuleState(modparts);
                 lvw.ImageIndex = (int)mstate;
                 lvwModules.Items.Add(lvw);
                 if (mstate != ModuleState.Okay)
                 {
                     tcSettings.SelectedTab = tbpModules;
                 }
             }
         }
     }
 }
Beispiel #8
0
        public void ClearMap()
        {
            UnregisterAllTiles();
            if (factories != null)
            {
                foreach (var tileFactory in factories)
                {
                    if (tileFactory == null)
                    {
                        continue;
                    }
                    tileFactory.Clear();
                    DestroyImmediate(tileFactory);
                }
            }
            foreach (var tileId in _activeTiles.Keys.ToList())
            {
                _activeTiles[tileId].ClearAssets();
                DisposeTile(tileId);
            }

            foreach (var tile in _inactiveTiles)
            {
                tile.ClearAssets();
                DestroyImmediate(tile.gameObject);
            }

            _inactiveTiles.Clear();
            State = ModuleState.Initialized;
        }
Beispiel #9
0
        public void UdpSend(byte[] buf, int len = -1)
        {
            if (len <= -1)
            {
                len = buf.Length;
            }
            Socket nSocket = mUdpSocket;

            try
            {
                nSocket.Send(buf, len, SocketFlags.None);
                mMessageCounter.SendPacketCount(len);
            }
            catch (Exception e)
            {
                Debug.LogError(string.Format("Kcp Socket send exception : {0}", e.Message));
                nSocket.Close();
                lock (mSocketLock)
                {
                    if (mState != ModuleState.CLOSE)
                    {
                        downTriggerFlag = true;
                        mState          = ModuleState.CLOSE;
                    }
                }
            }
        }
Beispiel #10
0
    protected ModuleState ImageSignControlInit(string pm_sOpinionType, string pm_sModuleName,
                                               WorkFlowFormOpinion pm_wfsImageSign, string pm_sUserCode)
    {
        int ud_iOpinionStateCount = 2;

        ModuleState[] ud_wfmaWorkFlowModuleState = new ModuleState[ud_iOpinionStateCount];

        for (int i = 0; i < ud_iOpinionStateCount; i++)
        {
            ud_wfmaWorkFlowModuleState[i] = this.up_wftToolbar.GetModuleState(pm_sModuleName, i);
        }



        pm_wfsImageSign.OpinionType     = pm_sOpinionType;
        pm_wfsImageSign.ApplicationCode = this.up_wftToolbar.ApplicationCode;
        pm_wfsImageSign.CaseCode        = this.up_wftToolbar.CaseCode;
        pm_wfsImageSign.State           = ud_wfmaWorkFlowModuleState[0];

        if (pm_sUserCode.Trim() != "")
        {
            pm_wfsImageSign.OpinionUserCode = pm_sUserCode;
        }

        pm_wfsImageSign.InitControl();

        return(ud_wfmaWorkFlowModuleState[0]);
    }
Beispiel #11
0
        public async Task <bool> IsEnabled(ICacheClient cache, ulong id)
        {
            if (await cache.ExistsAsync(GetCacheKey(id)))
            {
                return(await cache.GetAsync <bool>(GetCacheKey(id)));
            }
            else
            {
                ModuleState state = null;

                using (var context = new IAContext())
                {
                    long guildId = id.ToDbLong();
                    state = await context.ModuleStates.FindAsync(SqlName, guildId);
                }

                if (state == null)
                {
                    await cache.UpsertAsync(GetCacheKey(id), Enabled);

                    return(Enabled);
                }

                await cache.UpsertAsync(GetCacheKey(id), state.State);

                return(state.State);
            }
        }
Beispiel #12
0
        /// <summary>
        /// Initializes the factories by passing the file source down, which's necessary for data (web/file) calls
        /// </summary>
        /// <param name="fileSource"></param>
        public void Initialize(IMap map, IFileSource fileSource)
        {
            _map           = map;
            _activeTiles   = new Dictionary <UnwrappedTileId, UnityTile>();
            _inactiveTiles = new Queue <UnityTile>();
            State          = ModuleState.Initialized;

            foreach (var factory in _factories)
            {
                factory.Initialize(fileSource);
                factory.OnFactoryStateChanged += UpdateState;
            }

            MapEvents.OnMapEvent += (string eventName) => {
                if (eventName == "CLEARDATA")
                {
                    foreach (var unityTile in _activeTiles.Values)
                    {
                        int childCount = unityTile.transform.childCount;
                        for (int i = 0; i < childCount; i++)
                        {
                            Destroy(unityTile.transform.GetChild(i).gameObject);
                        }
                    }
                }
                if (eventName == "BUILDDATA")
                {
                    foreach (var unityTile in _activeTiles.Values)
                    {
                        LoadTileData(unityTile);
                    }
                }
            };
        }
Beispiel #13
0
 public OpenLoopMotionGuidanceStrategy(TrajectoryQueue queue, Communicator.Communicator com, int timeCycle)
 {
     communicator  = com;
     commandsQueue = queue;
     Ts            = TimeSpan.FromMilliseconds(timeCycle);
     internalState = ModuleState.Inactive;
 }
Beispiel #14
0
    /// ****************************************************************************
    /// <summary>
    /// 业务审核
    /// </summary>
    /// ****************************************************************************
    virtual protected Boolean Audit(StandardEntityDAO dao)
    {
        /**************************判断当前辅助控制项所对应的辅助控制是否有同意/否决 ******************************/
        string opinionType           = RmsPM.BLL.WorkFlowRule.GetTaskOpinionTypeByActCode(this.up_wftToolbar.ActCode);
        int    ud_iOpinionStateCount = 2;
        string ud_sOpinionConfirm    = "";

        ModuleState[] ud_wfmaWorkFlowModuleState = new ModuleState[ud_iOpinionStateCount];

        for (int i = 0; i < ud_iOpinionStateCount; i++)
        {
            ud_wfmaWorkFlowModuleState[i] = this.up_wftToolbar.GetModuleState(opinionType, i);
        }

        if (ud_wfmaWorkFlowModuleState[1] == ModuleState.Operable)  //当前如果有同意/否决选项 则做验证
        {
            ud_sOpinionConfirm = this.up_wftToolbar.AuditValue;
            if (ud_sOpinionConfirm == "")
            {
                ud_sOpinionConfirm = "Unknow";
            }
        }
        else
        {
            ud_sOpinionConfirm = this.up_wftToolbar.AuditValue;
        }
        /******************************************************************/
        //string ud_sOpinionConfirm = GetOpinionConfirm();


        return(this.up_ucOperationControl.Audit(ud_sOpinionConfirm));
    }
Beispiel #15
0
        uint[] GetNonLoadedTokens(ModuleState state)
        {
            var hash = new HashSet <uint>(state.ModifiedTypes);

            if (state.LoadClassHash != null)
            {
                foreach (var a in state.LoadClassHash)
                {
                    hash.Add(a);
                }
            }
            var tokens = hash.ToList();

            tokens.Sort();
            var res = new List <uint>(tokens.Count);

            foreach (uint token in tokens)
            {
                bool loaded = state.LoadClassHash != null && state.LoadClassHash.Contains(token);
                if (loaded)
                {
                    continue;                       // It has already been initialized
                }
                res.Add(token);
            }
            return(res.ToArray());
        }
Beispiel #16
0
 public void LoadImgSign(ModuleState moduleState, string ActUserCode, DataRow dr)
 {
     if (moduleState == ModuleState.Operable && (ActUserCode == null || ActUserCode == ""))
     {
         dr["ActUserCode"] = ((User)Session["User"]).UserCode;
     }
 }
Beispiel #17
0
 public void SetModuleState(ModuleState state)
 {
     foreach (var context in _modulesInfos)
     {
         context.SetState(state);
     }
 }
Beispiel #18
0
 public Module(string name, string fullpath, ModuleState modstate, Module parent = null)
 {
     Name        = name;
     FilePath    = fullpath;
     ModuleState = modstate;
     Parent      = parent;
 }
 public void SendCommand(House house, int moduleNumber, ModuleState state)
 {
     byte[] a1on = GetBytesForModule(house, moduleNumber, state);
     SendHeader();
     SendByte(a1on[0]);
     SendByte(a1on[1]);
     SendFooter();
 }
Beispiel #20
0
        public async Task <ModuleSet> GetModulesAsync(CancellationToken token)
        {
            IEnumerable <ModuleRuntimeInfo> moduleStatuses = await this.moduleStatusProvider.GetModules(token);

            var       modules   = new List <IModule>();
            ModuleSet moduleSet = this.deploymentConfig.GetModuleSet();

            foreach (ModuleRuntimeInfo moduleRuntimeInfo in moduleStatuses)
            {
                if (moduleRuntimeInfo.Type != "docker" || !(moduleRuntimeInfo is ModuleRuntimeInfo <DockerReportedConfig> dockerRuntimeInfo))
                {
                    Events.InvalidModuleType(moduleRuntimeInfo);
                    continue;
                }

                if (!moduleSet.Modules.TryGetValue(dockerRuntimeInfo.Name, out IModule configModule) || !(configModule is DockerModule dockerModule))
                {
                    dockerModule = new DockerModule(dockerRuntimeInfo.Name, string.Empty, ModuleStatus.Unknown, RestartPolicy.Unknown, new DockerConfig(string.Empty), new ConfigurationInfo(), null);
                }

                Option <ModuleState> moduleStateOption = await this.moduleStateStore.Get(moduleRuntimeInfo.Name);

                ModuleState moduleState = moduleStateOption.GetOrElse(new ModuleState(0, moduleRuntimeInfo.ExitTime.GetOrElse(DateTime.MinValue)));
                // compute module state based on restart policy
                DateTime     lastExitTime        = moduleRuntimeInfo.ExitTime.GetOrElse(DateTime.MinValue);
                ModuleStatus moduleRuntimeStatus = this.restartManager.ComputeModuleStatusFromRestartPolicy(moduleRuntimeInfo.ModuleStatus, dockerModule.RestartPolicy, moduleState.RestartCount, lastExitTime);
                string       image = !string.IsNullOrWhiteSpace(dockerRuntimeInfo.Config.Image) ? dockerRuntimeInfo.Config.Image : dockerModule.Config.Image;
                var          dockerReportedConfig = new DockerReportedConfig(image, dockerModule.Config.CreateOptions, dockerRuntimeInfo.Config.ImageHash);
                IModule      module;
                switch (moduleRuntimeInfo.Name)
                {
                case Core.Constants.EdgeHubModuleName:
                    module = new EdgeHubDockerRuntimeModule(
                        dockerModule.DesiredStatus, dockerModule.RestartPolicy, dockerReportedConfig,
                        (int)dockerRuntimeInfo.ExitCode, dockerRuntimeInfo.Description, dockerRuntimeInfo.StartTime.GetOrElse(DateTime.MinValue),
                        lastExitTime, moduleState.RestartCount, moduleState.LastRestartTimeUtc,
                        moduleRuntimeStatus, dockerModule.ConfigurationInfo, dockerModule.Env);
                    break;

                case Core.Constants.EdgeAgentModuleName:
                    module = new EdgeAgentDockerRuntimeModule(dockerReportedConfig, moduleRuntimeStatus,
                                                              (int)dockerRuntimeInfo.ExitCode, dockerRuntimeInfo.Description, dockerRuntimeInfo.StartTime.GetOrElse(DateTime.MinValue),
                                                              lastExitTime, dockerModule.ConfigurationInfo, dockerModule.Env);
                    break;

                default:
                    module = new DockerRuntimeModule(
                        moduleRuntimeInfo.Name, dockerModule.Version, dockerModule.DesiredStatus, dockerModule.RestartPolicy, dockerReportedConfig,
                        (int)moduleRuntimeInfo.ExitCode, moduleRuntimeInfo.Description, moduleRuntimeInfo.StartTime.GetOrElse(DateTime.MinValue), lastExitTime,
                        moduleState.RestartCount, moduleState.LastRestartTimeUtc,
                        moduleRuntimeStatus, dockerModule.ConfigurationInfo, dockerModule.Env);
                    break;
                }

                modules.Add(module);
            }
            return(new ModuleSet(modules.ToDictionary(m => m.Name, m => m)));
        }
 public ModuleState Stop()
 {
     if (internalState == ModuleState.Active)
     {
         OpponentModelingThread.Abort();
     }
     internalState = ModuleState.Inactive;
     return(internalState);
 }
Beispiel #22
0
        /// <param name="po_sConfirmOpinionList">控件名1,控件名2,控件名3,</param>
        /// <param name="pm_sInputType">Text,TextArea,TextAreaEsay,TextNum</param>
        protected WorkFlowControl.ModuleState[] OpinionControlInit(string pm_sOpinionTitle, string pm_sOpinionType, string pm_sModuleName,
                                                                   WorkFlowFormOpinion pm_wfoOpinion, string pm_sUserCode, string pm_sConfirmOpinionList, out string po_sConfirmOpinionList, string pm_sInputType)
        {
            int ud_iOpinionStateCount = 2;

            WorkFlowControl.ModuleState[] ud_wfmaWorkFlowModuleState = new ModuleState[ud_iOpinionStateCount];

            for (int i = 0; i < ud_iOpinionStateCount; i++)
            {
                ud_wfmaWorkFlowModuleState[i] = this.WorkFlowToolbar1.GetModuleState(pm_sModuleName, i);
            }

            if (ud_wfmaWorkFlowModuleState[1] == ModuleState.Operable)
            {
                pm_sConfirmOpinionList += pm_wfoOpinion.UniqueID + ",";
            }

            po_sConfirmOpinionList = pm_sConfirmOpinionList;

            switch (pm_sInputType.ToLower())
            {
            case "text":
                pm_wfoOpinion.ControlType = "Text";
                break;

            case "textarea":
                pm_wfoOpinion.ControlType = "TextArea";
                break;

            case "textareaesay":
                pm_wfoOpinion.ControlType = "TextAreaEsay";
                break;

            case "textnum":
                pm_wfoOpinion.ControlType = "TextNum";
                break;

            default:
                break;
            }
            pm_wfoOpinion.Title           = pm_sOpinionTitle;
            pm_wfoOpinion.OpinionType     = pm_sOpinionType;
            pm_wfoOpinion.ApplicationCode = this.WorkFlowToolbar1.ApplicationCode;
            pm_wfoOpinion.CaseCode        = this.WorkFlowToolbar1.CaseCode;
            pm_wfoOpinion.State           = ud_wfmaWorkFlowModuleState[0];
            pm_wfoOpinion.StateConfirm    = ud_wfmaWorkFlowModuleState[1];

            if (pm_sUserCode.Trim() != "")
            {
                pm_wfoOpinion.OpinionUserCode = pm_sUserCode;
            }

            pm_wfoOpinion.InitControl();

            return(ud_wfmaWorkFlowModuleState);
        }
 public ModuleState Start()
 {
     if (internalState == ModuleState.Inactive)
     {
         OpponentModelingThread = new Thread(() => OpponentModelingStrategy.ModelOpponent(this));
         OpponentModelingThread.Start();
         internalState = ModuleState.Active;
     }
     return(internalState);
 }
Beispiel #24
0
 public static void Main(ModuleState state)
 {
     Application.EnableVisualStyles();
     if (form != null)
     {
         form.Dispose();
     }
     form = new frmMain(state);
     form.ShowDialog();
 }
Beispiel #25
0
 public Module()
 {
     Node = new InputNode(this, "Schema", "DataLocation");
     Node.OnDisconnect += delegate
     {
         State = null;
     };
     AddInputNode(Node);
     DisplayName = "Designer";
 }
Beispiel #26
0
 public ModuleState Stop()
 {
     if (internalState == ModuleState.Active)
     {
         internalState = ModuleState.Inactive;
         PlanningScheduler.Deactivate();
         Scheduler.Abort();
     }
     return(internalState);
 }
Beispiel #27
0
        /*******************
         **** kcp funcs ****
         ******************/

        public void StartUdpSocket()
        {
            lock (mSocketLock)
            {
                mState       = ModuleState.NORMAL;
                mUdpSocket   = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
                mSvrEndPoint = new IPEndPoint(IPAddress.Parse(mIP), mPort);
                mUdpSocket.Connect(mSvrEndPoint);
            }
        }
Beispiel #28
0
        public void TestCreateValidation()
        {
            IEntityStore <string, ModuleState> store = new Mock <IEntityStore <string, ModuleState> >().Object;
            var state = new ModuleState(0, DateTime.UtcNow);

            Assert.Throws <ArgumentException>(() => new AddToStoreCommand <ModuleState>(store, null, state));
            Assert.Throws <ArgumentNullException>(() => new AddToStoreCommand <ModuleState>(null, "foo", state));
            Assert.Throws <ArgumentNullException>(() => new AddToStoreCommand <ModuleState>(store, "foo", null));
            Assert.NotNull(new AddToStoreCommand <ModuleState>(store, "foo", state));
        }
 public ModuleState Stop()
 {
     if (internalState == ModuleState.Active)
     {
         internalState = ModuleState.Inactive;
         motionGuidanceStrategy.Deactivate();
         Guidance.Abort();
     }
     return(internalState);
 }
Beispiel #30
0
        void OnModuleEditionCompleted(ModuleState moduleState)
        {
            if (this.OnModuleModificationCompleted != null)
            {
                this.OnModuleModificationCompleted(this.moduleSelected, moduleState);
            }

            this.modulesToggleGroupState.Select(false);

            this.currentState = this.modulesToggleGroupState;
        }
Beispiel #31
0
        /// <summary>
        /// Gets all properties decorated with the <see cref="SaveStateAttribute"/> and saves their values in the <see cref="ModuleState.Data"/> property of the specified <paramref name="state"/>.
        /// </summary>
        /// <param name="obj">The object to get the state properties from.</param>
        /// <param name="state">The state to save the values to.</param>
        public static void GetStateProperties(this object obj, ModuleState state)
        {
            var properties = obj.GetStateProperties();

            foreach (var property in properties)
            {
                var value = property.Key.GetValue(obj) ?? property.Value.DefaultValue;

                state.Data[property.Key.Name] = value;
            }
        }
Beispiel #32
0
        public void Dispose()
        {
            ModuleState myState = null;
            lock (gate)
            {
                if (--refCount == 0)
                {
                    myState = state;
                    state = null;
                }
            }

            if (myState != null && myState.Container != null)
            {
                    myState.Container.Dispose();
            }
        }
Beispiel #33
0
        public void Init(HttpApplication context)
        {
            if (Configuration.On == false) return; //Do nothing if Glimpse is off, events are not wired up

            lock (gate)
            {
                if (state == null)
                {
                    state = new ModuleState(context);
                }
                ++refCount;
            }

            context.BeginRequest += BeginRequest;
            context.EndRequest += EndRequest;
            context.PostRequestHandlerExecute += PostRequestHandlerExecute;
            context.PreSendRequestHeaders += PreSendRequestHeaders;
        }
Beispiel #34
0
    public virtual void SwitchToState(ModuleState s)
    {
        this.state = s;
        this._switching = true;

        switch (this.state)
        {
            case ModuleState.IDLE:
                this.SwitchToIdle();
                break;
            case ModuleState.START:
                this.SwitchToStart();
                break;
            case ModuleState.RUN:
                this.SwitchToRun();
                break;
            case ModuleState.END:
                this.SwitchToEnd();
                break;
        }
    }
        private static byte[] GetBytesForModule(House house, int moduleNumber, ModuleState state)
        {
            byte[] ret = new byte[2];
            ret[0] = (byte)house;
            ret[1] = 0x0;

            //if module is 9-16, update household byte
            if (moduleNumber > 9)
                ret[0] = (byte)(ret[0] | 0x04);

            if (moduleNumber == 1 || moduleNumber == 9)
                //1/9   0000 0000 0x00
                ret[1] = 0x00;
            else if (moduleNumber == 2 || moduleNumber == 10)
                //2/10  0001 0000 0x10
                ret[1] = 0x10;
            else if (moduleNumber == 3 || moduleNumber == 11)
                //3/11  0000 1000 0x08
                ret[1] = 0x08;
            else if (moduleNumber == 4 || moduleNumber == 12)
                //4/12  0001 1000 0x18
                ret[1] = 0x18;
            else if (moduleNumber == 5 || moduleNumber == 13)
                //5/13  0100 0000 0x40
                ret[1] = 0x40;
            else if (moduleNumber == 6 || moduleNumber == 14)
                //6/14  0101 0000 0x50
                ret[1] = 0x50;
            else if (moduleNumber == 7 || moduleNumber == 15)
                //7/15  0100 1000 0x48
                ret[1] = 0x48;
            else
                //8/16  0101 1000 0x58
                ret[1] = 0x58;

            //apply on/off state
            ret[1] = (byte)(ret[1] | (byte)state);

            return ret; //"or" the bytes together to get the on or off
        }
Beispiel #36
0
 /// ------------------------------------------------------------------------------------
 /// <summary>Initializes a new instance of the <see cref="ModuleDescriptor"/> class.</summary>
 /// <param name="name">The name.</param>
 /// <param name="state">The state.</param>
 public ModuleDescriptor(string name, ModuleState state)
    : base(name) {
    this.State = state;
 }