📄 fdj_hb_p103.c.bak
字号:
//++++++++++++++++++++++++++++++++++++++++++++++++++++
// 发电机后备保护通信程序
// 创建日期:2004年12月13日
// 修改日期:2005年08月29日
//++++++++++++++++++++++++++++++++++++++++++++++++++++
#include "define.h"
#include "P103_mmi2dsp.h"
#define DELAYACK 200 //通信间隔计时器
#define DELAYACK1 200 //通信间隔计时器
#define RECALLCOUNT 600 //重复发送计数器
#define COMMANDDELAY 1500
#define FUNTYPE 0x01
#define Setting_Total 55
#define Sys_Cfg_Total 50
#define YC_Total 20
#define CHANNEL_NUM 10
extern struct comm_buf_fm PortA;
extern struct comm_buf_fm Comm0;
extern unsigned int YC_Value[YC_NUM]; /*数组存所有YC数据*/
extern struct System_Info_fm System_Info; //实时信息
extern unsigned int System_config[CONFIG_NUM]; //系统配置
extern unsigned int System_setting[SETTING_NUM]; //定值
extern struct Time_buf realtime; //实时时钟
extern struct Time_buf realtime1; //实时时钟
extern unsigned char TargetArea; //目标区(用于复制定值)
extern unsigned char SourceArea; //原始区(用于复制定值)
extern struct SOE_Buf_Show_fm SOE_Buf_Show0; //存放SOE的缓冲区
extern struct Report_Buf_Show_fm Report_Buf_Show0;
extern struct SoftInformation_fm SoftInformation;
extern struct Setting_Copy_fm Setting_Copy;
extern struct Setting_Switch_fm Setting_Switch;
extern struct Output_Test_YK_fm Output_Test_YK;
extern struct Channel_Ration_Flag_fm Channel_Ration_Flag;
extern struct YYB_Modify_Flag_fm YYB_Modify_Flag;
extern struct Fault_Recode_Flag_fm Fault_Recode_Flag; //召唤故障报告/SOE缓冲区
extern struct Harmonic_Value_fm Harmonic_Value;
extern unsigned char New_Information_Flag,PC_Comm_Flag;
struct comm_buf_flag_fm
{
UC RecvBuf[270]; //接收缓冲区
UI ReceivePoint; //接收到的字节计数器
UC synchro; //同步标志
UC Type; //固定帧还是可变帧
UC FrameRecv; //收到完整的数据帧,固定帧0x15;可变帧0x1a
UC DeviceAddr; //DSP插件地址
US Timing; //发送时间间隔计数器
UC Sendbuf[270]; //发送缓冲区
US SendSeq; //发送次序
UC Length; //发送长度计数
UC Counter; //重复发送计数器
UC CommError; //装置通信故障标志,0x22复位CU 0x11复位FCB
UC Flag_CallAll; //总召唤标志
UI Timer_CallAll; //总召唤计时
UC Flag_CheckTime; //对时标志
UC Modify_Time_Flag; //修改时间标志
UI Timer_CheckTime; //定时对时计时器
UC Init_System_Flag; //上电初始化标志
UC Asdu10_10;
UC Asdu10_12;
UC Asdu10_13;
UC TempBuf[260]; //发送临时缓冲区
UC FCB;
UC FCV;
UC FUN; //哪种类型的保护
UC ACD;
//---------YK------------
UC YkCommand; //遥控命令
UC YkDataNo1; //遥控点号1
UC YkDataNo2; //遥控点号2
UC YkSelect; //选择标志
UC YkError; //遥控出错
//---------Setting-------
UC DzCommand; //定值操作,
UC DzAreaNo; //定值区号
UC DzDataNum; //定值个数
UC DzSwitchSele; //定值切换选择标志
UC DzCopySele; //定值复制选择标志
UC DzData[256];
UC DzSelect; //定值选择标志
UC DzError; //远方修改定值出错
UC FunctionCode; //功能码
UC LPDU_Command;
UC ASDU_Length;
struct comm_buf_fm *com_103;
};
struct comm_buf_flag_fm *comm_buf_flag;
struct comm_buf_flag_fm ComDsp_buf_flag;
struct Order_Array_fm
{
unsigned char Set;
unsigned char Get;
unsigned short Order[10];
};
struct Order_Array_fm Order_Array;
struct command_statue_fm
{
int Check_Time_Flag; //修改时间
int Check_Time_Count;
int Config_Operation_Flag; //系统参数操作标志
int Config_Operation_Count;
int Setting_Operation_Flag; //定值操作标志
int Setting_Operation_Count;
int Channel_Ration_Flag; //通道系数操作标志
int Channel_Ration_Count;
int YYB_Opreation_Flag; //软压板操作
int YYB_Opreation_Count;
int Password_Modified_Flag; //修改密码
int Password_Modified_Count;
int YK_Output_Command_Flag; //遥控/开出传动选择
int YK_Output_Command_Count;
int Demand_Soe_Report_Flag; //查询SOE及故障报告
int Demand_Soe_Report_Count;
int Device_FUGUI_Flag; //装置复归
int Device_FUGUI_Count;
};
struct command_statue_fm command_statue;
//---------------------------------------------
// 以下为函数声明
//---------------------------------------------
void Init_Unit(void); //初始化
void Check_Time(void); //对时
void Call_WholeData(void); //总召唤
void Com_Patrol(void); //轮询
void ComSend(void);
void ComResend(void);
void Comm_RecvProcess(void);
void CommDspTimeUpdate(void);
void YK_Command_Style(unsigned int Addr,unsigned int Style,unsigned int Seq);
//int MMI_DSP_Instruction(unsigned int Command,unsigned int per1,unsigned int per2);
void Command_Timer_Update(void);
void Command_Timer_Check(void);
int Check_Instruction_Statue(unsigned int Command);
void SendFixFrm(UC SFunCode);
void SendValFrm(UC SFunCode, UC len );
void ProcessMMI_DSP(void);
void Init_Unit(void);
void Call_WholeData(void);
void Check_Time(void);
void Com_Patrol(void);
void Read_SystemConfig(void);
void Read_SystemSetting(void);
void Auto_Adjust_Ration(void);
void Modify_Channel_Ration(void);
void Setting_PreModify(void);
void Setting_Modified_Exe(void);
void Setting_Area_Switch(void);
void YYB_Opreation(void);
void Setting_Area_Copy(void);
void Config_PreModify(void);
void Config_Modified_Exe(void);
void Password_Modified_Exe(void);
void Demand_Soe_Report(void);
void YK_Output_Command(void);
void Device_FUGUI(void);
void ADSU_01_Analyze(void);
void ASDU_05_Send0(void);
void ASDU_05_Send1(void);
void ASDU_05_Send2(void);
void ASDU_05_Analyze(void);
void ASDU_06_Send0(void);
void ASDU_06_Send1(void);
void ASDU_06_Analyze(void);
void ASDU_07_Send(void);
void ASDU_10_Send2(unsigned char Type);
void ASDU_10_Send3(unsigned char Type);
void ASDU_10_Analyze(void);
void ASDU_20_Send0(void);
void ASDU_20_Send1(void);
void ASDU_20_Send2(void);
void ASDU_20_Send3(void);
void ASDU_20_Send4(void);
void ASDU_20_Send5(void);
void ASDU_20_Send7(void);
void ASDU_20_Send8(void);
void ASDU_20_Analyze(void);
void ASDU_21_Send0(unsigned char Segment);
void ASDU_40_Analyze(void);
void ASDU_50_Analyze(void);
void ASDU_64_Send0(void);
void ASDU_64_Analyze(void);
void ASDU_Analyze(void);
//---------------------------------------------
// 初始化通信标志及缓冲区
//---------------------------------------------
void ComMMI2DSP_init(void)
{
ComDsp_buf_flag.synchro = 0;
ComDsp_buf_flag.Type = 0xff; //固定帧还是可变帧
ComDsp_buf_flag.FrameRecv = 0;
Order_Array.Set = Order_Array.Get = 0;
ComDsp_buf_flag.CommError = 0x11;
ComDsp_buf_flag.DeviceAddr = 0x03;
ComDsp_buf_flag.ReceivePoint = 0; //
ComDsp_buf_flag.SendSeq = 0x000;
ComDsp_buf_flag.FUN = 160; //哪种类型的保护
ComDsp_buf_flag.Flag_CallAll = 0x01; //上电允许总召唤
ComDsp_buf_flag.Timer_CallAll = 0; //总召唤计时器回零
ComDsp_buf_flag.Flag_CheckTime = 0x01; //上电允许对时
ComDsp_buf_flag.Modify_Time_Flag = 0x00;
ComDsp_buf_flag.Timer_CheckTime = 0; //对时间隔计时器回零
ComDsp_buf_flag.Init_System_Flag = 0x01; //上电初始化标志
//---------YK------------
ComDsp_buf_flag.YkCommand = 0; //遥控命令
ComDsp_buf_flag.YkDataNo1 = 0; //遥控点号
ComDsp_buf_flag.YkDataNo2 = 0; //遥控点号
ComDsp_buf_flag.YkSelect = 0; //选择标志
ComDsp_buf_flag.YkError = 0; //遥控出错
//---------Setting-------
ComDsp_buf_flag.DzCommand = 0; //定值操作,
ComDsp_buf_flag.DzAreaNo = 0; //定值区号
ComDsp_buf_flag.DzDataNum = 0; //定值个数
ComDsp_buf_flag.DzSelect = 0; //定值选择标志
ComDsp_buf_flag.DzError = 0; //远方修改定值出错
ComDsp_buf_flag.FunctionCode = 0; //功能码
ComDsp_buf_flag.LPDU_Command = 0;
ComDsp_buf_flag.ASDU_Length = 0;
Order_Array.Order[ Order_Array.Set ] = 0x0200;
Order_Array.Set = (Order_Array.Set+1)%10;
Order_Array.Order[ Order_Array.Set ] = 0x0100;
Order_Array.Set = (Order_Array.Set+1)%10;
ComDsp_buf_flag.com_103 =&PortA;// &Comm0;//
comm_buf_flag = &ComDsp_buf_flag;
}
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++
// 发送处理
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++
void ComSend(void)
{
UI i;
for( i = 0 ; i < comm_buf_flag->Length ; i++)
{
comm_buf_flag->com_103->SendBuf[comm_buf_flag->com_103->SendSet] = comm_buf_flag->Sendbuf[i];
if((comm_buf_flag->com_103->SendSet++) >= SENDNUM)
comm_buf_flag->com_103->SendSet=0;
if(PC_Comm_Flag == 0x00)
{
Comm0.SendBuf[Comm0.SendSet] = comm_buf_flag->Sendbuf[i];
Comm0.SendSet = (Comm0.SendSet+1)%SENDNUM;
}
}
}
void ComResend(void)
{
UI i,Length;
if( comm_buf_flag->TempBuf[0] == 0x10 )
Length = 0x05;
else if(( comm_buf_flag->TempBuf[0] == 0x68 )&&( comm_buf_flag->TempBuf[3] == 0x68 )
&&(comm_buf_flag->TempBuf[1] == comm_buf_flag->TempBuf[2]))
{
if( (comm_buf_flag->TempBuf[1]+5)== 0x16 ) Length = comm_buf_flag->TempBuf[1]+6;
}
else return;
for( i = 0 ; i < Length ; i++)
{
comm_buf_flag->com_103->SendBuf[comm_buf_flag->com_103->SendSet] = comm_buf_flag->TempBuf[i];
if((comm_buf_flag->com_103->SendSet++) >= SENDNUM)
comm_buf_flag->com_103->SendSet=0;
if(PC_Comm_Flag == 0x00)
{
Comm0.SendBuf[Comm0.SendSet] = comm_buf_flag->TempBuf[i];
Comm0.SendSet = (Comm0.SendSet+1)%SENDNUM;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -