Просмотр исходного кода

Starts reimplementation of ConnectionObject

Signed-off-by: CapXilinx <melik-merkumians@acin.tuwien.ac.at>
CapXilinx 8 лет назад
Родитель
Сommit
849a8fc205
2 измененных файлов с 132 добавлено и 0 удалено
  1. 52 0
      source/src/cip/cipconnectionobject.c
  2. 80 0
      source/src/cip/cipconnectionobject.h

+ 52 - 0
source/src/cip/cipconnectionobject.c

@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright (c) 2017, Rockwell Automation, Inc.
+ * All rights reserved.
+ *
+ ******************************************************************************/
+
+#include "cipconnectionobject.h"
+
+#define CIP_CONNECTION_OBJECT_STATE_NON_EXISTANT 0U
+#define CIP_CONNECTION_OBJECT_STATE_CONFIGURING 1U
+#define CIP_CONNECTION_OBJECT_STATE_WAITING_FOR_CONNECTION_ID 2U
+#define CIP_CONNECTION_OBJECT_STATE_ESTABLISHED 3U
+#define CIP_CONNECTION_OBJECT_STATE_TIMEOUT 4U
+#define CIP_CONNECTION_OBJECT_STATE_DEFERRED_DELETE 5U
+#define CIP_CONNECTION_OBJECT_STATE_CLOSING 6U
+
+ConnectionObjectState GetConnectionObjectState(
+  const CipConnectionObject *const connection_object) {
+  switch(connection_object->state) {
+    case CIP_CONNECTION_OBJECT_STATE_NON_EXISTANT: return
+        kConnectionObjectStateNonExistant; break;
+    case CIP_CONNECTION_OBJECT_STATE_CONFIGURING: return
+        kConnectionObjectStateConfiguring; break;
+    case CIP_CONNECTION_OBJECT_STATE_WAITING_FOR_CONNECTION_ID: return
+        kConnectionObjectStateWaitingForConnectionID; break;
+    case CIP_CONNECTION_OBJECT_STATE_ESTABLISHED: return
+        kConnectionObjectStateEstablished; break;
+    case CIP_CONNECTION_OBJECT_STATE_TIMEOUT: return
+        kConnectionObjectStateTimedOut; break;
+    case CIP_CONNECTION_OBJECT_STATE_DEFERRED_DELETE: return
+        kConnectionStateDeferredDelete; break;
+    case CIP_CONNECTION_OBJECT_STATE_CLOSING: return
+        kConnectionObjectStateClosing; break;
+    default: return kConnectionObjectStateInvalid;
+  }
+}
+
+ConnectionObjectInstanceType GetConnectionObjectInstanceType(
+  const CipConnectionObject *const connection_object) {
+
+}
+
+ConnectionObjectTransportClassTriggerDirection
+GetConnectionObjectTransportClassTriggerDirection(
+  const CipConnectionObject *const connection_object) {
+  const CipByte TransportClassTriggerDirectionMask = 0x80;
+  return (connection_object->transport_class_trigger &
+          TransportClassTriggerDirectionMask) ==
+         TransportClassTriggerDirectionMask ?
+         kConnectionObjectTransportClassTriggerDirectionServer
+         : kConnectionObjectTransportClassTriggerDirectionClient;
+}

+ 80 - 0
source/src/cip/cipconnectionobject.h

@@ -0,0 +1,80 @@
+/*******************************************************************************
+ * Copyright (c) 2017, Rockwell Automation, Inc.
+ * All rights reserved.
+ *
+ ******************************************************************************/
+
+#ifndef SRC_CIP_CIPCONNECTIONOBJECT_H_
+#define SRC_CIP_CIPCONNECTIONOBJECT_H_
+
+#include "typedefs.h"
+
+#define CIP_CONNECTION_OBJECT_CODE 0x05
+
+typedef enum {
+  kConnectionObjectStateInvalid = -1,
+  kConnectionObjectStateNonExistant = 0,
+  kConnectionObjectStateConfiguring,
+  kConnectionObjectStateWaitingForConnectionID,
+  kConnectionObjectStateEstablished,
+  kConnectionObjectStateTimedOut,
+  kConnectionObjectStateDeferredDelete,
+  kConnectionObjectStateClosing
+} ConnectionObjectState;
+
+typedef enum {
+  kConnectionObjectInstanceTypeExplicitMessaging = 0,
+  kConnectionObjectInstanceTypeIO,
+  kConnectionObjectInstanceTypeCipBridged
+} ConnectionObjectInstanceType;
+
+typedef enum {
+  kConnectionObjectTransportClassTriggerDirectionClient = 0,
+  kConnectionObjectTransportClassTriggerDirectionServer
+} ConnectionObjectTransportClassTriggerDirection;
+
+typedef enum {
+  kConnectionObjectTransportClassTriggerProductionTriggerCyclic = 0,
+  kConnectionObjectTransportClassTriggerProductionTriggerChangeOfState,
+  kConnectionObjectTransportClassTriggerProductionTriggerApplicationObject
+} ConnectionObjectTransportClassTriggerProductionTrigger;
+
+typedef enum {
+  kConnectionObjectTransportClassTriggerTransportClass0 = 0,
+  kConnectionObjectTransportClassTriggerTransportClass1,
+  kConnectionObjectTransportClassTriggerTransportClass2,
+  kConnectionObjectTransportClassTriggerTransportClass3
+} ConnectionObjectTransportClassTriggerTransportClass;
+
+typedef struct cip_connection_object {
+  CipUsint state;       //*< Attribute 1
+  CipUsint instance_type;       //*< Attribute 2
+  CipByte transport_class_trigger;       //*< Attribute 3
+  /* Attribute 4-6 only for device net*/
+  CipUint produced_connection_size;       //*< Attribute 7
+  CipUint consumed_connection_size;       //*< Attribute 8
+  CipUint expected_packet_rate;       //*< Attribute 9
+  CipUint cip_produced_connection_id;       //*< Attribute 10
+  CipUint cip_consumed_connection_id;       //*< Attribute 11
+  CipUsint watchdog_timeout_action;       //*< Attribute 12
+  CipUint produced_connection_path_length;       //*< Attribute 13
+  CipEpath produced_connection_path;       //*< Attribute 14
+  CipUint consumed_connection_path_length;       //*< Attribute 15
+  CipEpath consumed_connection_path;       //*< Attribute 16
+  CipUint production_inhibit_time;        //*< Attribute 17
+  CipUsint connection_timeout_multiplier;        //*< Attribute 18
+  /* Attribute 19 not supported as Connection Bind service not supported */
+
+} CipConnectionObject;
+
+ConnectionObjectState GetConnectionObjectState(
+  const CipConnectionObject *const connection_object);
+
+ConnectionObjectInstanceType GetConnectionObjectInstanceType(
+  const CipConnectionObject *const connection_object);
+
+ConnectionObjectTransportClassTriggerDirection
+GetConnectionObjectTransportClassTriggerDirection(
+  const CipConnectionObject *const connection_object);
+
+#endif /* SRC_CIP_CIPCONNECTIONOBJECT_H_ */