您的位置:控制工程论坛网论坛 » 自动化软件 » WINCC实现打印时间选择教程

马军成

马军成   |   当前状态:在线

总积分:13914  2024年可用积分:0

注册时间: 2006-12-01

最后登录时间: 2022-06-28

空间 发短消息加为好友

WINCC实现打印时间选择教程

马军成  发表于 2007/11/11 20:27:11      1999 查看 1 回复  [上一主题]  [下一主题]

手机阅读

WINCC实现打印时间选择教程

 打印时间选择教程

            1.  报表编辑器-〉布局,新建动态对象中的动态表格。然后连结表格。
            2.  取消时间范围的选择,并建立好变量选择,这里的变量应该是变量记录中的归档变量,其采集时间是从归档变量中设置的。
            3.  完成后退出并新建打印作业。取消启动参数的选择,选择时间范围中的绝对时间。
            4.  实现打印功能最关键的是一个新建的项目函数,西门子的教程上有例子。我已将条是调试通过。
            /*****************************************************************************/
            //                   函数名:ModifyPrintJob
            //                   功  能:修改打印作业的绝对时间
            /*****************************************************************************/
            BOOL ModifyPrintJob(SYSTEMTIME st1, SYSTEMTIME st2, char 
            jobname[200])
            {
                   BOOL                                 fRet;
                   PCMN_ERROR                   pError;
                   HPROPERTIES                    hProp;
                   LPVOID                              ptr1, ptr2;
                   DWORD                             typ;
                   DWORD                             dwVal;
                   char                                    
            propname1[200],propname2[200];
                   TCHAR                               g_szProj[MAX_PATH+1];
                   
                   typ = VT_DATE;
                   strcpy( propname1, "ABSOLUTESELECTIONFROM" );
                   strcpy( propname2, "ABSOLUTESELECTIONTO" );
                   ptr1 = (LPVOID)&st1;
                   ptr2 = (LPVOID)&st2;
                   if( !DMGetRuntimeProject( g_szProj, MAX_PATH, pError ) )
                   {
                          printf( "Error DMGetRuntimeProject(...) 
            " );
                          return FALSE;
                   }
                   hProp = RPJCreatePropertyHandle( g_szProj, pError );
                   if( !hProp )
                   {
                          printf( "Error RPJCreatePropertyHandle(...) 
            " );
                          return FALSE;
                   }
                   if( !RPJGetJobProps( hProp, jobname, pError ) )
                   {
                          printf( "Error RPJGetJobProps(...) 
            " );
                          RPJDeletePropertyHandle( hProp, pError );
                          return FALSE;
                   }
                   if( !RPJSetProperty( hProp, propname1, ptr1, (VARTYPE)typ, 
            200, pError ) )
                   {
                          printf( "Error RPJSetProperty(...) 
            " );
                          RPJDeletePropertyHandle( hProp, pError );
                          return FALSE;
                   }
                   if( !RPJSetJobProps( hProp, jobname, pError ) )
                   {
                          printf( "Error RPJSetJobProps(...) 
            " );
                          RPJDeletePropertyHandle( hProp, pError );
                          return FALSE;
                   }
                   if( !RPJGetJobProps( hProp, jobname, pError ) )
                   {
                          printf( "Error RPJGetJobProps(...) 
            " );
                          RPJDeletePropertyHandle( hProp, pError );
                          return FALSE;
                   }
                   if( !RPJSetProperty( hProp, propname2, ptr2, (VARTYPE)typ, 
            200, pError ) )
                   {
                          printf( "Error RPJSetProperty(...) 
            " );
                          RPJDeletePropertyHandle( hProp, pError );
                          return FALSE;        
                   }
                   if( !RPJSetJobProps( hProp, jobname, pError ) )
                   {
                          printf( "Error RPJSetProps(...) 
            " );
                          RPJDeletePropertyHandle( hProp, pError );
                          return FALSE;        
                   }
                   fRet = RPJDeletePropertyHandle( hProp, pError );
                   return TRUE;
            }
            /*****************************************************************************/
            //                   函数名:TimeFrom
            //                   功  能:打印时间的开始时间
            /*****************************************************************************/
            SYSTEMTIME TimeFrom()
            {
                   SYSTEMTIME st;
                   st.wYear = GetTagWord("FromYear");
                   st.wMonth = GetTagWord("FromMonth");
                   st.wDay = GetTagWord("FromDay");
                   st.wHour = GetTagWord("FromHour");
                   st.wMinute = GetTagWord("FromMinute");
                   st.wSecond = GetTagWord("FromSecond");
                   return st ;
            }
            /*****************************************************************************/
            //                   函数名:TimeTo
            //                   功  能:打印时间的结束时间
            /*****************************************************************************/
            SYSTEMTIME      TimeTo()
            {
                   SYSTEMTIME st;
                   st.wYear = GetTagWord("ToYear");
                   st.wMonth = GetTagWord("ToMonth");
                   st.wDay = GetTagWord("ToDay");
                   st.wHour = GetTagWord("ToHour");
                   st.wMinute = GetTagWord("ToMinute");
                   st.wSecond = GetTagWord("ToSecond");
                   return st ;
            }
            以上的这些函数都是新建立的项目函数(可以直接粘贴使用,已经过调试)。其中用到的变量 FromYear, FromMonth, 
            FromDay, FromHour, FromMinute, FromSecond, ToYear, ToMonth, ToDay, 
            ToHour, ToMinute, ToSecond 都是新建立的内部对象。
            5.  在组态画面上新建一个打印按钮,调用该函数即可实现。 

1楼 0 0 回复
总共 , 当前 /