《IEC61850 C++.doc》由会员分享,可在线阅读,更多相关《IEC61850 C++.doc(2页珍藏版)》请在三一办公上搜索。
1、规范性:封装性:继承性:多态性:完整性:/*/data.h/#include#include# define N 100Using namespace std;Class DATA /IEC 61850-7-2 数据类 Public:string DataName; /数据名称string DataRef; /数据属性/*/Class INS:public DATA /INS类继承自DATA类 Public:Int stValN; /状态字String q; /品质Time t; /时标String d; /描述/*/Class Health:public INS /Health类继承自INS
2、类 Private:String DataName; /定义数据名 Public:Void SetDataName() /设置数据名为HealthDataName=Health;/*/class Time /时间类public:Time( int = 0, int = 0, int = 0);/ set functions, 设定函数/void setTime( int, int, int ); / set hour, minute and second, 调用setHour, setMinute, setSecondvoid setHour( int ); / set hour (after
3、 validation, 有效性检查)void setMinute( int ); / set minute(after validation, 有效性检查)void setSecond( int ); / set second(after validation, 有效性检查)/ get functions, 获取函数/int getHour();int getMinute();int getSecond();/ print functions, 输出函数/void printlnUniversal();/ data members, 数据成员/private:int hour; / 0 -
4、23 (24-hour clock format)小时int minute; / 0 59分钟int second; / 0 59秒; /*/Class类函数Time:Time(int hr, int min, int sec) /内置函数setTime(hr, min, sec);void Time:setTime(int h, int m, int s) /构造函数调用内置函数setHour( h );setMinute( m );setSecond( s );void Time:setHour(int h) /设置小时hour = ( h = 0 & h = 0 & m = 0 & s
5、60 ) ? s : 0; int Time:getHour() / 获取小时return hour;int Time:getMinute() / 获取分钟return minute;int Time:getSecond() / 获取秒钟return second;void Time:printlnUniversal() / 输出时间(24小时标准计时)cout setfill( 0 ) setw( 2 ) getHour() : setw( 2 ) getMinute() : setw( 2 ) getSecond(); /*/主函数#include#includeUsing namespace std;int main()INS.t.time(0, 0, 0); /设置原件工作起始时间 int i;for(i=0;istVali; /输入状态字,为int型t.printlnUniversal(); / 00:00:00 /显示工作时间return 0;