Commit 6867b35d authored by Claes Sjofors's avatar Claes Sjofors

Profinet, Added functionality for acyclic write to a device

parent 37612708
......@@ -29,4 +29,5 @@
110328 cs profinet Profinet configurator, choice wether to clear or keep data when gsdml file is changed.
110429 cs profibus Profibus gsd Bit and BitArea syntax fix for space between Bit and (
110531 cs profinet Recall buffer added to profinet configurator.
110531 cs profinet Script functions GetIoDeviceData and SetIoDeviceData to modify profinet configuration added.
\ No newline at end of file
110531 cs profinet Script functions GetIoDeviceData and SetIoDeviceData to modify profinet configuration added.
110909 rk profinet Added functionality for acyclic write to a device
\ No newline at end of file
......@@ -220,6 +220,7 @@ static pwr_tStatus IoAgentInit (
pn_subslot_data = new PnSubmoduleData;
pn_subslot_data->subslot_number = dev_data->slot_data[jj]->subslot_data[kk]->subslot_number;
pn_subslot_data->ident_number = dev_data->slot_data[jj]->subslot_data[kk]->submodule_ident_number;
pn_subslot_data->api = dev_data->slot_data[jj]->subslot_data[kk]->api;
if (dev_data->slot_data[jj]->subslot_data[kk]->io_input_length > 0) {
pn_subslot_data->io_in_data_length = dev_data->slot_data[jj]->subslot_data[kk]->io_input_length;
pn_subslot_data->type = PROFINET_IO_SUBMODULE_TYPE_INPUT ;
......@@ -261,7 +262,7 @@ static pwr_tStatus IoAgentInit (
sts = pnak_send_service_req_res(0, &local->service_req_res);
if (sts == PNAK_OK) {
sts = handle_service_con(local, ap);
sts = wait_service_con(local, ap);
if (sts == PNAK_OK) {
/* Loop through devices and calculate offset for io */
......@@ -324,7 +325,7 @@ static pwr_tStatus IoAgentInit (
sts = pnak_send_service_req_res(0, &local->service_req_res);
if (sts == PNAK_OK) {
sts = handle_service_con(local, ap);
sts = wait_service_con(local, ap);
}
/* Set mode online */
......@@ -393,7 +394,7 @@ static pwr_tStatus IoAgentInit (
sts = pnak_send_service_req_res(0, &local->service_req_res);
if (sts == PNAK_OK) {
sts = handle_service_con(local, ap);
sts = wait_service_con(local, ap);
}
}
......@@ -484,6 +485,8 @@ static pwr_tStatus IoAgentWrite (
unsigned char *io_datap;
unsigned char *clean_io_datap;
PnSubmoduleData *submodule;
io_sRack *slave_list;
pwr_sClass_PnDevice *sp;
unsigned short data_length, ii, jj, kk, ll;
unsigned char *status_datap;
......@@ -492,6 +495,9 @@ static pwr_tStatus IoAgentWrite (
/* Write i/o for all devices fetch it first from clean io data area */
/* Iterate over the slaves. */
slave_list = ap->racklist;
for (ii = 1; ii < local->device_data.size(); ii++) {
if (local->device_data[ii]->device_state == PNAK_DEVICE_STATE_CONNECTED) {
......@@ -520,6 +526,36 @@ static pwr_tStatus IoAgentWrite (
sts = pnak_set_iocr_data(0, pn_iocr_data->identifier, pn_iocr_data->io_data, pn_iocr_data->io_data_length);
}
}
if (slave_list != NULL) {
sp = (pwr_sClass_PnDevice *) slave_list->op;
slave_list = slave_list->next;
/* Check if there is a write request pending ?? */
if (sp->WriteReq.SendReq) {
if ((sp->WriteReq.Length > 0) && (sp->WriteReq.Length <= sizeof(sp->WriteReq.Data))) {
for (jj = 0; jj < local->device_data[ii]->module_data.size(); jj++) {
if (local->device_data[ii]->module_data[jj]->slot_number == sp->WriteReq.SlotNumber) {
for (kk = 0; kk < local->device_data[ii]->module_data[jj]->submodule_data.size(); kk++) {
if (local->device_data[ii]->module_data[jj]->submodule_data[kk]->subslot_number == sp->WriteReq.SubslotNumber) {
if (local->device_data[ii]->module_data[jj]->submodule_data[kk]->api > 0) {
sp->WriteReq.Api = local->device_data[ii]->module_data[jj]->submodule_data[kk]->api;
}
pack_write_req(&local->service_req_res, local->device_data[ii]->device_ref, &sp->WriteReq);
sts = pnak_send_service_req_res(0, &local->service_req_res);
break;
}
}
break;
}
}
}
sp->WriteReq.SendReq = 0;
}
}
}
}
......
......@@ -74,7 +74,7 @@ class PnIOCRData {
class PnSubmoduleData {
public:
PnSubmoduleData() : subslot_number(0), subslot_idx(0), type(0), state(0), ident_number(0), phys_ident_number(0) {}
PnSubmoduleData() : subslot_number(0), subslot_idx(0), type(0), state(0), ident_number(0), phys_ident_number(0), api(0) {}
unsigned short subslot_number;
unsigned short subslot_idx;
......@@ -82,6 +82,7 @@ class PnSubmoduleData {
unsigned short state;
unsigned int ident_number;
unsigned int phys_ident_number;
unsigned int api;
unsigned short io_in_data_length; // bytes of pure io-data
unsigned short offset_io_in; // offset in io-data area for this iocr
......
......@@ -63,6 +63,8 @@ void pack_set_identification_req(T_PNAK_SERVICE_REQ_RES *ServiceReqRes);
void pack_get_device_state_req(T_PNAK_SERVICE_REQ_RES *ServiceReqRes, unsigned short device_ref);
void pack_write_req(T_PNAK_SERVICE_REQ_RES *ServiceReqRes, unsigned short device_ref, pwr_sClass_PnWriteReq *wr_req);
void pack_get_los_req(T_PNAK_SERVICE_REQ_RES *ServiceReqRes);
void pack_get_alarm_req(T_PNAK_SERVICE_REQ_RES *ServiceReqRes, unsigned short ref);
......@@ -71,6 +73,8 @@ void pack_alarm_ack_req(T_PNAK_SERVICE_REQ_RES *ServiceReqRes, unsigned short re
void pack_download_req(T_PNAK_SERVICE_REQ_RES *ServiceReqRes, GsdmlDeviceData *dev_data, unsigned short device_ref);
int unpack_write_con(T_PNAK_SERVICE_DESCRIPTION* pSdb, io_sAgentLocal *local);
int unpack_get_los_con(T_PNAK_SERVICE_DESCRIPTION* pSdb, io_sAgentLocal *local);
int unpack_get_alarm_con(T_PNAK_SERVICE_DESCRIPTION* pSdb, io_sAgentLocal *local, io_sAgent *ap);
......@@ -80,6 +84,8 @@ int unpack_download_con(T_PNAK_SERVICE_DESCRIPTION* pSdb, io_sAgentLocal *local)
int handle_service_con(io_sAgentLocal *local, io_sAgent *ap);
int wait_service_con(io_sAgentLocal *local, io_sAgent *ap);
void handle_exception (io_sAgentLocal *local);
void handle_state_changed (io_sAgentLocal *local);
......
Volume Profibus $ClassVolume 0.0.250.7
Body SysBody 05-SEP-2005 17:51:40.00
Attr NextOix = "_X209"
Attr NextCix = "_X19"
Attr NextCix = "_X20"
Attr NextTix[0] = "_X12"
EndBody
Object Type $TypeHier 55 16-JAN-2006 10:07:43.21
......@@ -2695,7 +2695,7 @@ Volume Profibus $ClassVolume 0.0.250.7
!
! Furthermore, manufacturer specific alarms may be used and alarms
! are reserved for profile specific definitions.
!
!
!*/
Object Type $Attribute 1 10-JUN-2010 10:53:19.20
Body SysBody 21-OCT-2010 08:59:53.40
......@@ -2803,12 +2803,103 @@ Volume Profibus $ClassVolume 0.0.250.7
EndObject
EndObject
!/**
! Sends an acyclic write request to a device
! for a certain slot and subslot.
!*/
Object PnWriteReq $ClassDef 19 07-SEP-2011 08:49:46.86
Body SysBody 07-SEP-2011 08:49:30.59
Attr Editor = 0
Attr Method = 0
Attr Flags = 16
EndBody
Object RtBody $ObjBodyDef 1 07-SEP-2011 08:49:53.46
Body SysBody 07-SEP-2011 08:49:53.46
Attr StructName = "PnWriteReq"
Attr NextAix = "_X8"
EndBody
!/**
! Application Process Identifier, usually 0 but can be
! defined to other by a device profile.
!*/
Object Api $Attribute 1 07-SEP-2011 08:50:09.27
Body SysBody 07-SEP-2011 08:50:29.19
Attr PgmName = "Api"
Attr TypeRef = "pwrs:Type-$UInt32"
EndBody
EndObject
!/**
! Number of slot to write to.
!*/
Object SlotNumber $Attribute 2 07-SEP-2011 08:50:58.89
Body SysBody 07-SEP-2011 08:50:58.89
Attr PgmName = "SlotNumber"
Attr Flags = 1024
Attr TypeRef = "pwrs:Type-$UInt16"
EndBody
EndObject
!/**
! Number of subslot to write to.
!*/
Object SubslotNumber $Attribute 3 07-SEP-2011 08:50:58.89
Body SysBody 07-SEP-2011 08:50:58.89
Attr PgmName = "SubslotNumber"
Attr Flags = 1024
Attr TypeRef = "pwrs:Type-$UInt16"
EndBody
EndObject
!/**
! Unique ID of record data object to write to.
!*/
Object Index $Attribute 4 07-SEP-2011 08:51:20.46
Body SysBody 07-SEP-2011 08:51:21.42
Attr PgmName = "Index"
Attr Flags = 1024
Attr TypeRef = "pwrs:Type-$UInt16"
EndBody
EndObject
!/**
! Bytes of data to write.
!*/
Object Length $Attribute 5 07-SEP-2011 08:55:25.16
Body SysBody 07-SEP-2011 08:55:25.53
Attr PgmName = "Length"
Attr Flags = 1024
Attr TypeRef = "pwrs:Type-$UInt16"
EndBody
EndObject
!/**
! The data to write.
!*/
Object Data $Attribute 6 07-SEP-2011 08:56:03.58
Body SysBody 07-SEP-2011 08:56:48.30
Attr PgmName = "Data"
Attr Flags = 1026
Attr Elements = 256
Attr TypeRef = "pwrs:Type-$UInt8"
EndBody
EndObject
!/**
! Send the write request.
!*/
Object SendReq $Attribute 7 07-SEP-2011 09:13:01.58
Body SysBody 07-SEP-2011 09:13:16.75
Attr PgmName = "SendReq"
Attr TypeRef = "pwrs:Type-$Boolean"
EndBody
EndObject
EndObject
Object Template PnWriteReq 2152693760 01-JAN-1970 01:00:00.00
Body RtBody 01-JAN-1970 01:00:00.00
EndBody
EndObject
EndObject
!/**
! @Author Robert Karlsson
! @Version 1.0
! @Group IO
! @Summary Defines that a Profinet controller stack is installed.
! Configures a Profinet controller stack.
!
!
! @b See also
! @classlink PnDevice profibus_pndevice.html
!*/
......@@ -2915,7 +3006,7 @@ Volume Profibus $ClassVolume 0.0.250.7
! @Group IO
! @Summary Configures one Profinet device.
! Configures one Profinet device.
!
!
! @b See also
! @classlink PnControllerSoftingPNAK profibus_pncontrollersoftingpnak.html
! @classlink Hilscher_cifX_PnController otherio_hilscher_cifx_pncontroller.html
......@@ -2929,7 +3020,7 @@ Volume Profibus $ClassVolume 0.0.250.7
Object RtBody $ObjBodyDef 1 21-APR-2009 13:41:08.17
Body SysBody 21-APR-2009 13:41:08.17
Attr StructName = "PnDevice"
Attr NextAix = "_X105"
Attr NextAix = "_X106"
EndBody
!/**
! Description.
......@@ -3107,6 +3198,16 @@ Volume Profibus $ClassVolume 0.0.250.7
Attr TypeRef = "Profibus:Class-PnAlarm"
EndBody
EndObject
!/**
! Request to write data to a subslot
!*/
Object WriteReq $Attribute 105 07-SEP-2011 10:24:03.67
Body SysBody 07-SEP-2011 10:24:13.69
Attr PgmName = "WriteReq"
Attr Flags = 16908288
Attr TypeRef = "Profibus:Class-PnWriteReq"
EndBody
EndObject
EndObject
Object ConfiguratorPosnn $Menu 122 21-APR-2009 13:41:08.17
Object Pointed $Menu 123 21-APR-2009 13:41:08.17
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment