etherlab/plc_etherlab.c
changeset 2036 7c31fab22c74
parent 2032 766078d83e22
child 2039 3a218f6bd805
equal deleted inserted replaced
2035:1d113faf4433 2036:7c31fab22c74
    13 #ifdef _WINDOWS_H
    13 #ifdef _WINDOWS_H
    14   #include "iec_types.h"
    14   #include "iec_types.h"
    15 #else
    15 #else
    16   #include "iec_std_lib.h"
    16   #include "iec_std_lib.h"
    17 #endif
    17 #endif
       
    18 
       
    19 extern unsigned long long common_ticktime__;
    18 
    20 
    19 // declaration of interface variables
    21 // declaration of interface variables
    20 %(located_variables_declaration)s
    22 %(located_variables_declaration)s
    21 
    23 
    22 // Optional features
    24 // Optional features
    68     if (ecrt_domain_reg_pdo_entry_list(domain1, domain1_regs)) {
    70     if (ecrt_domain_reg_pdo_entry_list(domain1, domain1_regs)) {
    69         fprintf(stderr, "PDO entry registration failed!\n");
    71         fprintf(stderr, "PDO entry registration failed!\n");
    70         return -1;
    72         return -1;
    71     }
    73     }
    72 
    74 
       
    75 	ecrt_master_set_send_interval(master, common_ticktime__);
       
    76 
    73 %(slaves_initialization)s
    77 %(slaves_initialization)s
    74 
    78 
    75     sprintf(&rt_dev_file[0],"%%s%%u",EC_RTDM_DEV_FILE_NAME,0);
    79     sprintf(&rt_dev_file[0],"%%s%%u",EC_RTDM_DEV_FILE_NAME,0);
    76     rt_fd = rt_dev_open( &rt_dev_file[0], 0);
    80     rt_fd = rt_dev_open( &rt_dev_file[0], 0);
    77     if (rt_fd < 0) {
    81     if (rt_fd < 0) {
   109 	ecrt_release_master(master);
   113 	ecrt_release_master(master);
   110 }
   114 }
   111 
   115 
   112 void __retrieve_%(location)s(void)
   116 void __retrieve_%(location)s(void)
   113 {
   117 {
       
   118     // send process data
       
   119     ecrt_rtdm_domain_queque(rt_fd);
       
   120     ecrt_rtdm_master_send(rt_fd);
       
   121 
       
   122     rt_task_sleep(rt_timer_ns2tsc(wait_period_ns));
       
   123 
   114     // receive ethercat
   124     // receive ethercat
   115     ecrt_rtdm_master_recieve(rt_fd);
   125     ecrt_rtdm_master_recieve(rt_fd);
   116     ecrt_rtdm_domain_process(rt_fd);
   126     ecrt_rtdm_domain_process(rt_fd);
   117 
       
   118     rt_task_sleep(rt_timer_ns2tsc(wait_period_ns));
       
   119 
       
   120     // send process data
       
   121     ecrt_rtdm_domain_queque(rt_fd);
       
   122     ecrt_rtdm_master_send(rt_fd);
       
   123 
   127 
   124 %(retrieve_variables)s
   128 %(retrieve_variables)s
   125 }
   129 }
   126 
   130 
   127 void __publish_%(location)s(void)
   131 void __publish_%(location)s(void)