• 电路工作状态


    #include "stdafx.h"
    #include <stdio.h>
    #include <string.h>
    #include <math.h>
    #include<stdlib.h>
    #include <dos.h>
    #include <conio.h>
    
    typedef  enum _Cicurt_State
    { 
        Cicuit_Init_State,
        open_circuit_State,
        short_cicuit_State,
        thoroughfare_State,
    }Cicurt_State;
    
    typedef  struct _Cicurt
    {
        Cicurt_State  cicurt_state;
        int Plain_conductor;
        int electronic_parts;
        int electricals;
    }Cicurt;
    
    typedef enum _Cicurt_Event
    {
        Plain_conductor_open_circuit_Event,
        Plain_conductor_short_cicuit_Event,
        Plain_conductor_thoroughfare_State,
    
        electronic_parts_open_circuit_Event,
        electronic_parts_short_cicuit_Event,
        electronic_parts_thoroughfare_State,
    
        electricals_open_circuit_Event,
        electricals_short_cicuit_Event,
        electricals_thoroughfare_State_Event,
    
    }Cicurt_Event;
    
    typedef  struct _Fsm_Table
    {
        Cicurt_Event cicurt_event;
        void(*Event_Process)(Cicurt_Event cicurt_event, Cicurt_State  cicurt_state);
    }Fsm_Table;
    
    
    static void  Plain_conductor_Event_Process(Cicurt_Event cicurt_event, Cicurt_State  cicurt_state)
    {
        int* Plain_conductor_Cicurt_state = (int*)&cicurt_state;
    
        switch (*Plain_conductor_Cicurt_state)
        {
            case Cicuit_Init_State:
                break;
            case open_circuit_State:
                break;
            case short_cicuit_State:
                break;
            case thoroughfare_State:
                break;
        }
    
    }
    
    
    static void electronic_parts_Event_Process(Cicurt_Event cicurt_event, Cicurt_State  cicurt_state)
    {
        int* electronic_parts_Cicurt_state = (int*)&cicurt_state;
    
        switch (*electronic_parts_Cicurt_state)
        {
            case Cicuit_Init_State:
                break;
            case open_circuit_State:
                break;
            case short_cicuit_State:
                break;
            case thoroughfare_State:
                break;
        }
    
    }
    
    static void electricals_Event_Process(Cicurt_Event cicurt_event, Cicurt_State  cicurt_state)
    {
        int* electricals_state = (int*)&cicurt_state;
    
        switch (*electricals_state)
        {
            case Cicuit_Init_State:
                break;
            case open_circuit_State:
                break;
            case short_cicuit_State:
                break;
            case thoroughfare_State:
                break;
        }
    
    }
    
    
    static Fsm_Table  fsm_Table[] = 
    {
    
        { Plain_conductor_open_circuit_Event,Plain_conductor_Event_Process},
        { Plain_conductor_short_cicuit_Event,Plain_conductor_Event_Process},
        { Plain_conductor_thoroughfare_State,Plain_conductor_Event_Process},
        { electronic_parts_open_circuit_Event,electronic_parts_Event_Process },
        { electronic_parts_short_cicuit_Event,electronic_parts_Event_Process },
        { electronic_parts_thoroughfare_State,electronic_parts_Event_Process },
        { electricals_open_circuit_Event,electricals_Event_Process },
        { electricals_short_cicuit_Event,electricals_Event_Process },
        { electricals_thoroughfare_State_Event,electricals_Event_Process },
    
    };
    
    
    static Cicurt_Event getCicurt_Event(Cicurt_Event  cicurt_Event)
    {
    
    
        return cicurt_Event;
    }
    
    int main()
    {
        Cicurt_State   cicurt_state = Cicuit_Init_State;
        Cicurt_Event   cicurt_Event = electricals_open_circuit_Event;
        cicurt_Event  = getCicurt_Event(cicurt_Event);
    
        for (int i = 0; i < sizeof(fsm_Table) / sizeof(Fsm_Table);i++)
        {
            if (fsm_Table[i].cicurt_event == cicurt_Event)
            {
                fsm_Table[i].Event_Process(cicurt_Event, Cicuit_Init_State);
            }
        }
    
        while (1);
    
        return 0;
    }
    一勤天下无难事。
  • 相关阅读:
    25、Base64
    24、AES RSA加密处理记录
    23、获取app所占据的内存
    22、DDMS(转载)
    21、HierarchyViewer使用记录
    kubernetes 操作 serviceaccounts
    删除dashboard
    数据库建库指定UTF-8和jdbc连接字符串
    apt 被卸载
    EasyReport报表工具部署
  • 原文地址:https://www.cnblogs.com/nowroot/p/12864568.html
Copyright © 2020-2023  润新知