111 lines
3.4 KiB
C
111 lines
3.4 KiB
C
/*!
|
|
Copyright 2017 ÀÎ "ÍÈÈÝÒ" è ÎÎÎ "ÍÏÔ ÂÅÊÒÎÐ"
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
you may not use this file except in compliance with the License.
|
|
You may obtain a copy of the License at
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
See the License for the specific language governing permissions and
|
|
limitations under the License.
|
|
|
|
\file SMCmdLogic.h
|
|
\brief Îáðàáîòêà êîìàíä è çàäàíèé, ïîñòóïàþùèõ èç ðàçëè÷íûõ èñòî÷íèêîâ. (ñì. TSM_CmdLogic)
|
|
\author ÎÎÎ "ÍÏÔ Âåêòîð". http://motorcontrol.ru
|
|
\version v 2.0 25/03/2016
|
|
|
|
\defgroup SMCmdLogic Îáðàáîòêà êîìàíä è çàäàíèé, ïîñòóïàþùèõ èç ðàçëè÷íûõ èñòî÷íèêîâ. (ñì. TSM_CmdLogic)
|
|
@{
|
|
*/
|
|
|
|
|
|
#ifndef SM_CmdLogicH
|
|
#define SM_CmdLogicH
|
|
|
|
#include "V_common.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C"
|
|
{
|
|
#endif
|
|
|
|
|
|
//! Ñèñòåìà îñòàíîâëåíà, ãîòîâà ê çàïóñêó (ÃÎÒÎÂ)
|
|
#define CMD_LOGIC_TURNED_OFF 0x0
|
|
//! Ñîñòîÿíèå ÐÀÁÎÒÀ
|
|
#define CMD_LOGIC_TURNED_ON 0x2
|
|
|
|
#if defined (HW_MCB3)
|
|
//Äëÿ óïðàâëåíèÿ êîíòðîëëåðîì ìû èñïîëüçóåì âíåøíèå äèñêðåòíûå âõîäû ñ èñïîëüçîâàíèåì ôèëüòðàöèè (ñì. V_DIO)
|
|
#define STARTBUTTON (BIT_IS_SET(input_vect, 0) ? 1 : 0) //Ïðîâåðêà íà óñòàâêó áèòà â âåêòîðå äèñêðåòíûõ âõîäîâ
|
|
#define STOPBUTTON (BIT_IS_SET(input_vect, 1) ? 1 : 0) //Ïðîâåðêà íà óñòàâêó áèòà â âåêòîðå äèñêðåòíûõ âõîäîâ
|
|
#define RESETBUTTON (BIT_IS_SET(input_vect, 2) ? 1 : 0) //Ïðîâåðêà íà óñòàâêó áèòà â âåêòîðå äèñêðåòíûõ âõîäîâ
|
|
#elif defined (HW_MCB3_SIMULATOR)
|
|
#define STARTBUTTON 0
|
|
#define STOPBUTTON 0
|
|
#define RESETBUTTON 0
|
|
#endif
|
|
|
|
|
|
/*! \class TSM_CmdLogic
|
|
\brief Îáðàáîòêà êîìàíä è çàäàíèé, ïîñòóïàþùèõ èç ðàçëè÷íûõ èñòî÷íèêîâ.
|
|
|
|
Êëàññ \a TSM_CmdLogic, îñíîâàííûé íà ñòðóêòóðå SSMCmdLogic, ñëóæèò äëÿ îáðàáîòêè êîìàíä
|
|
îïåðàòèâíîãî óïðàâëåíèÿ è çàäàíèÿ ñêîðîñòè. Êîìàíäû ìîãóò ïîñòóïàòü êàê ïî CANOpen,
|
|
òàê è ïî äðóãèì ïðîòîêîëàì (ModBus). Ñîäåðæèò äèñêðåòíûé àâòîìàò, êîòîðûé ïåðåêëþ÷àåò
|
|
ñèñòåìó ìåæäó ñîñòîÿíèÿìè ÐÀÁÎÒÀ è ÎÑÒÀÍÎÂ (ÃÎÒÎÂ).
|
|
*/
|
|
|
|
//! ñì. TSM_CmdLogic
|
|
struct SSM_CmdLogic
|
|
{
|
|
int state;//!<Cîñòîÿíèå
|
|
int state_prev;//!<Ïðåäûäóùåå ñîñòîÿíèå
|
|
int E;//!<Ôëàã ïåðâîãî âõîæäåíèÿ
|
|
TCmd cmd_by_level_prev;//!<Ïðåäûäóùåå ñîñòîÿíèå êîìàíäíîãî ñëîâà
|
|
int ReRunCounter;//!< Ñ÷åò÷èê âðåìåíè ñ ìîìåíòà ïðåäûäóùåãî çàïóñêà ñèñòåìû
|
|
int StartButtonPrev;
|
|
int StartButton;
|
|
int StopButtonPrev;
|
|
int StopButton;
|
|
int ResetButton;
|
|
int ResetButtonPrev;
|
|
void (*init)(volatile struct SSM_CmdLogic*);//!< Pointer to the init funcion
|
|
void (*slow_calc)(volatile struct SSM_CmdLogic*);//!< Pointer to the calc funtion
|
|
void (*ms_calc)(volatile struct SSM_CmdLogic*); //!< Pointer to the calc funtion
|
|
};
|
|
|
|
typedef volatile struct SSM_CmdLogic TSM_CmdLogic;
|
|
|
|
//! Èíèöèàëèçàòð ïî óìîë÷àíèþ
|
|
#define SM_CMD_LOGIC_DEFAULTS {0,0,0,{0},0,0,0,0,0,0,0,\
|
|
SM_CmdLogicInit,\
|
|
SM_CmdLogicSlow_Calc,\
|
|
SM_CmdLogicms_Calc}
|
|
|
|
//! \memberof TSM_CmdLogic
|
|
void SM_CmdLogicInit(TSM_CmdLogic*);
|
|
//! \memberof TSM_CmdLogic
|
|
void SM_CmdLogicSlow_Calc(TSM_CmdLogic*);
|
|
//! \memberof TSM_CmdLogic
|
|
void SM_CmdLogicms_Calc(TSM_CmdLogic*);
|
|
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
/*@}*/
|
|
|
|
|
|
|
|
|
|
|