From 00e071639b0a0484bc6b22bdf272e27df5aadf3c Mon Sep 17 00:00:00 2001 From: Markus Sommer Date: Mon, 25 Mar 2019 12:45:45 +0100 Subject: [PATCH 1/2] Add Classes from Folders Messages, Events and Connection (in part) --- .../base/connection/AbstractPlcConnection.cpp | 55 +++++ .../base/connection/AbstractPlcConnection.h | 79 +++++++ .../cpp/base/connection/ChannelFactory.cpp | 39 ++++ .../cpp/base/connection/ChannelFactory.h | 59 +++++ .../connection/DefaultPlcFieldHandler.cpp | 111 ++++++++++ .../base/connection/DefaultPlcFieldHandler.h | 96 +++++++++ .../cpp/base/connection/PlcFieldHandler.cpp | 39 ++++ .../cpp/base/connection/PlcFieldHandler.h | 99 +++++++++ .../plc4x/cpp/base/events/ConnectEvent.cpp | 39 ++++ .../plc4x/cpp/base/events/ConnectEvent.h | 48 +++++ .../plc4x/cpp/base/events/ConnectedEvent.cpp | 39 ++++ .../plc4x/cpp/base/events/ConnectedEvent.h | 47 ++++ .../base/messages/DefaultPlcReadRequest.cpp | 122 +++++++++++ .../cpp/base/messages/DefaultPlcReadRequest.h | 81 +++++++ .../base/messages/DefaultPlcWriteRequest.cpp | 120 +++++++++++ .../base/messages/DefaultPlcWriteRequest.h | 81 +++++++ .../base/messages/InternalPlcFieldRequest.cpp | 42 ++++ .../base/messages/InternalPlcFieldRequest.h | 54 +++++ .../messages/InternalPlcFieldResponse.cpp | 39 ++++ .../base/messages/InternalPlcFieldResponse.h | 53 +++++ .../InternalPlcProprietaryRequest.cpp | 40 ++++ .../messages/InternalPlcProprietaryRequest.h | 52 +++++ .../InternalPlcProprietaryResponse.cpp | 40 ++++ .../messages/InternalPlcProprietaryResponse.h | 52 +++++ .../base/messages/InternalPlcReadRequest.cpp | 39 ++++ .../base/messages/InternalPlcReadRequest.h | 54 +++++ .../cpp/base/messages/InternalPlcRequest.cpp | 39 ++++ .../cpp/base/messages/InternalPlcRequest.h | 53 +++++ .../cpp/base/messages/InternalPlcResponse.cpp | 39 ++++ .../cpp/base/messages/InternalPlcResponse.h | 53 +++++ .../base/messages/InternalPlcWriteRequest.cpp | 39 ++++ .../base/messages/InternalPlcWriteRequest.h | 60 ++++++ .../base/messages/PlcProprietaryRequest.cpp | 39 ++++ .../cpp/base/messages/PlcProprietaryRequest.h | 54 +++++ .../base/messages/PlcProprietaryResponse.cpp | 40 ++++ .../base/messages/PlcProprietaryResponse.h | 53 +++++ .../plc4x/cpp/base/messages/PlcReader.cpp | 39 ++++ .../plc4x/cpp/base/messages/PlcReader.h | 49 +++++ .../plc4x/cpp/base/messages/PlcWriter.cpp | 39 ++++ .../plc4x/cpp/base/messages/PlcWriter.h | 55 +++++ .../messages/items/BaseDefaultFieldItem.cpp | 43 ++++ .../messages/items/BaseDefaultFieldItem.h | 136 ++++++++++++ .../items/DefaultBigDecimalFieldItem.cpp | 196 +++++++++++++++++ .../items/DefaultBigDecimalFieldItem.h | 83 ++++++++ .../items/DefaultBigIntegerFieldItem.cpp | 201 ++++++++++++++++++ .../items/DefaultBigIntegerFieldItem.h | 84 ++++++++ .../items/DefaultBooleanFieldItem.cpp | 196 +++++++++++++++++ .../messages/items/DefaultBooleanFieldItem.h | 80 +++++++ .../items/DefaultByteArrayFieldItem.cpp | 196 +++++++++++++++++ .../items/DefaultByteArrayFieldItem.h | 81 +++++++ .../messages/items/DefaultByteFieldItem.cpp | 196 +++++++++++++++++ .../messages/items/DefaultByteFieldItem.h | 81 +++++++ .../messages/items/DefaultDoubleFieldItem.cpp | 196 +++++++++++++++++ .../messages/items/DefaultDoubleFieldItem.h | 81 +++++++ .../messages/items/DefaultFloatFieldItem.cpp | 196 +++++++++++++++++ .../messages/items/DefaultFloatFieldItem.h | 81 +++++++ .../items/DefaultIntegerFieldItem.cpp | 196 +++++++++++++++++ .../messages/items/DefaultIntegerFieldItem.h | 81 +++++++ .../items/DefaultLocalDateFieldItem.cpp | 196 +++++++++++++++++ .../items/DefaultLocalDateFieldItem.h | 81 +++++++ .../items/DefaultLocalDateTimeFieldItem.h | 71 +++++++ .../items/DefaultLocalDateTimeFieldltem.cpp | 95 +++++++++ .../items/DefaultLocalTimeFieldItem.cpp | 95 +++++++++ .../items/DefaultLocalTimeFieldItem.h | 71 +++++++ .../messages/items/DefaultLongFieldItem.cpp | 196 +++++++++++++++++ .../messages/items/DefaultLongFieldItem.h | 82 +++++++ .../messages/items/DefaultShortFieldItem.cpp | 196 +++++++++++++++++ .../messages/items/DefaultShortFieldItem.h | 82 +++++++ .../messages/items/DefaultStringFieldItem.cpp | 59 +++++ .../messages/items/DefaultStringFieldItem.h | 66 ++++++ 70 files changed, 5964 insertions(+) create mode 100644 plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/connection/AbstractPlcConnection.cpp create mode 100644 plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/connection/AbstractPlcConnection.h create mode 100644 plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/connection/ChannelFactory.cpp create mode 100644 plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/connection/ChannelFactory.h create mode 100644 plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/connection/DefaultPlcFieldHandler.cpp create mode 100644 plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/connection/DefaultPlcFieldHandler.h create mode 100644 plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/connection/PlcFieldHandler.cpp create mode 100644 plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/connection/PlcFieldHandler.h create mode 100644 plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/events/ConnectEvent.cpp create mode 100644 plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/events/ConnectEvent.h create mode 100644 plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/events/ConnectedEvent.cpp create mode 100644 plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/events/ConnectedEvent.h create mode 100644 plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/DefaultPlcReadRequest.cpp create mode 100644 plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/DefaultPlcReadRequest.h create mode 100644 plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/DefaultPlcWriteRequest.cpp create mode 100644 plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/DefaultPlcWriteRequest.h create mode 100644 plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/InternalPlcFieldRequest.cpp create mode 100644 plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/InternalPlcFieldRequest.h create mode 100644 plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/InternalPlcFieldResponse.cpp create mode 100644 plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/InternalPlcFieldResponse.h create mode 100644 plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/InternalPlcProprietaryRequest.cpp create mode 100644 plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/InternalPlcProprietaryRequest.h create mode 100644 plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/InternalPlcProprietaryResponse.cpp create mode 100644 plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/InternalPlcProprietaryResponse.h create mode 100644 plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/InternalPlcReadRequest.cpp create mode 100644 plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/InternalPlcReadRequest.h create mode 100644 plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/InternalPlcRequest.cpp create mode 100644 plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/InternalPlcRequest.h create mode 100644 plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/InternalPlcResponse.cpp create mode 100644 plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/InternalPlcResponse.h create mode 100644 plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/InternalPlcWriteRequest.cpp create mode 100644 plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/InternalPlcWriteRequest.h create mode 100644 plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/PlcProprietaryRequest.cpp create mode 100644 plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/PlcProprietaryRequest.h create mode 100644 plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/PlcProprietaryResponse.cpp create mode 100644 plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/PlcProprietaryResponse.h create mode 100644 plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/PlcReader.cpp create mode 100644 plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/PlcReader.h create mode 100644 plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/PlcWriter.cpp create mode 100644 plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/PlcWriter.h create mode 100644 plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/BaseDefaultFieldItem.cpp create mode 100644 plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/BaseDefaultFieldItem.h create mode 100644 plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultBigDecimalFieldItem.cpp create mode 100644 plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultBigDecimalFieldItem.h create mode 100644 plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultBigIntegerFieldItem.cpp create mode 100644 plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultBigIntegerFieldItem.h create mode 100644 plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultBooleanFieldItem.cpp create mode 100644 plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultBooleanFieldItem.h create mode 100644 plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultByteArrayFieldItem.cpp create mode 100644 plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultByteArrayFieldItem.h create mode 100644 plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultByteFieldItem.cpp create mode 100644 plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultByteFieldItem.h create mode 100644 plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultDoubleFieldItem.cpp create mode 100644 plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultDoubleFieldItem.h create mode 100644 plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultFloatFieldItem.cpp create mode 100644 plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultFloatFieldItem.h create mode 100644 plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultIntegerFieldItem.cpp create mode 100644 plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultIntegerFieldItem.h create mode 100644 plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultLocalDateFieldItem.cpp create mode 100644 plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultLocalDateFieldItem.h create mode 100644 plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultLocalDateTimeFieldItem.h create mode 100644 plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultLocalDateTimeFieldltem.cpp create mode 100644 plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultLocalTimeFieldItem.cpp create mode 100644 plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultLocalTimeFieldItem.h create mode 100644 plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultLongFieldItem.cpp create mode 100644 plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultLongFieldItem.h create mode 100644 plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultShortFieldItem.cpp create mode 100644 plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultShortFieldItem.h create mode 100644 plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultStringFieldItem.cpp create mode 100644 plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultStringFieldItem.h diff --git a/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/connection/AbstractPlcConnection.cpp b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/connection/AbstractPlcConnection.cpp new file mode 100644 index 00000000000..af47faa5432 --- /dev/null +++ b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/connection/AbstractPlcConnection.cpp @@ -0,0 +1,55 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +*/ + +#include "AbstractPlcConnection.h" + +namespace org +{ + namespace apache + { + namespace plc4x + { + namespace cpp + { + namespace base + { + namespace connection + { + PlcConnectionMetadata& AbstractPlcConnection::getMetadata() + { + return *this; + } + bool AbstractPlcConnection::canRead() + { + return false; + } + bool AbstractPlcConnection::canWrite() + { + return false; + } + bool AbstractPlcConnection::canSubscribe() + { + return false; + } + } + } + } + } + } +} diff --git a/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/connection/AbstractPlcConnection.h b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/connection/AbstractPlcConnection.h new file mode 100644 index 00000000000..4f85192b7b7 --- /dev/null +++ b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/connection/AbstractPlcConnection.h @@ -0,0 +1,79 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +*/ + +#ifndef _ABSTRCT_PLC_HANDLER +#define _ABSTRCT_PLC_HANDLER + +#include +#include "../../../../../../../../../../../../api/src/main/cpp/org/apache/plc4x/cpp/api/PlcConnection.h" +#include + +using namespace org::apache::plc4x::cpp::api; + +namespace org +{ + namespace apache + { + namespace plc4x + { + namespace cpp + { + namespace base + { + namespace connection + { + /** + * Base class for implementing connections. + * Per default, all operations (read, write, subscribe) are unsupported. + * Concrete implementations should override the methods indicating connection capabilities + * and for obtaining respective request builders. + */ + class AbstractPlcConnection : public PlcConnection, PlcConnectionMetadata + { + + public: + PlcConnectionMetadata& getMetadata(); + bool canRead(); + bool canWrite(); + bool canSubscribe(); + + virtual void open() = 0; + virtual void close() = 0; + virtual bool send(unsigned char* pBytesToSend, int iNumBytesToSend) = 0; + + // Todo: Check if required + //PlcReadRequest.Builder readRequestBuilder(); + // PlcWriteRequest.Builder writeRequestBuilder(); + // PlcSubscriptionRequest.Builder subscriptionRequestBuilder(); + // PlcUnsubscriptionRequest.Builder nsubscriptionRequestBuilder(); + + protected: + virtual void onReceive(const boost::system::error_code& errorCode, std::size_t bytes_transferred) = 0; + private: + + }; + } + } + } + } + } +} + +#endif + diff --git a/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/connection/ChannelFactory.cpp b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/connection/ChannelFactory.cpp new file mode 100644 index 00000000000..129dbb203b1 --- /dev/null +++ b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/connection/ChannelFactory.cpp @@ -0,0 +1,39 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +*/ + +#include "ChannelFactory.h" + +namespace org +{ + namespace apache + { + namespace plc4x + { + namespace cpp + { + namespace base + { + namespace connection + { + } + } + } + } + } +} diff --git a/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/connection/ChannelFactory.h b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/connection/ChannelFactory.h new file mode 100644 index 00000000000..b44fa0a4da4 --- /dev/null +++ b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/connection/ChannelFactory.h @@ -0,0 +1,59 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +*/ + +#ifndef _CHANNEL_FACTORY +#define _CHANNEL_FACTORY + +#include +#include +#include +#include + +#include + +using namespace boost::asio; +using namespace boost::asio::ip; +using boost::asio::ip::address; + +namespace org +{ + namespace apache + { + namespace plc4x + { + namespace cpp + { + namespace base + { + namespace connection + { + class ChannelFactory + { + + public: + virtual tcp::socket* createChannel() = 0; + }; + } + } + } + } + } +} + +#endif \ No newline at end of file diff --git a/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/connection/DefaultPlcFieldHandler.cpp b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/connection/DefaultPlcFieldHandler.cpp new file mode 100644 index 00000000000..af769a39952 --- /dev/null +++ b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/connection/DefaultPlcFieldHandler.cpp @@ -0,0 +1,111 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +*/ + +#include "DefaultPlcFieldHandler.h" + +namespace org +{ + namespace apache + { + namespace plc4x + { + namespace cpp + { + namespace base + { + namespace connection + { + BaseDefaultFieldItem* DefaultPlcFieldhandler::encodeBoolean(PlcField field, std::vector values) + { + throw new PlcRuntimeException("Invalid encoder for type "/*Todo: +std::string((field)*/); + } + + BaseDefaultFieldItem* DefaultPlcFieldhandler::encodeByte(PlcField field, std::vector) + { + throw new PlcRuntimeException("Invalid encoder for type "/* Todo: + field*/); + } + + BaseDefaultFieldItem* DefaultPlcFieldhandler::encodeShort(PlcField field, std::vector values) + { + throw new PlcRuntimeException("Invalid encoder for type "/* + field*/); + } + + BaseDefaultFieldItem* DefaultPlcFieldhandler::encodeInteger(PlcField field, std::vector values) + { + throw new PlcRuntimeException("Invalid encoder for type "/* + field*/); + } + + BaseDefaultFieldItem* DefaultPlcFieldhandler::encodeBigInteger(PlcField field, std::vector) + { + throw new PlcRuntimeException("Invalid encoder for type "/* + field*/); + } + + BaseDefaultFieldItem* DefaultPlcFieldhandler::encodeLong(PlcField field, std::vector) + { + throw new PlcRuntimeException("Invalid encoder for type "/* + field*/); + } + + BaseDefaultFieldItem* DefaultPlcFieldhandler::encodeFloat(PlcField field, std::vector) + { + throw new PlcRuntimeException("Invalid encoder for type " /*+ field*/); + + } + + BaseDefaultFieldItem* DefaultPlcFieldhandler::encodeBigDecimal(PlcField field, std::vector values) + { + throw new PlcRuntimeException("Invalid encoder for type "/* + field*/); + } + + BaseDefaultFieldItem* DefaultPlcFieldhandler::encodeDouble(PlcField field, std::vector) + { + throw new PlcRuntimeException("Invalid encoder for type "/* + field*/); + } + + BaseDefaultFieldItem* DefaultPlcFieldhandler::encodeString(PlcField field, std::vector values) + { + throw new PlcRuntimeException("Invalid encoder for type "/* + field*/); + } + + BaseDefaultFieldItem* DefaultPlcFieldhandler::encodeTime(PlcField field, std::vector values) + { + throw new PlcRuntimeException("Invalid encoder for type "/* + field*/); + } + + BaseDefaultFieldItem* DefaultPlcFieldhandler::encodeDate(PlcField field, std::vector values) + { + throw new PlcRuntimeException("Invalid encoder for type "/* + field*/); + } + + BaseDefaultFieldItem* DefaultPlcFieldhandler::encodeDateTime(PlcField field, std::vector values) + { + throw new PlcRuntimeException("Invalid encoder for type "/* + field*/); + } + + BaseDefaultFieldItem* DefaultPlcFieldhandler::encodeByteArray(PlcField field, std::vector values) + { + throw new PlcRuntimeException("Invalid encoder for type "/* + field*/); + } + } + } + } + } + } +} + + diff --git a/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/connection/DefaultPlcFieldHandler.h b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/connection/DefaultPlcFieldHandler.h new file mode 100644 index 00000000000..7cfad354031 --- /dev/null +++ b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/connection/DefaultPlcFieldHandler.h @@ -0,0 +1,96 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +*/ + +#ifndef _DEFAULT_PLC_FIELD_HANDLER +#define _DEFAULT_PLC_FIELD_HANDLER + +#include +#include "../../../../../../../../../../../../api/src/main/cpp/org/apache/plc4x/cpp/api/PlcConnection.h" +#include +#include +#include +#include +#include +#include + +#include "../../../../../../../../../../../../api/src/main/cpp/org/apache/plc4x/cpp/api/model/PlcField.h" +#include "PlcFieldHandler.h" +#include "../messages/items/BaseDefaultFieldItem.h" + +using namespace org::apache::plc4x::cpp::api::model; +using namespace org::apache::plc4x::cpp::base::messages::items; + +namespace org +{ + namespace apache + { + namespace plc4x + { + namespace cpp + { + namespace base + { + namespace connection + { + /** + * Base Implementation of {@link PlcFieldHandler} which throws a {@link PlcRuntimeException} for all + * encodeXXX methods. + */ + class DefaultPlcFieldhandler : public PlcFieldHandler + { + + public: + + BaseDefaultFieldItem* encodeBoolean(PlcField plcField, std::vector pValues) override; + + BaseDefaultFieldItem* encodeByte(PlcField plcField, std::vector pValues) override; + + BaseDefaultFieldItem* encodeShort(PlcField plcField, std::vector pValues) override; + + BaseDefaultFieldItem* encodeInteger(PlcField plcField, std::vector pValues) override; + + BaseDefaultFieldItem* encodeBigInteger(PlcField plcField, std::vector pValues) override; + + BaseDefaultFieldItem* encodeLong(PlcField plcField, std::vector pValues) override; + + BaseDefaultFieldItem* encodeFloat(PlcField plcField, std::vector pValues) override; + + BaseDefaultFieldItem* encodeBigDecimal(PlcField plcField,std::vector pValues) override; + + BaseDefaultFieldItem* encodeDouble(PlcField plcField, std::vector pValues) override; + + BaseDefaultFieldItem* encodeString(PlcField plcField, std::vector pValues) override; + + BaseDefaultFieldItem* encodeTime(PlcField plcField, std::vector pValues) override; + + BaseDefaultFieldItem* encodeDate(PlcField plcField, std::vector pValues) override; + + BaseDefaultFieldItem* encodeDateTime(PlcField plcField, std::vector pValues) override; + + BaseDefaultFieldItem* encodeByteArray(PlcField plcField, std::vector pValues) override; + + }; + } + } + } + } + } +} + +#endif \ No newline at end of file diff --git a/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/connection/PlcFieldHandler.cpp b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/connection/PlcFieldHandler.cpp new file mode 100644 index 00000000000..71f739b47b2 --- /dev/null +++ b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/connection/PlcFieldHandler.cpp @@ -0,0 +1,39 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +*/ + +#include "PlcFieldHandler.h" + +namespace org +{ + namespace apache + { + namespace plc4x + { + namespace cpp + { + namespace base + { + namespace connection + { + } + } + } + } + } +} diff --git a/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/connection/PlcFieldHandler.h b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/connection/PlcFieldHandler.h new file mode 100644 index 00000000000..1d166d7e40c --- /dev/null +++ b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/connection/PlcFieldHandler.h @@ -0,0 +1,99 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +*/ + +#ifndef _PLC_FIELD_HANDLER +#define _PLC_FIELD_HANDLER + +#include +#include "../../../../../../../../../../../../api/src/main/cpp/org/apache/plc4x/cpp/api/PlcConnection.h" +#include +#include +#include + +#include "../../../../../../../../../../../../api/src/main/cpp/org/apache/plc4x/cpp/api/model/PlcField.h" +#include "../messages/items/BaseDefaultFieldItem.h" + +using namespace org::apache::plc4x::cpp::api::model; +using namespace org::apache::plc4x::cpp::base::messages; +using namespace org::apache::plc4x::cpp::base::messages::items; +using namespace boost::multiprecision; + + +namespace org +{ + namespace apache + { + namespace plc4x + { + namespace cpp + { + namespace base + { + namespace connection + { + /** + * Base class for implementing connections. + * Per default, all operations (read, write, subscribe) are unsupported. + * Concrete implementations should override the methods indicating connection capabilities + * and for obtaining respective request builders. + */ + class PlcFieldHandler + { + + public: + + virtual PlcField createField(std::string strFieldQuery) = 0; + + virtual BaseDefaultFieldItem* encodeBoolean(PlcField plcField, std::vector pValues) = 0; + + virtual BaseDefaultFieldItem* encodeByte(PlcField plcField, std::vector pValues)= 0; + + virtual BaseDefaultFieldItem* encodeShort(PlcField plcField, std::vector pValues) = 0; + + virtual BaseDefaultFieldItem* encodeInteger(PlcField plcField, std::vector pValues) = 0; + + virtual BaseDefaultFieldItem* encodeBigInteger(PlcField plcField,std::vector pValues) = 0; + + virtual BaseDefaultFieldItem* encodeLong(PlcField plcField, std::vector pValues) = 0; + + virtual BaseDefaultFieldItem* encodeFloat(PlcField plcField, std::vector pValues) = 0; + + virtual BaseDefaultFieldItem< cpp_dec_float_100>* encodeBigDecimal(PlcField plcField, std::vector pValues) = 0; + + virtual BaseDefaultFieldItem* encodeDouble(PlcField plcField, std::vector pValues) = 0; + + virtual BaseDefaultFieldItem* encodeString(PlcField plcField, std::vector pValues) = 0; + + virtual BaseDefaultFieldItem* encodeTime(PlcField plcField, std::vector pValues) = 0; + + virtual BaseDefaultFieldItem* encodeDate(PlcField plcField, std::vector pValues) = 0; + + virtual BaseDefaultFieldItem* encodeDateTime(PlcField plcField, std::vector pValues)= 0; + + virtual BaseDefaultFieldItem* encodeByteArray(PlcField fieplcFieldld,std::vector pValues) = 0; + + }; + } + } + } + } + } +} + +#endif \ No newline at end of file diff --git a/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/events/ConnectEvent.cpp b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/events/ConnectEvent.cpp new file mode 100644 index 00000000000..585eae38bb5 --- /dev/null +++ b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/events/ConnectEvent.cpp @@ -0,0 +1,39 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +*/ + +#include "ConnectEvent.h" + +namespace org +{ + namespace apache + { + namespace plc4x + { + namespace cpp + { + namespace base + { + namespace events + { + } + } + } + } + } +} diff --git a/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/events/ConnectEvent.h b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/events/ConnectEvent.h new file mode 100644 index 00000000000..77732dd940c --- /dev/null +++ b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/events/ConnectEvent.h @@ -0,0 +1,48 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +*/ + +#ifndef _CONNECT_EVENT +#define _CONNECT_EVENT + +#include + +namespace org +{ + namespace apache + { + namespace plc4x + { + namespace cpp + { + namespace base + { + namespace events + { + + class ConnectEvent + { + }; + } + } + } + } + } +} + +#endif diff --git a/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/events/ConnectedEvent.cpp b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/events/ConnectedEvent.cpp new file mode 100644 index 00000000000..84b5e4a6bf2 --- /dev/null +++ b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/events/ConnectedEvent.cpp @@ -0,0 +1,39 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +*/ + +#include "ConnectedEvent.h" + +namespace org +{ + namespace apache + { + namespace plc4x + { + namespace cpp + { + namespace base + { + namespace events + { + } + } + } + } + } +} diff --git a/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/events/ConnectedEvent.h b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/events/ConnectedEvent.h new file mode 100644 index 00000000000..315b9c6286f --- /dev/null +++ b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/events/ConnectedEvent.h @@ -0,0 +1,47 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +*/ + +#ifndef _CONNECTED_EVENT +#define _CONNECTED_EVENT + +namespace org +{ + namespace apache + { + namespace plc4x + { + namespace cpp + { + namespace base + { + namespace events + { + + class ConnectedEvent + { + }; + } + } + } + } + } +} + +#endif + diff --git a/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/DefaultPlcReadRequest.cpp b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/DefaultPlcReadRequest.cpp new file mode 100644 index 00000000000..21005b7c0b5 --- /dev/null +++ b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/DefaultPlcReadRequest.cpp @@ -0,0 +1,122 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +*/ + +#include "DefaultPlcReadRequest.h" + +using namespace org::apache::plc4x::cpp::api::model; + +namespace org +{ + namespace apache + { + namespace plc4x + { + namespace cpp + { + namespace base + { + namespace messages + { + // ========================================================= + DefaultPlcReadRequest::DefaultPlcReadRequest() + { + } + + // ========================================================= + DefaultPlcReadRequest::DefaultPlcReadRequest(PlcReader* reader, std::map fields) + { + this->_reader = reader; + this->_fields = fields; + } + + // ========================================================== + int DefaultPlcReadRequest::getNumberOfFields() + { + return _fields.size(); + } + + // ========================================================= + PlcField* DefaultPlcReadRequest::getField(std::string name) + { + // sgl: check 1st, whether the key is contained in vector + // (otherwise an exception is thrown)... + std::map::iterator iterator = _fields.find(name); + + if (iterator == _fields.end()) + { + return nullptr; + } + + return &(iterator->second); + + } + + // ====================================================== + std::map DefaultPlcReadRequest::getNamedFields() + { + // Todo: + /*return fields.entrySet() + .stream() + .map(stringPlcFieldEntry->Pair.of(stringPlcFieldEntry.getKey(), stringPlcFieldEntry.getValue())) + .collect(Collectors.toCollection(LinkedList::new)); +*/ + return std::map(); + } + + // ==================================================== + PlcReader* DefaultPlcReadRequest::getReader() + { + return _reader; + } + + // ===================================================== + std::vector DefaultPlcReadRequest::getFields() + { + // TODO: check if already exists... + std::pair me; + std::vector vNames; + + BOOST_FOREACH(me, _fields) + { + vNames.push_back(me.second); + } + + return vNames; + } + + // ========================================================= + std::vector DefaultPlcReadRequest::getFieldNames() + { + // TODO: check if already exists... + std::pair me; + std::vector vNames; + + BOOST_FOREACH(me, _fields) + { + vNames.push_back(me.first); + } + + return vNames; + } + } + } + } + } + } +} diff --git a/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/DefaultPlcReadRequest.h b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/DefaultPlcReadRequest.h new file mode 100644 index 00000000000..f6047f19c21 --- /dev/null +++ b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/DefaultPlcReadRequest.h @@ -0,0 +1,81 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +*/ + +#ifndef _DEFAULT_PLC_READ_REQUEST +#define _DEFAULT_PLC_READ_REQUEST + +#include "InternalPlcReadRequest.h" +#include "InternalPlcFieldRequest.h" +#include "PlcReader.h" +#include "../../../../../../../../../../../../api/src/main/cpp/org/apache/plc4x/cpp/api/model/PlcField.h" + +#include +#include + +using namespace org::apache::plc4x::cpp::api::messages; + + +namespace org +{ + namespace apache + { + namespace plc4x + { + namespace cpp + { + namespace base + { + namespace messages + { + + class DefaultPlcReadRequest : public InternalPlcReadRequest //, public InternalPlcFieldRequest + { + public: + // Todo: + /*CompletableFuture execute() + { + return reader.read(this); + }*/ + + // Todo: implement java Builder-pattern for C++ + + DefaultPlcReadRequest(PlcReader* reader, std::map fields); + int getNumberOfFields(); + std::vector getFieldNames(); + PlcField* getField(std::string name); + std::vector getFields(); + std::map getNamedFields(); + + protected: + PlcReader* getReader(); + + + private: + DefaultPlcReadRequest(); + PlcReader* _reader; + std::map _fields; + }; + } + } + } + } + } +} + +#endif \ No newline at end of file diff --git a/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/DefaultPlcWriteRequest.cpp b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/DefaultPlcWriteRequest.cpp new file mode 100644 index 00000000000..bccc0c34211 --- /dev/null +++ b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/DefaultPlcWriteRequest.cpp @@ -0,0 +1,120 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +*/ + +#include "DefaultPlcReadRequest.h" + +namespace org +{ + namespace apache + { + namespace plc4x + { + namespace cpp + { + namespace base + { + namespace messages + { + // ========================================================= + DefaultPlcReadRequest::DefaultPlcReadRequest() + { + } + + // ========================================================= + DefaultPlcReadRequest::DefaultPlcReadRequest(PlcReader* reader, std::map fields) + { + this->_reader = reader; + this->_fields = fields; + } + + // ========================================================== + int DefaultPlcReadRequest::getNumberOfFields() + { + return _fields.size(); + } + + // ========================================================= + PlcField* DefaultPlcReadRequest::getField(std::string name) + { + // sgl: check 1st, whether the key is contained in vector + // (otherwise an exception is thrown)... + std::map::iterator iterator = _fields.find(name); + + if (iterator == _fields.end()) + { + return nullptr; + } + + return &(iterator->second); + + } + + // ====================================================== + std::map DefaultPlcReadRequest::getNamedFields() + { + // Todo: + /*return fields.entrySet() + .stream() + .map(stringPlcFieldEntry->Pair.of(stringPlcFieldEntry.getKey(), stringPlcFieldEntry.getValue())) + .collect(Collectors.toCollection(LinkedList::new)); +*/ + return std::map(); + } + + // ==================================================== + PlcReader* DefaultPlcReadRequest::getReader() + { + return _reader; + } + + // ===================================================== + std::vector DefaultPlcReadRequest::getFields() + { + // TODO: check if already exists... + std::pair me; + std::vector vNames; + + BOOST_FOREACH(me, _fields) + { + vNames.push_back(me.second); + } + + return vNames; + } + + // ========================================================= + std::vector DefaultPlcReadRequest::getFieldNames() + { + // TODO: check if already exists... + std::pair me; + std::vector vNames; + + BOOST_FOREACH(me, _fields) + { + vNames.push_back(me.first); + } + + return vNames; + } + } + } + } + } + } +} diff --git a/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/DefaultPlcWriteRequest.h b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/DefaultPlcWriteRequest.h new file mode 100644 index 00000000000..163c64b8791 --- /dev/null +++ b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/DefaultPlcWriteRequest.h @@ -0,0 +1,81 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +*/ + +#ifndef _DEFAULT_PLC_WRITE_REQUEST +#define _DEFAULT_PLC_WRITE_REQUEST + +#include "InternalPlcWriteRequest.h" +#include "InternalPlcFieldRequest.h" +#include "PlcWriter.h" + +#include +#include + +using namespace org::apache::plc4x::cpp::api::messages; + + +namespace org +{ + namespace apache + { + namespace plc4x + { + namespace cpp + { + namespace base + { + namespace messages + { + + class DefaultPlcWriteRequest : public InternalPlcWriteRequest + { + public: + // Todo: + /*CompletableFuture execute() + { + return reader.read(this); + }*/ + + // Todo: implement java Builder-pattern for C++ + + DefaultPlcWriteRequest(PlcWriter* writer, std::map fields); + int getNumberOfFields(); + std::vector getFieldNames(); + PlcField* getField(std::string name); + std::vector getFields(); + std::map getNamedFields(); + // Todo: implement callback to: execute() { _writer.write(this); } + + protected: + PlcWriter* getWriter(); + + + private: + DefaultPlcWriteRequest(); + PlcWriter* _writer; + std::map _fields; + }; + } + } + } + } + } +} + +#endif \ No newline at end of file diff --git a/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/InternalPlcFieldRequest.cpp b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/InternalPlcFieldRequest.cpp new file mode 100644 index 00000000000..4ebe4efb5fc --- /dev/null +++ b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/InternalPlcFieldRequest.cpp @@ -0,0 +1,42 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +*/ + +#include "InternalPlcFieldRequest.h" + +namespace org +{ + namespace apache + { + namespace plc4x + { + namespace cpp + { + namespace base + { + namespace messages + { + InternalPlcFieldRequest::InternalPlcFieldRequest() + { + } + } + } + } + } + } +} diff --git a/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/InternalPlcFieldRequest.h b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/InternalPlcFieldRequest.h new file mode 100644 index 00000000000..a772d4c8c8e --- /dev/null +++ b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/InternalPlcFieldRequest.h @@ -0,0 +1,54 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +*/ + +#ifndef _INTERNAL_PLC_FIELD_REQUEST +#define _INTERNAL_PLC_FIELD_REQUEST + +#include "InternalPlcRequest.h" +#include "../../../../../../../../../../../../api/src/main/cpp/org/apache/plc4x/cpp/api/messages/PlcFieldRequest.h" + +#include + +namespace org +{ + namespace apache + { + namespace plc4x + { + namespace cpp + { + namespace base + { + namespace messages + { + + class InternalPlcFieldRequest : public InternalPlcRequest, PlcFieldRequest + { + public: + virtual std::map getNamedFields() = 0; + InternalPlcFieldRequest(); + }; + } + } + } + } + } +} + +#endif \ No newline at end of file diff --git a/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/InternalPlcFieldResponse.cpp b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/InternalPlcFieldResponse.cpp new file mode 100644 index 00000000000..4aa84d7a8e8 --- /dev/null +++ b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/InternalPlcFieldResponse.cpp @@ -0,0 +1,39 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +*/ + +#include "InternalPlcFieldResponse.h" + +namespace org +{ + namespace apache + { + namespace plc4x + { + namespace cpp + { + namespace base + { + namespace messages + { + } + } + } + } + } +} diff --git a/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/InternalPlcFieldResponse.h b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/InternalPlcFieldResponse.h new file mode 100644 index 00000000000..04cee487c1d --- /dev/null +++ b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/InternalPlcFieldResponse.h @@ -0,0 +1,53 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +*/ + +#ifndef _INTERNAL_PLC_FIELD_RESPONSE +#define _INTERNAL_PLC_FIELD_RESPONSE + +#include "../../../../../../../../../../../../api/src/main/cpp/org/apache/plc4x/cpp/api/messages/PlcFieldResponse.h" + +using namespace org::apache::plc4x::cpp::api::messages; + + +namespace org +{ + namespace apache + { + namespace plc4x + { + namespace cpp + { + namespace base + { + namespace messages + { + + class InternalPlcFieldResponse : public PlcFieldResponse + { + public: + + }; + } + } + } + } + } +} + +#endif \ No newline at end of file diff --git a/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/InternalPlcProprietaryRequest.cpp b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/InternalPlcProprietaryRequest.cpp new file mode 100644 index 00000000000..52e079509e6 --- /dev/null +++ b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/InternalPlcProprietaryRequest.cpp @@ -0,0 +1,40 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +*/ + +#include "InternalPlcProprietaryRequest.h" + +namespace org +{ + namespace apache + { + namespace plc4x + { + namespace cpp + { + namespace base + { + namespace messages + { + + } + } + } + } + } +} diff --git a/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/InternalPlcProprietaryRequest.h b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/InternalPlcProprietaryRequest.h new file mode 100644 index 00000000000..cf31f8546ae --- /dev/null +++ b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/InternalPlcProprietaryRequest.h @@ -0,0 +1,52 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +*/ + +#ifndef _INTERNAL_PLC_PROPRIETARY_REQUEST +#define _INTERNAL_PLC_PROPRIETARY_REQUEST + +#include "PlcProprietaryRequest.h" +#include "InternalPlcRequest.h" + +using namespace org::apache::plc4x::cpp::api::messages; + +namespace org +{ + namespace apache + { + namespace plc4x + { + namespace cpp + { + namespace base + { + namespace messages + { + //template + class InternalPlcProprietaryRequest : public PlcProprietaryRequest, public InternalPlcRequest + { + public: + }; + } + } + } + } + } +} + +#endif \ No newline at end of file diff --git a/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/InternalPlcProprietaryResponse.cpp b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/InternalPlcProprietaryResponse.cpp new file mode 100644 index 00000000000..ce9c1da3380 --- /dev/null +++ b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/InternalPlcProprietaryResponse.cpp @@ -0,0 +1,40 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +*/ + +#include "InternalPlcProprietaryResponse.h" + +namespace org +{ + namespace apache + { + namespace plc4x + { + namespace cpp + { + namespace base + { + namespace messages + { + + } + } + } + } + } +} diff --git a/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/InternalPlcProprietaryResponse.h b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/InternalPlcProprietaryResponse.h new file mode 100644 index 00000000000..593c398c869 --- /dev/null +++ b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/InternalPlcProprietaryResponse.h @@ -0,0 +1,52 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +*/ + +#ifndef _INTERNAL_PLC_PROPRIETARY_RESPONSE +#define _INTERNAL_PLC_PROPRIETARY_RESPONSE + +#include "PlcProprietaryResponse.h" +#include "InternalPlcRequest.h" + +using namespace org::apache::plc4x::cpp::api::messages; + +namespace org +{ + namespace apache + { + namespace plc4x + { + namespace cpp + { + namespace base + { + namespace messages + { + //template + class InternalPlcProprietaryResponse : public PlcProprietaryResponse, public InternalPlcRequest + { + public: + }; + } + } + } + } + } +} + +#endif \ No newline at end of file diff --git a/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/InternalPlcReadRequest.cpp b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/InternalPlcReadRequest.cpp new file mode 100644 index 00000000000..22f3abb3ad4 --- /dev/null +++ b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/InternalPlcReadRequest.cpp @@ -0,0 +1,39 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +*/ + +#include "InternalPlcReadRequest.h" + +namespace org +{ + namespace apache + { + namespace plc4x + { + namespace cpp + { + namespace base + { + namespace messages + { + } + } + } + } + } +} diff --git a/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/InternalPlcReadRequest.h b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/InternalPlcReadRequest.h new file mode 100644 index 00000000000..5641ed756f4 --- /dev/null +++ b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/InternalPlcReadRequest.h @@ -0,0 +1,54 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +*/ + +#ifndef _INTERNAL_PLC_READ_REQUEST +#define _INTERNAL_PLC_READ_REQUEST + +#include "../../../../../../../../../../../../api/src/main/cpp/org/apache/plc4x/cpp/api/messages/PlcReadRequest.h" +#include "InternalPlcFieldRequest.h" + +using namespace org::apache::plc4x::cpp::api::messages; + + +namespace org +{ + namespace apache + { + namespace plc4x + { + namespace cpp + { + namespace base + { + namespace messages + { + + class InternalPlcReadRequest : public PlcReadRequest, public InternalPlcFieldRequest + { + public: + + }; + } + } + } + } + } +} + +#endif \ No newline at end of file diff --git a/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/InternalPlcRequest.cpp b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/InternalPlcRequest.cpp new file mode 100644 index 00000000000..836a78eadbc --- /dev/null +++ b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/InternalPlcRequest.cpp @@ -0,0 +1,39 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +*/ + +#include "InternalPlcRequest.h" + +namespace org +{ + namespace apache + { + namespace plc4x + { + namespace cpp + { + namespace base + { + namespace messages + { + } + } + } + } + } +} diff --git a/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/InternalPlcRequest.h b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/InternalPlcRequest.h new file mode 100644 index 00000000000..e7e22bb2459 --- /dev/null +++ b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/InternalPlcRequest.h @@ -0,0 +1,53 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +*/ + +#ifndef _INTERNAL_PLC_REQUEST +#define _INTERNAL_PLC_REQUEST + +#include "../../../../../../../../../../../../api/src/main/cpp/org/apache/plc4x/cpp/api/messages/PlcRequest.h" + +using namespace org::apache::plc4x::cpp::api::messages; + + +namespace org +{ + namespace apache + { + namespace plc4x + { + namespace cpp + { + namespace base + { + namespace messages + { + + class InternalPlcRequest : public PlcRequest + { + public: + + }; + } + } + } + } + } +} + +#endif \ No newline at end of file diff --git a/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/InternalPlcResponse.cpp b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/InternalPlcResponse.cpp new file mode 100644 index 00000000000..4f5b49f717c --- /dev/null +++ b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/InternalPlcResponse.cpp @@ -0,0 +1,39 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +*/ + +#include "InternalPlcResponse.h" + +namespace org +{ + namespace apache + { + namespace plc4x + { + namespace cpp + { + namespace base + { + namespace messages + { + } + } + } + } + } +} diff --git a/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/InternalPlcResponse.h b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/InternalPlcResponse.h new file mode 100644 index 00000000000..1f6baee0d95 --- /dev/null +++ b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/InternalPlcResponse.h @@ -0,0 +1,53 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +*/ + +#ifndef _INTERNAL_PLC_RESPONSE +#define _INTERNAL_PLC_RESPONSE + +#include "../../../../../../../../../../../../api/src/main/cpp/org/apache/plc4x/cpp/api/messages/PlcResponse.h" + +using namespace org::apache::plc4x::cpp::api::messages; + + +namespace org +{ + namespace apache + { + namespace plc4x + { + namespace cpp + { + namespace base + { + namespace messages + { + + class InternalPlcResponse : public PlcResponse + { + public: + + }; + } + } + } + } + } +} + +#endif \ No newline at end of file diff --git a/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/InternalPlcWriteRequest.cpp b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/InternalPlcWriteRequest.cpp new file mode 100644 index 00000000000..e0665cbca6b --- /dev/null +++ b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/InternalPlcWriteRequest.cpp @@ -0,0 +1,39 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +*/ + +#include "InternalPlcWriteRequest.h" + +namespace org +{ + namespace apache + { + namespace plc4x + { + namespace cpp + { + namespace base + { + namespace messages + { + } + } + } + } + } +} diff --git a/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/InternalPlcWriteRequest.h b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/InternalPlcWriteRequest.h new file mode 100644 index 00000000000..9d5e0fc7bef --- /dev/null +++ b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/InternalPlcWriteRequest.h @@ -0,0 +1,60 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +*/ + +#ifndef _INTERNAL_PLC_WRITE_REQUEST +#define _INTERNAL_PLC_WRITE_REQUEST + +#include "../../../../../../../../../../../../api/src/main/cpp/org/apache/plc4x/cpp/api/messages/PlcWriteRequest.h" +#include "./items/BaseDefaultFieldItem.h" +#include "InternalPlcFieldRequest.h" +#include +#include + +using namespace org::apache::plc4x::cpp::api::messages; +using namespace org::apache::plc4x::cpp::base::messages::items; + + +namespace org +{ + namespace apache + { + namespace plc4x + { + namespace cpp + { + namespace base + { + namespace messages + { + + class InternalPlcWriteRequest : public PlcWriteRequest, public InternalPlcFieldRequest + { + public: + virtual ValueTypeObject getFieldItem(std::string name) = 0; + virtual std::vector getFieldItems(std::string name)= 0; + virtual std::tuple getNamedFieldTriples() = 0; + }; + } + } + } + } + } +} + +#endif \ No newline at end of file diff --git a/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/PlcProprietaryRequest.cpp b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/PlcProprietaryRequest.cpp new file mode 100644 index 00000000000..abe5335ad3f --- /dev/null +++ b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/PlcProprietaryRequest.cpp @@ -0,0 +1,39 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +*/ + +#include "PlcProprietaryRequest.h" + +namespace org +{ + namespace apache + { + namespace plc4x + { + namespace cpp + { + namespace base + { + namespace messages + { + } + } + } + } + } +} diff --git a/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/PlcProprietaryRequest.h b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/PlcProprietaryRequest.h new file mode 100644 index 00000000000..d381c3e50c4 --- /dev/null +++ b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/PlcProprietaryRequest.h @@ -0,0 +1,54 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +*/ + +#ifndef _PLC_PROPRIETARY_REQUEST +#define _PLC_PROPRIETARY_REQUEST + +#include "../../../../../../../../../../../../api/src/main/cpp/org/apache/plc4x/cpp/api/messages/REQUEST.h" +#include "../../../../../../../../../../../../api/src/main/cpp/org/apache/plc4x/cpp/api/messages/PlcRequest.h" +#include "../../../../../../../../../../../../api/src/main/cpp/org/apache/plc4x/cpp/api//messages/RequestTemplate.h" + +using namespace org::apache::plc4x::cpp::api::messages; + +namespace org +{ + namespace apache + { + namespace plc4x + { + namespace cpp + { + namespace base + { + namespace messages + { + + class PlcProprietaryRequest : public PlcRequest, public RequestTemplate + { + public: + virtual REQUEST getProprietaryRequest() = 0; + }; + } + } + } + } + } +} + +#endif \ No newline at end of file diff --git a/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/PlcProprietaryResponse.cpp b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/PlcProprietaryResponse.cpp new file mode 100644 index 00000000000..ce4074ed7fc --- /dev/null +++ b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/PlcProprietaryResponse.cpp @@ -0,0 +1,40 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +*/ + +#include "PlcProprietaryResponse.h" + +namespace org +{ + namespace apache + { + namespace plc4x + { + namespace cpp + { + namespace base + { + namespace messages + { + + } + } + } + } + } +} diff --git a/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/PlcProprietaryResponse.h b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/PlcProprietaryResponse.h new file mode 100644 index 00000000000..aa9d9d781c6 --- /dev/null +++ b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/PlcProprietaryResponse.h @@ -0,0 +1,53 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +*/ + +#ifndef _PLC_PROPRIETARY_RESPONSE +#define _PLC_PROPRIETARY_RESPONSE + +#include "../../../../../../../../../../../../api/src/main/cpp/org/apache/plc4x/cpp/api/messages/RESPONSE.h" +#include "../../../../../../../../../../../../api/src/main/cpp/org/apache/plc4x/cpp/api/messages/PlcResponse.h" +#include "../../../../../../../../../../../../api/src/main/cpp/org/apache/plc4x/cpp/api/messages/ResponseTemplate.h" + +using namespace org::apache::plc4x::cpp::api::messages; + +namespace org +{ + namespace apache + { + namespace plc4x + { + namespace cpp + { + namespace base + { + namespace messages + { + //template + class PlcProprietaryResponse : public PlcResponse, public ResponseTemplate + { + public: + }; + } + } + } + } + } +} + +#endif \ No newline at end of file diff --git a/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/PlcReader.cpp b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/PlcReader.cpp new file mode 100644 index 00000000000..c88119fb1ec --- /dev/null +++ b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/PlcReader.cpp @@ -0,0 +1,39 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +*/ + +#include "PlcReader.h" + +namespace org +{ + namespace apache + { + namespace plc4x + { + namespace cpp + { + namespace base + { + namespace messages + { + } + } + } + } + } +} diff --git a/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/PlcReader.h b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/PlcReader.h new file mode 100644 index 00000000000..298ae375976 --- /dev/null +++ b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/PlcReader.h @@ -0,0 +1,49 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +*/ + +#ifndef _PLC_READER +#define _PLC_READER + +namespace org +{ + namespace apache + { + namespace plc4x + { + namespace cpp + { + namespace base + { + namespace messages + { + + class PlcReader + { + // Todo: implement java-CompletableFuture + public: + + }; + } + } + } + } + } +} + +#endif \ No newline at end of file diff --git a/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/PlcWriter.cpp b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/PlcWriter.cpp new file mode 100644 index 00000000000..6d1d5373a48 --- /dev/null +++ b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/PlcWriter.cpp @@ -0,0 +1,39 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +*/ + +#include "PlcWriter.h" + +namespace org +{ + namespace apache + { + namespace plc4x + { + namespace cpp + { + namespace base + { + namespace messages + { + } + } + } + } + } +} diff --git a/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/PlcWriter.h b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/PlcWriter.h new file mode 100644 index 00000000000..a24e19afbd1 --- /dev/null +++ b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/PlcWriter.h @@ -0,0 +1,55 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +*/ + +#ifndef _PLC_WRITER +#define _PLC_WRITER + +namespace org +{ + namespace apache + { + namespace plc4x + { + namespace cpp + { + namespace base + { + namespace messages + { + + class PlcWriter + { + /** + * Writes a given value to a PLC. + * + * @param writeRequest object describing the type, location and value that whould be written. + * @return a {@link CompletableFuture} giving async access to the response of the write operation. + */ + // Todo: CompletableFuture write(PlcWriteRequest writeRequest); + public: + + }; + } + } + } + } + } +} + +#endif \ No newline at end of file diff --git a/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/BaseDefaultFieldItem.cpp b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/BaseDefaultFieldItem.cpp new file mode 100644 index 00000000000..e90ddd0545e --- /dev/null +++ b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/BaseDefaultFieldItem.cpp @@ -0,0 +1,43 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +*/ + +#include "BaseDefaultFieldItem.h" + +namespace org +{ + namespace apache + { + namespace plc4x + { + namespace cpp + { + namespace base + { + namespace messages + { + namespace items + { + } + + } + } + } + } + } +} diff --git a/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/BaseDefaultFieldItem.h b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/BaseDefaultFieldItem.h new file mode 100644 index 00000000000..56db3e91994 --- /dev/null +++ b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/BaseDefaultFieldItem.h @@ -0,0 +1,136 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +*/ + +#ifndef _BASE_DEFAULT_FIELD_ITEM +#define _BASE_DEFAULT_FIELD_ITEM + +#include +#include +#include +#include +#include + +#include "../../../../../../../../../../../../../api/src/main/cpp/org/apache/plc4x/cpp/api/exceptions/PlcIncompatibleDatatypeException.h" +#include "../../../../../../../../../../../../../api/src/main/cpp/org/apache/plc4x/cpp/api/exceptions/PlcFieldRangeException.h" +#include "../../../../../../../../../../../../../api/src/main/cpp/org/apache/plc4x/cpp/api/types/ValueTypeObject.h" + +#include + +using namespace org::apache::plc4x::cpp::api::exceptions; +using namespace org::apache::plc4x::cpp::api::types; + + +namespace org +{ + namespace apache + { + namespace plc4x + { + namespace cpp + { + namespace base + { + namespace messages + { + namespace items + { + template + class BaseDefaultFieldItem : public ValueTypeObject + { + + public: + inline int getNumberOfValues() { return _values.length; } + virtual T getObject(int index) = 0; + inline bool isValidBoolean(int index) { return false; } + inline bool getBoolean(int index) { throw new PlcIncompatibleDatatypeException("bool", index); } + inline bool isValidByte(int index) { return false; } + inline char getByte(int index) { throw new PlcIncompatibleDatatypeException("byte", index); } + inline bool isValidShort(int index) { return false; } + inline short getShort(int index) { throw new PlcIncompatibleDatatypeException("short", index); } + inline bool isValidInteger(int index) { return false; } + inline int getInteger(int index) { throw new PlcIncompatibleDatatypeException("int", index); } + inline bool isValidLong(int index) { return false; } + inline long getLong(int index) { throw new PlcIncompatibleDatatypeException("long", index); } + inline bool isValidBigInteger(int index) { return false; } + inline long long getBigInteger(int index) { throw new PlcIncompatibleDatatypeException("long long", index); } + inline bool isValidFloat(int index) { return false; } + inline float getFloat(int index) { throw new PlcIncompatibleDatatypeException("float", index); } + inline bool isValidDouble(int index) { return false; } + inline double getDouble(int index) { throw new PlcIncompatibleDatatypeException("double", index); } + inline bool isValidBigDecimal(int index) { return false; } + inline long long getBigDecimal(int index) { throw new PlcIncompatibleDatatypeException("long long", index); } + inline bool isValidString(int index) { return false; } + inline std::string getString(int index) { throw new PlcIncompatibleDatatypeException("string", index); } + inline bool isValidTime(int index) { return false; } + inline tm* getTime(int index) { throw new PlcIncompatibleDatatypeException("tm*", index); } + inline bool isValidDate(int index) { return false; } + inline tm* getDate(int index) { throw new PlcIncompatibleDatatypeException("tm*", index); } + inline bool isValidDateTime(int index) { return false; } + inline tm* getDateTime(int index) { throw new PlcIncompatibleDatatypeException("tm*", index); } + inline bool isValidByteArray(int index) { return false; } + inline char* getByteArray(int index) { throw new PlcIncompatibleDatatypeException("char", index); } + inline std::vector* getValues() { return &_values; } + inline int hashCode() { return int_hash(_values); } // Todo: @Override + inline std::string toString() // Todo: @Override + { + return "BaseDefaultFielditem { values=" + std::string(_values) + "}"; + }; + + // Todo: add methods for unsigned data types? + + /* Todo: + @Override + bool equals(Object o) + { + if (this == o) + { + return true; + } + if (!(o instanceof BaseDefaultFieldItem)) + { + return false; + } + BaseDefaultFieldItem< ? > fieldItem = (BaseDefaultFieldItem< ? >) o; + return Arrays.equals(values, fieldItem.values); + }*/ + + protected: + //BaseDefaultFieldItem() { this._values = new array(0); } + inline BaseDefaultFieldItem(T* values) { this._values = values; } + inline T getValue(int index) + { + if ((index < 0 || (index >= _values.size()))) + { + throw new PlcFieldRangeException((_values.size() == 0) ? -1 : _values.size() - 1, index); + } + return _values[index]; + } + + std::vector _values; + }; + } + } + } + } + } + } +} + +#endif + diff --git a/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultBigDecimalFieldItem.cpp b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultBigDecimalFieldItem.cpp new file mode 100644 index 00000000000..996528282e9 --- /dev/null +++ b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultBigDecimalFieldItem.cpp @@ -0,0 +1,196 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +*/ + +#include "DefaultBigDecimalFieldItem.h" + +namespace org +{ + namespace apache + { + namespace plc4x + { + namespace cpp + { + namespace base + { + namespace messages + { + namespace items + { + // ================================================== + bool DefaultBigDecimalFieldItem::getBoolean(int index) + { + if (!isValidBoolean(index)) + { + throw new PlcIncompatibleDatatypeException("bool", index); + } + + return getValue(index) == 1; + } + + // =================================================== + bool DefaultBigDecimalFieldItem::isValidByte(int index) + { + cpp_dec_float_100 value = getValue(index); + return value <= -127 && value >= -128; + } + + // =================================================== + char DefaultBigDecimalFieldItem::getByte(int index) + { + if (!isValidByte(index)) + { + throw new PlcIncompatibleDatatypeException("char", index); + } + return (char) getValue(index); + } + + // =================================================== + bool DefaultBigDecimalFieldItem::isValidShort(int index) + { + cpp_dec_float_100 value = getValue(index); + return value >= -32768 && value <= 32767; + } + + // =================================================== + short DefaultBigDecimalFieldItem::getShort(int index) + { + if (!isValidShort(index)) + { + throw new PlcIncompatibleDatatypeException("short", index); + } + + return (short)getValue(index); + } + + // =================================================== + bool DefaultBigDecimalFieldItem::isValidInteger(int index) + { + cpp_dec_float_100 value = getValue(index); + return value >= 0 && value <= 2147483647; + } + + // =================================================== + int DefaultBigDecimalFieldItem::getInteger(int index) + { + if (!isValidInteger(index)) + { + throw new PlcIncompatibleDatatypeException("int", index); + } + + return (int)getValue(index); + } + + // =================================================== + bool DefaultBigDecimalFieldItem::isValidLong(int index) + { + cpp_dec_float_100 value = getValue(index); + return value >= -(2 ^ 63) && value <= (2 ^ 63) - 1; + } + + // =================================================== + long DefaultBigDecimalFieldItem::getLong(int index) + { + if (!isValidLong(index)) + { + throw new PlcIncompatibleDatatypeException("long", index); + } + + return (long)getValue(index); + } + + // =================================================== + bool DefaultBigDecimalFieldItem::isValidBigInteger(int index) + { + return true; + } + + // =================================================== + long long DefaultBigDecimalFieldItem::getBigInteger(int index) + { + if (!isValidBigInteger(index)) + { + throw new PlcIncompatibleDatatypeException("long long", index); + } + + // Todo: add conversion from cpp_dec_float_100 TO long long + return (long)getValue(index); + } + + // =================================================== + bool DefaultBigDecimalFieldItem::isValidFloat(int index) + { + cpp_dec_float_100 value = getValue(index); + return value >= -3.4e38 && value <= 3.4e38; + } + + // =================================================== + float DefaultBigDecimalFieldItem::getFloat(int index) + { + if (!isValidFloat(index)) + { + throw new PlcIncompatibleDatatypeException("float", index); + } + + return (float)getValue(index); + } + + // =================================================== + bool DefaultBigDecimalFieldItem::isValidDouble(int index) + { + cpp_dec_float_100 value = getValue(index); + return value >= -1.7e308 && value <= 1.7e308; + } + + // =================================================== + double DefaultBigDecimalFieldItem::getDouble(int index) + { + if (!isValidDouble(index)) + { + throw new PlcIncompatibleDatatypeException("double", index); + } + + return (double)getValue(index); + } + + // =================================================== + bool DefaultBigDecimalFieldItem::isValidBigDecimal(int index) + { + // same limits but higher precision + return isValidDouble(index); + } + + // =================================================== + cpp_dec_float_100 DefaultBigDecimalFieldItem::getBigDecimal(int index) + { + if (!isValidBigDecimal(index)) + { + throw new PlcIncompatibleDatatypeException("cpp_dec_float_100", index); + } + + return (cpp_dec_float_100)getValue(index); + } + } + + } + } + } + } + } +} diff --git a/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultBigDecimalFieldItem.h b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultBigDecimalFieldItem.h new file mode 100644 index 00000000000..14bae84f086 --- /dev/null +++ b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultBigDecimalFieldItem.h @@ -0,0 +1,83 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +*/ + +#ifndef _DEFAULT_BIG_DECIMAL_FIELD_ITEM +#define _DEFAULT_BIG_DECIMAL_FIELD_ITEM + +#include +#include "BaseDefaultFieldItem.h" + +using namespace org::apache::plc4x::cpp::api::exceptions; +using namespace boost::multiprecision; + + +namespace org +{ + namespace apache + { + namespace plc4x + { + namespace cpp + { + namespace base + { + namespace messages + { + namespace items + { + + class DefaultBigDecimalFieldItem : public BaseDefaultFieldItem + { + + public: + template + DefaultBigDecimalFieldItem(std::vector values); + + template + inline T getObject(int index) { return BaseDefaultFieldItem::getValue(index); } + inline bool isValidBoolean(int index) { return getValue(index) <= 1 && getValue(index) >= 0; } + bool getBoolean(int index); + bool isValidByte(int index); + char getByte(int index); + bool isValidShort(int index); + short getShort(int index); + bool isValidInteger(int index); + int getInteger(int index); + bool isValidLong(int index); + long getLong(int index); + bool isValidBigInteger(int index); + long long getBigInteger(int index); + bool isValidFloat(int index); + float getFloat(int index); + bool isValidDouble(int index); + double getDouble(int index); + bool isValidBigDecimal(int index); + cpp_dec_float_100 getBigDecimal(int index); + + private: + }; + } + } + } + } + } + } +} + +#endif diff --git a/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultBigIntegerFieldItem.cpp b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultBigIntegerFieldItem.cpp new file mode 100644 index 00000000000..fb1266e355b --- /dev/null +++ b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultBigIntegerFieldItem.cpp @@ -0,0 +1,201 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +*/ + +#include "DefaultBigIntegerFieldItem.h" + +namespace org +{ + namespace apache + { + namespace plc4x + { + namespace cpp + { + namespace base + { + namespace messages + { + namespace items + { + // ================================================== + bool DefaultBigIntegerFieldItem::getBoolean(int index) + { + if (!isValidBoolean(index)) + { + throw new PlcIncompatibleDatatypeException("bool", index); + } + + return getValue(index) == 1; + } + + // =================================================== + bool DefaultBigIntegerFieldItem::isValidByte(int index) + { + long long value = getValue(index); + return value <= -127 && value >= -128; + } + + // =================================================== + char DefaultBigIntegerFieldItem::getByte(int index) + { + if (!isValidByte(index)) + { + throw new PlcIncompatibleDatatypeException("char", index); + } + + long long value = getValue(index); + + return (char) getValue(index); + } + + // =================================================== + bool DefaultBigIntegerFieldItem::isValidShort(int index) + { + long long value = getValue(index); + + return value >= -32768 && value <= 32767; + } + + // =================================================== + short DefaultBigIntegerFieldItem::getShort(int index) + { + if (!isValidShort(index)) + { + throw new PlcIncompatibleDatatypeException("short", index); + } + + return (short)getValue(index); + } + + // =================================================== + bool DefaultBigIntegerFieldItem::isValidInteger(int index) + { + long long value = getValue(index); + + return value >= 0 && value <= 2147483647; + } + + // =================================================== + int DefaultBigIntegerFieldItem::getInteger(int index) + { + if (!isValidInteger(index)) + { + throw new PlcIncompatibleDatatypeException("int", index); + } + + return (int)getValue(index); + } + + // =================================================== + bool DefaultBigIntegerFieldItem::isValidLong(int index) + { + long long value = getValue(index); + + return value >= -(2 ^ 63) && value <= (2 ^ 63) - 1; + } + + // =================================================== + long DefaultBigIntegerFieldItem::getLong(int index) + { + if (!isValidLong(index)) + { + throw new PlcIncompatibleDatatypeException("long", index); + } + + return (long)getValue(index); + } + + // =================================================== + bool DefaultBigIntegerFieldItem::isValidBigInteger(int index) + { + return true; + } + + // =================================================== + long long DefaultBigIntegerFieldItem::getBigInteger(int index) + { + if (!isValidBigInteger(index)) + { + throw new PlcIncompatibleDatatypeException("long long", index); + } + + // Todo: add conversion from cpp_dec_float_100 TO InfInt + return (long)getValue(index); + } + + // =================================================== + bool DefaultBigIntegerFieldItem::isValidFloat(int index) + { + long long value = getValue(index); + return value >= -3.4e38 && value <= 3.4e38; + } + + // =================================================== + float DefaultBigIntegerFieldItem::getFloat(int index) + { + if (!isValidFloat(index)) + { + throw new PlcIncompatibleDatatypeException("float", index); + } + + return (float)getValue(index); + } + + // =================================================== + bool DefaultBigIntegerFieldItem::isValidDouble(int index) + { + long long value = getValue(index); + return value >= -1.7e308 && value <= 1.7e308; + } + + // =================================================== + double DefaultBigIntegerFieldItem::getDouble(int index) + { + if (!isValidDouble(index)) + { + throw new PlcIncompatibleDatatypeException("double", index); + } + + return (double)getValue(index); + } + + // =================================================== + bool DefaultBigIntegerFieldItem::isValidBigDecimal(int index) + { + return true; + } + + // =================================================== + cpp_dec_float_100 DefaultBigIntegerFieldItem::getBigDecimal(int index) + { + if (!isValidDouble(index)) + { + throw new PlcIncompatibleDatatypeException("cpp_dec_float_100", index); + } + + return (cpp_dec_float_100)getValue(index); + } + } + + } + } + } + } + } +} diff --git a/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultBigIntegerFieldItem.h b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultBigIntegerFieldItem.h new file mode 100644 index 00000000000..817d5344cdf --- /dev/null +++ b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultBigIntegerFieldItem.h @@ -0,0 +1,84 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +*/ + +#ifndef _DEFAULT_BIG_INTEGER_FIELD_ITEM +#define _DEFAULT_BIG_INTEGER_FIELD_ITEM + +#include +#include "BaseDefaultFieldItem.h" + +using namespace org::apache::plc4x::cpp::api::exceptions; +using namespace boost::multiprecision; + +namespace org +{ + namespace apache + { + namespace plc4x + { + namespace cpp + { + namespace base + { + namespace messages + { + namespace items + { + + class DefaultBigIntegerFieldItem : public BaseDefaultFieldItem + { + + public: + template + DefaultBigIntegerFieldItem(std::vector values); + + template + inline T getObject(int index) { return BaseDefaultFieldItem::getValue(index); } + + inline bool isValidBoolean(int index) { return getValue(index) <= 1 && getValue(index) >= 0; } + bool getBoolean(int index); + bool isValidByte(int index); + char getByte(int index); + bool isValidShort(int index); + short getShort(int index); + bool isValidInteger(int index); + int getInteger(int index); + bool isValidLong(int index); + long getLong(int index); + bool isValidBigInteger(int index); + long long getBigInteger(int index); + bool isValidFloat(int index); + float getFloat(int index); + bool isValidDouble(int index); + double getDouble(int index); + bool isValidBigDecimal(int index); + cpp_dec_float_100 getBigDecimal(int index); + + private: + }; + } + } + } + } + } + } +} + +#endif + diff --git a/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultBooleanFieldItem.cpp b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultBooleanFieldItem.cpp new file mode 100644 index 00000000000..0b695c6576a --- /dev/null +++ b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultBooleanFieldItem.cpp @@ -0,0 +1,196 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +*/ + +#include "DefaultBooleanFieldItem.h" + +namespace org +{ + namespace apache + { + namespace plc4x + { + namespace cpp + { + namespace base + { + namespace messages + { + namespace items + { + // ================================================== + bool DefaultBooleanFieldItem::getBoolean(int index) + { + if (!isValidBoolean(index)) + { + throw new PlcIncompatibleDatatypeException("bool", index); + } + + return getValue(index); + } + + // =================================================== + bool DefaultBooleanFieldItem::isValidByte(int index) + { + bool value = getValue(index); + return value <= -127 && value >= -128; + } + + // =================================================== + char DefaultBooleanFieldItem::getByte(int index) + { + if (!isValidByte(index)) + { + throw new PlcIncompatibleDatatypeException("char", index); + } + return (char) getValue(index); + } + + // =================================================== + bool DefaultBooleanFieldItem::isValidShort(int index) + { + bool value = getValue(index); + return value >= -32768 && value <= 32767; + } + + // =================================================== + short DefaultBooleanFieldItem::getShort(int index) + { + if (!isValidShort(index)) + { + throw new PlcIncompatibleDatatypeException("short", index); + } + + return (short)getValue(index); + } + + // =================================================== + bool DefaultBooleanFieldItem::isValidInteger(int index) + { + bool value = getValue(index); + return value >= 0 && value <= 2147483647; + } + + // =================================================== + int DefaultBooleanFieldItem::getInteger(int index) + { + if (!isValidInteger(index)) + { + throw new PlcIncompatibleDatatypeException("int", index); + } + + return (int)getValue(index); + } + + // =================================================== + bool DefaultBooleanFieldItem::isValidLong(int index) + { + bool value = getValue(index); + return value >= -(2 ^ 63) && value <= (2 ^ 63) - 1; + } + + // =================================================== + long DefaultBooleanFieldItem::getLong(int index) + { + if (!isValidLong(index)) + { + throw new PlcIncompatibleDatatypeException("long", index); + } + + return (long)getValue(index); + } + + // =================================================== + bool DefaultBooleanFieldItem::isValidBigInteger(int index) + { + return true; + } + + // =================================================== + long long DefaultBooleanFieldItem::getBigInteger(int index) + { + if (!isValidBigInteger(index)) + { + throw new PlcIncompatibleDatatypeException("long long", index); + } + + // Todo: add conversion from cpp_dec_float_100 TO long long + return (long)getValue(index); + } + + // =================================================== + bool DefaultBooleanFieldItem::isValidFloat(int index) + { + bool value = getValue(index); + return value >= -3.4e38 && value <= 3.4e38; + } + + // =================================================== + float DefaultBooleanFieldItem::getFloat(int index) + { + if (!isValidFloat(index)) + { + throw new PlcIncompatibleDatatypeException("float", index); + } + + return (float)getValue(index); + } + + // =================================================== + bool DefaultBooleanFieldItem::isValidDouble(int index) + { + bool value = getValue(index); + return value >= -1.7e308 && value <= 1.7e308; + } + + // =================================================== + double DefaultBooleanFieldItem::getDouble(int index) + { + if (!isValidDouble(index)) + { + throw new PlcIncompatibleDatatypeException("double", index); + } + + return (double)getValue(index); + } + + // =================================================== + bool DefaultBooleanFieldItem::isValidBigDecimal(int index) + { + // same limits but higher precision + return isValidDouble(index); + } + + // =================================================== + cpp_dec_float_100 DefaultBooleanFieldItem::getBigDecimal(int index) + { + if (!isValidBigDecimal(index)) + { + throw new PlcIncompatibleDatatypeException("cpp_dec_float_100", index); + } + + return (cpp_dec_float_100)getValue(index); + } + } + + } + } + } + } + } +} diff --git a/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultBooleanFieldItem.h b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultBooleanFieldItem.h new file mode 100644 index 00000000000..eda13a3f963 --- /dev/null +++ b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultBooleanFieldItem.h @@ -0,0 +1,80 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +*/ +#ifndef _DEFAULT_BIG_BOOLEAN_FIELD_ITEM +#define _DEFAULT_BIG_BOOLEAN_FIELD_ITEM + +#include +#include "BaseDefaultFieldItem.h" + +using namespace org::apache::plc4x::cpp::api::exceptions; +using namespace boost::multiprecision; + +namespace org +{ + namespace apache + { + namespace plc4x + { + namespace cpp + { + namespace base + { + namespace messages + { + namespace items + { + class DefaultBooleanFieldItem : public BaseDefaultFieldItem + { + + public: + template + DefaultBooleanFieldItem(std::vector values); + + template + inline T getObject(int index) { return BaseDefaultFieldItem::getValue(index); } + inline bool isValidBoolean(int index) { return true; } + bool getBoolean(int index); + bool isValidByte(int index); + char getByte(int index); + bool isValidShort(int index); + short getShort(int index); + bool isValidInteger(int index); + int getInteger(int index); + bool isValidLong(int index); + long getLong(int index); + bool isValidBigInteger(int index); + long long getBigInteger(int index); + bool isValidFloat(int index); + float getFloat(int index); + bool isValidDouble(int index); + double getDouble(int index); + bool isValidBigDecimal(int index); + cpp_dec_float_100 getBigDecimal(int index); + + private: + }; + } + } + } + } + } + } +} + +#endif diff --git a/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultByteArrayFieldItem.cpp b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultByteArrayFieldItem.cpp new file mode 100644 index 00000000000..e5957e6466e --- /dev/null +++ b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultByteArrayFieldItem.cpp @@ -0,0 +1,196 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +*/ + +#include "DefaultByteArrayFieldItem.h" + +namespace org +{ + namespace apache + { + namespace plc4x + { + namespace cpp + { + namespace base + { + namespace messages + { + namespace items + { + // ================================================== + bool DefaultByteArrayFieldItem::getBoolean(int index) + { + if (!isValidBoolean(index)) + { + throw new PlcIncompatibleDatatypeException("bool", index); + } + + return getValue(index); + } + + // =================================================== + bool DefaultByteArrayFieldItem::isValidByte(int index) + { + char value = getValue(index); + return value <= -127 && value >= -128; + } + + // =================================================== + char DefaultByteArrayFieldItem::getByte(int index) + { + if (!isValidByte(index)) + { + throw new PlcIncompatibleDatatypeException("char", index); + } + return (char) getValue(index); + } + + // =================================================== + bool DefaultByteArrayFieldItem::isValidShort(int index) + { + char value = getValue(index); + return value >= -32768 && value <= 32767; + } + + // =================================================== + short DefaultByteArrayFieldItem::getShort(int index) + { + if (!isValidShort(index)) + { + throw new PlcIncompatibleDatatypeException("short", index); + } + + return (short)getValue(index); + } + + // =================================================== + bool DefaultByteArrayFieldItem::isValidInteger(int index) + { + char value = getValue(index); + return value >= 0 && value <= 2147483647; + } + + // =================================================== + int DefaultByteArrayFieldItem::getInteger(int index) + { + if (!isValidInteger(index)) + { + throw new PlcIncompatibleDatatypeException("int", index); + } + + return (int)getValue(index); + } + + // =================================================== + bool DefaultByteArrayFieldItem::isValidLong(int index) + { + char value = getValue(index); + return value >= -(2 ^ 63) && value <= (2 ^ 63) - 1; + } + + // =================================================== + long DefaultByteArrayFieldItem::getLong(int index) + { + if (!isValidLong(index)) + { + throw new PlcIncompatibleDatatypeException("long", index); + } + + return (long)getValue(index); + } + + // =================================================== + bool DefaultByteArrayFieldItem::isValidBigInteger(int index) + { + return true; + } + + // =================================================== + long long DefaultByteArrayFieldItem::getBigInteger(int index) + { + if (!isValidBigInteger(index)) + { + throw new PlcIncompatibleDatatypeException("long long", index); + } + + // Todo: add conversion from cpp_dec_float_100 TO InfInt + return (long)getValue(index); + } + + // =================================================== + bool DefaultByteArrayFieldItem::isValidFloat(int index) + { + char value = getValue(index); + return value >= -3.4e38 && value <= 3.4e38; + } + + // =================================================== + float DefaultByteArrayFieldItem::getFloat(int index) + { + if (!isValidFloat(index)) + { + throw new PlcIncompatibleDatatypeException("float", index); + } + + return (float)getValue(index); + } + + // =================================================== + bool DefaultByteArrayFieldItem::isValidDouble(int index) + { + char value = getValue(index); + return value >= -1.7e308 && value <= 1.7e308; + } + + // =================================================== + double DefaultByteArrayFieldItem::getDouble(int index) + { + if (!isValidDouble(index)) + { + throw new PlcIncompatibleDatatypeException("double", index); + } + + return (double)getValue(index); + } + + // =================================================== + bool DefaultByteArrayFieldItem::isValidBigDecimal(int index) + { + // same limits but higher precision + return isValidDouble(index); + } + + // =================================================== + cpp_dec_float_100 DefaultByteArrayFieldItem::getBigDecimal(int index) + { + if (!isValidBigDecimal(index)) + { + throw new PlcIncompatibleDatatypeException("cpp_dec_float_100", index); + } + + return (cpp_dec_float_100)getValue(index); + } + } + + } + } + } + } + } +} diff --git a/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultByteArrayFieldItem.h b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultByteArrayFieldItem.h new file mode 100644 index 00000000000..9275f0142b4 --- /dev/null +++ b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultByteArrayFieldItem.h @@ -0,0 +1,81 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +*/ + +#ifndef _DEFAULT_BYTE_ARRAY_FIELD_ITEM +#define _DEFAULT_BYTE_ARRAY_FIELD_ITEM + +#include +#include "BaseDefaultFieldItem.h" + +using namespace org::apache::plc4x::cpp::api::exceptions; +using namespace boost::multiprecision; + +namespace org +{ + namespace apache + { + namespace plc4x + { + namespace cpp + { + namespace base + { + namespace messages + { + namespace items + { + class DefaultByteArrayFieldItem : public BaseDefaultFieldItem + { + + public: + template + DefaultByteArrayFieldItem(std::vector values); + + template + inline T getObject(int index) { return BaseDefaultFieldItem::getValue(index); } + inline bool isValidBoolean(int index) { return true; } + bool getBoolean(int index); + bool isValidByte(int index); + char getByte(int index); + bool isValidShort(int index); + short getShort(int index); + bool isValidInteger(int index); + int getInteger(int index); + bool isValidLong(int index); + long getLong(int index); + bool isValidBigInteger(int index); + long long getBigInteger(int index); + bool isValidFloat(int index); + float getFloat(int index); + bool isValidDouble(int index); + double getDouble(int index); + bool isValidBigDecimal(int index); + cpp_dec_float_100 getBigDecimal(int index); + + private: + }; + } + } + } + } + } + } +} + +#endif \ No newline at end of file diff --git a/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultByteFieldItem.cpp b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultByteFieldItem.cpp new file mode 100644 index 00000000000..5f2c1323977 --- /dev/null +++ b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultByteFieldItem.cpp @@ -0,0 +1,196 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +*/ + +#include "DefaultByteFieldItem.h" + +namespace org +{ + namespace apache + { + namespace plc4x + { + namespace cpp + { + namespace base + { + namespace messages + { + namespace items + { + // ================================================== + bool DefaultByteFieldItem::getBoolean(int index) + { + if (!isValidBoolean(index)) + { + throw new PlcIncompatibleDatatypeException("bool", index); + } + + return getValue(index); + } + + // =================================================== + bool DefaultByteFieldItem::isValidByte(int index) + { + char value = getValue(index); + return value <= -127 && value >= -128; + } + + // =================================================== + char DefaultByteFieldItem::getByte(int index) + { + if (!isValidByte(index)) + { + throw new PlcIncompatibleDatatypeException("char", index); + } + return (char) getValue(index); + } + + // =================================================== + bool DefaultByteFieldItem::isValidShort(int index) + { + char value = getValue(index); + return value >= -32768 && value <= 32767; + } + + // =================================================== + short DefaultByteFieldItem::getShort(int index) + { + if (!isValidShort(index)) + { + throw new PlcIncompatibleDatatypeException("short", index); + } + + return (short)getValue(index); + } + + // =================================================== + bool DefaultByteFieldItem::isValidInteger(int index) + { + char value = getValue(index); + return value >= 0 && value <= 2147483647; + } + + // =================================================== + int DefaultByteFieldItem::getInteger(int index) + { + if (!isValidInteger(index)) + { + throw new PlcIncompatibleDatatypeException("int", index); + } + + return (int)getValue(index); + } + + // =================================================== + bool DefaultByteFieldItem::isValidLong(int index) + { + char value = getValue(index); + return value >= -(2 ^ 63) && value <= (2 ^ 63) - 1; + } + + // =================================================== + long DefaultByteFieldItem::getLong(int index) + { + if (!isValidLong(index)) + { + throw new PlcIncompatibleDatatypeException("long", index); + } + + return (long)getValue(index); + } + + // =================================================== + bool DefaultByteFieldItem::isValidBigInteger(int index) + { + return true; + } + + // =================================================== + long long DefaultByteFieldItem::getBigInteger(int index) + { + if (!isValidBigInteger(index)) + { + throw new PlcIncompatibleDatatypeException("long long", index); + } + + // Todo: add conversion from cpp_dec_float_100 TO long long + return (long)getValue(index); + } + + // =================================================== + bool DefaultByteFieldItem::isValidFloat(int index) + { + char value = getValue(index); + return value >= -3.4e38 && value <= 3.4e38; + } + + // =================================================== + float DefaultByteFieldItem::getFloat(int index) + { + if (!isValidFloat(index)) + { + throw new PlcIncompatibleDatatypeException("float", index); + } + + return (float)getValue(index); + } + + // =================================================== + bool DefaultByteFieldItem::isValidDouble(int index) + { + char value = getValue(index); + return value >= -1.7e308 && value <= 1.7e308; + } + + // =================================================== + double DefaultByteFieldItem::getDouble(int index) + { + if (!isValidDouble(index)) + { + throw new PlcIncompatibleDatatypeException("double", index); + } + + return (double)getValue(index); + } + + // =================================================== + bool DefaultByteFieldItem::isValidBigDecimal(int index) + { + // same limits but higher precision + return isValidDouble(index); + } + + // =================================================== + cpp_dec_float_100 DefaultByteFieldItem::getBigDecimal(int index) + { + if (!isValidBigDecimal(index)) + { + throw new PlcIncompatibleDatatypeException("cpp_dec_float_100", index); + } + + return (cpp_dec_float_100)getValue(index); + } + } + + } + } + } + } + } +} diff --git a/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultByteFieldItem.h b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultByteFieldItem.h new file mode 100644 index 00000000000..64715bb61e8 --- /dev/null +++ b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultByteFieldItem.h @@ -0,0 +1,81 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +*/ + +#ifndef _DEFAULT_BYTE_FIELD_ITEM +#define _DEFAULT_BYTE_FIELD_ITEM + +#include +#include "BaseDefaultFieldItem.h" + +using namespace org::apache::plc4x::cpp::api::exceptions; +using namespace boost::multiprecision; + +namespace org +{ + namespace apache + { + namespace plc4x + { + namespace cpp + { + namespace base + { + namespace messages + { + namespace items + { + class DefaultByteFieldItem : public BaseDefaultFieldItem + { + + public: + template + DefaultByteFieldItem(std::vector values); + + template + inline T getObject(int index) { return BaseDefaultFieldItem::getValue(index); } + inline bool isValidBoolean(int index) { return true; } + bool getBoolean(int index); + bool isValidByte(int index); + char getByte(int index); + bool isValidShort(int index); + short getShort(int index); + bool isValidInteger(int index); + int getInteger(int index); + bool isValidLong(int index); + long getLong(int index); + bool isValidBigInteger(int index); + long long getBigInteger(int index); + bool isValidFloat(int index); + float getFloat(int index); + bool isValidDouble(int index); + double getDouble(int index); + bool isValidBigDecimal(int index); + cpp_dec_float_100 getBigDecimal(int index); + + private: + }; + } + } + } + } + } + } +} + +#endif \ No newline at end of file diff --git a/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultDoubleFieldItem.cpp b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultDoubleFieldItem.cpp new file mode 100644 index 00000000000..aa094358e51 --- /dev/null +++ b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultDoubleFieldItem.cpp @@ -0,0 +1,196 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +*/ + +#include "DefaultDoubleFieldItem.h" + +namespace org +{ + namespace apache + { + namespace plc4x + { + namespace cpp + { + namespace base + { + namespace messages + { + namespace items + { + // ================================================== + bool DefaultDoubleFieldItem::getBoolean(int index) + { + if (!isValidBoolean(index)) + { + throw new PlcIncompatibleDatatypeException("bool", index); + } + + return getValue(index); + } + + // =================================================== + bool DefaultDoubleFieldItem::isValidByte(int index) + { + double value = getValue(index); + return value <= -127 && value >= -128; + } + + // =================================================== + char DefaultDoubleFieldItem::getByte(int index) + { + if (!isValidByte(index)) + { + throw new PlcIncompatibleDatatypeException("char", index); + } + return (char) getValue(index); + } + + // =================================================== + bool DefaultDoubleFieldItem::isValidShort(int index) + { + double value = getValue(index); + return value >= -32768 && value <= 32767; + } + + // =================================================== + short DefaultDoubleFieldItem::getShort(int index) + { + if (!isValidShort(index)) + { + throw new PlcIncompatibleDatatypeException("short", index); + } + + return (short)getValue(index); + } + + // =================================================== + bool DefaultDoubleFieldItem::isValidInteger(int index) + { + double value = getValue(index); + return value >= 0 && value <= 2147483647; + } + + // =================================================== + int DefaultDoubleFieldItem::getInteger(int index) + { + if (!isValidInteger(index)) + { + throw new PlcIncompatibleDatatypeException("int", index); + } + + return (int)getValue(index); + } + + // =================================================== + bool DefaultDoubleFieldItem::isValidLong(int index) + { + double value = getValue(index); + return value >= -(2 ^ 63) && value <= (2 ^ 63) - 1; + } + + // =================================================== + long DefaultDoubleFieldItem::getLong(int index) + { + if (!isValidLong(index)) + { + throw new PlcIncompatibleDatatypeException("long", index); + } + + return (long)getValue(index); + } + + // =================================================== + bool DefaultDoubleFieldItem::isValidBigInteger(int index) + { + return true; + } + + // =================================================== + long long DefaultDoubleFieldItem::getBigInteger(int index) + { + if (!isValidBigInteger(index)) + { + throw new PlcIncompatibleDatatypeException("long long", index); + } + + // Todo: add conversion from cpp_dec_float_100 TO long long + return (long)getValue(index); + } + + // =================================================== + bool DefaultDoubleFieldItem::isValidFloat(int index) + { + double value = getValue(index); + return value >= -3.4e38 && value <= 3.4e38; + } + + // =================================================== + float DefaultDoubleFieldItem::getFloat(int index) + { + if (!isValidFloat(index)) + { + throw new PlcIncompatibleDatatypeException("float", index); + } + + return (float)getValue(index); + } + + // =================================================== + bool DefaultDoubleFieldItem::isValidDouble(int index) + { + double value = getValue(index); + return value >= -1.7e308 && value <= 1.7e308; + } + + // =================================================== + double DefaultDoubleFieldItem::getDouble(int index) + { + if (!isValidDouble(index)) + { + throw new PlcIncompatibleDatatypeException("double", index); + } + + return (double)getValue(index); + } + + // =================================================== + bool DefaultDoubleFieldItem::isValidBigDecimal(int index) + { + // same limits but higher precision + return isValidDouble(index); + } + + // =================================================== + cpp_dec_float_100 DefaultDoubleFieldItem::getBigDecimal(int index) + { + if (!isValidBigDecimal(index)) + { + throw new PlcIncompatibleDatatypeException("cpp_dec_float_100", index); + } + + return (cpp_dec_float_100)getValue(index); + } + } + + } + } + } + } + } +} diff --git a/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultDoubleFieldItem.h b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultDoubleFieldItem.h new file mode 100644 index 00000000000..2ee39d99a7a --- /dev/null +++ b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultDoubleFieldItem.h @@ -0,0 +1,81 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +*/ + +#ifndef _DEFAULT_DOUBLE_FIELD_ITEM +#define _DEFAULT_DOUBLE_FIELD_ITEM + +#include +#include "BaseDefaultFieldItem.h" + +using namespace org::apache::plc4x::cpp::api::exceptions; +using namespace boost::multiprecision; + +namespace org +{ + namespace apache + { + namespace plc4x + { + namespace cpp + { + namespace base + { + namespace messages + { + namespace items + { + class DefaultDoubleFieldItem : public BaseDefaultFieldItem + { + + public: + template + DefaultDoubleFieldItem(std::vector values); + + template + inline T getObject(int index) { return BaseDefaultFieldItem::getValue(index); } + inline bool isValidBoolean(int index) { return true; } + bool getBoolean(int index); + bool isValidByte(int index); + char getByte(int index); + bool isValidShort(int index); + short getShort(int index); + bool isValidInteger(int index); + int getInteger(int index); + bool isValidLong(int index); + long getLong(int index); + bool isValidBigInteger(int index); + long long getBigInteger(int index); + bool isValidFloat(int index); + float getFloat(int index); + bool isValidDouble(int index); + double getDouble(int index); + bool isValidBigDecimal(int index); + cpp_dec_float_100 getBigDecimal(int index); + + private: + }; + } + } + } + } + } + } +} + +#endif \ No newline at end of file diff --git a/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultFloatFieldItem.cpp b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultFloatFieldItem.cpp new file mode 100644 index 00000000000..afabdbd6afd --- /dev/null +++ b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultFloatFieldItem.cpp @@ -0,0 +1,196 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +*/ + +#include "DefaultFloatFieldItem.h" + +namespace org +{ + namespace apache + { + namespace plc4x + { + namespace cpp + { + namespace base + { + namespace messages + { + namespace items + { + // ================================================== + bool DefaultFloatFieldItem::getBoolean(int index) + { + if (!isValidBoolean(index)) + { + throw new PlcIncompatibleDatatypeException("bool", index); + } + + return getValue(index); + } + + // =================================================== + bool DefaultFloatFieldItem::isValidByte(int index) + { + float value = getValue(index); + return value <= -127 && value >= -128; + } + + // =================================================== + char DefaultFloatFieldItem::getByte(int index) + { + if (!isValidByte(index)) + { + throw new PlcIncompatibleDatatypeException("char", index); + } + return (char) getValue(index); + } + + // =================================================== + bool DefaultFloatFieldItem::isValidShort(int index) + { + float value = getValue(index); + return value >= -32768 && value <= 32767; + } + + // =================================================== + short DefaultFloatFieldItem::getShort(int index) + { + if (!isValidShort(index)) + { + throw new PlcIncompatibleDatatypeException("short", index); + } + + return (short)getValue(index); + } + + // =================================================== + bool DefaultFloatFieldItem::isValidInteger(int index) + { + float value = getValue(index); + return value >= 0 && value <= 2147483647; + } + + // =================================================== + int DefaultFloatFieldItem::getInteger(int index) + { + if (!isValidInteger(index)) + { + throw new PlcIncompatibleDatatypeException("int", index); + } + + return (int)getValue(index); + } + + // =================================================== + bool DefaultFloatFieldItem::isValidLong(int index) + { + float value = getValue(index); + return value >= -(2 ^ 63) && value <= (2 ^ 63) - 1; + } + + // =================================================== + long DefaultFloatFieldItem::getLong(int index) + { + if (!isValidLong(index)) + { + throw new PlcIncompatibleDatatypeException("long", index); + } + + return (long)getValue(index); + } + + // =================================================== + bool DefaultFloatFieldItem::isValidBigInteger(int index) + { + return true; + } + + // =================================================== + long long DefaultFloatFieldItem::getBigInteger(int index) + { + if (!isValidBigInteger(index)) + { + throw new PlcIncompatibleDatatypeException("long long", index); + } + + // Todo: add conversion from cpp_dec_float_100 TO long long + return (long)getValue(index); + } + + // =================================================== + bool DefaultFloatFieldItem::isValidFloat(int index) + { + float value = getValue(index); + return value >= -3.4e38 && value <= 3.4e38; + } + + // =================================================== + float DefaultFloatFieldItem::getFloat(int index) + { + if (!isValidFloat(index)) + { + throw new PlcIncompatibleDatatypeException("float", index); + } + + return (float)getValue(index); + } + + // =================================================== + bool DefaultFloatFieldItem::isValidDouble(int index) + { + double value = getValue(index); + return value >= -1.7e308 && value <= 1.7e308; + } + + // =================================================== + double DefaultFloatFieldItem::getDouble(int index) + { + if (!isValidDouble(index)) + { + throw new PlcIncompatibleDatatypeException("double", index); + } + + return (double)getValue(index); + } + + // =================================================== + bool DefaultFloatFieldItem::isValidBigDecimal(int index) + { + // same limits but higher precision + return isValidDouble(index); + } + + // =================================================== + cpp_dec_float_100 DefaultFloatFieldItem::getBigDecimal(int index) + { + if (!isValidBigDecimal(index)) + { + throw new PlcIncompatibleDatatypeException("cpp_dec_float_100", index); + } + + return (cpp_dec_float_100)getValue(index); + } + } + + } + } + } + } + } +} diff --git a/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultFloatFieldItem.h b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultFloatFieldItem.h new file mode 100644 index 00000000000..f59a44c50d7 --- /dev/null +++ b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultFloatFieldItem.h @@ -0,0 +1,81 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +*/ + +#ifndef _DEFAULT_FLOAT_FIELD_ITEM +#define _DEFAULT_FLOAT_FIELD_ITEM + +#include +#include "BaseDefaultFieldItem.h" + +using namespace org::apache::plc4x::cpp::api::exceptions; +using namespace boost::multiprecision; + +namespace org +{ + namespace apache + { + namespace plc4x + { + namespace cpp + { + namespace base + { + namespace messages + { + namespace items + { + class DefaultFloatFieldItem : public BaseDefaultFieldItem + { + + public: + template + DefaultFloatFieldItem(std::vector values); + + template + inline T getObject(int index) { return BaseDefaultFieldItem::getValue(index); } + inline bool isValidBoolean(int index) { return true; } + bool getBoolean(int index); + bool isValidByte(int index); + char getByte(int index); + bool isValidShort(int index); + short getShort(int index); + bool isValidInteger(int index); + int getInteger(int index); + bool isValidLong(int index); + long getLong(int index); + bool isValidBigInteger(int index); + long long getBigInteger(int index); + bool isValidFloat(int index); + float getFloat(int index); + bool isValidDouble(int index); + double getDouble(int index); + bool isValidBigDecimal(int index); + cpp_dec_float_100 getBigDecimal(int index); + + private: + }; + } + } + } + } + } + } +} + +#endif \ No newline at end of file diff --git a/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultIntegerFieldItem.cpp b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultIntegerFieldItem.cpp new file mode 100644 index 00000000000..3d34f67bcf8 --- /dev/null +++ b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultIntegerFieldItem.cpp @@ -0,0 +1,196 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +*/ + +#include "DefaultIntegerFieldItem.h" + +namespace org +{ + namespace apache + { + namespace plc4x + { + namespace cpp + { + namespace base + { + namespace messages + { + namespace items + { + // ================================================== + bool DefaultIntegerFieldItem::getBoolean(int index) + { + if (!isValidBoolean(index)) + { + throw new PlcIncompatibleDatatypeException("bool", index); + } + + return getValue(index); + } + + // =================================================== + bool DefaultIntegerFieldItem::isValidByte(int index) + { + int value = getValue(index); + return value <= -127 && value >= -128; + } + + // =================================================== + char DefaultIntegerFieldItem::getByte(int index) + { + if (!isValidByte(index)) + { + throw new PlcIncompatibleDatatypeException("char", index); + } + return (char) getValue(index); + } + + // =================================================== + bool DefaultIntegerFieldItem::isValidShort(int index) + { + int value = getValue(index); + return value >= -32768 && value <= 32767; + } + + // =================================================== + short DefaultIntegerFieldItem::getShort(int index) + { + if (!isValidShort(index)) + { + throw new PlcIncompatibleDatatypeException("short", index); + } + + return (short)getValue(index); + } + + // =================================================== + bool DefaultIntegerFieldItem::isValidInteger(int index) + { + int value = getValue(index); + return value >= 0 && value <= 2147483647; + } + + // =================================================== + int DefaultIntegerFieldItem::getInteger(int index) + { + if (!isValidInteger(index)) + { + throw new PlcIncompatibleDatatypeException("int", index); + } + + return (int)getValue(index); + } + + // =================================================== + bool DefaultIntegerFieldItem::isValidLong(int index) + { + int value = getValue(index); + return value >= -(2 ^ 63) && value <= (2 ^ 63) - 1; + } + + // =================================================== + long DefaultIntegerFieldItem::getLong(int index) + { + if (!isValidLong(index)) + { + throw new PlcIncompatibleDatatypeException("long", index); + } + + return (long)getValue(index); + } + + // =================================================== + bool DefaultIntegerFieldItem::isValidBigInteger(int index) + { + return true; + } + + // =================================================== + long long DefaultIntegerFieldItem::getBigInteger(int index) + { + if (!isValidBigInteger(index)) + { + throw new PlcIncompatibleDatatypeException("long long", index); + } + + // Todo: add conversion from cpp_dec_float_100 TO long long + return (long)getValue(index); + } + + // =================================================== + bool DefaultIntegerFieldItem::isValidFloat(int index) + { + int value = getValue(index); + return value >= -3.4e38 && value <= 3.4e38; + } + + // =================================================== + float DefaultIntegerFieldItem::getFloat(int index) + { + if (!isValidFloat(index)) + { + throw new PlcIncompatibleDatatypeException("float", index); + } + + return (float)getValue(index); + } + + // =================================================== + bool DefaultIntegerFieldItem::isValidDouble(int index) + { + int value = getValue(index); + return value >= -1.7e308 && value <= 1.7e308; + } + + // =================================================== + double DefaultIntegerFieldItem::getDouble(int index) + { + if (!isValidDouble(index)) + { + throw new PlcIncompatibleDatatypeException("double", index); + } + + return (double)getValue(index); + } + + // =================================================== + bool DefaultIntegerFieldItem::isValidBigDecimal(int index) + { + // same limits but higher precision + return isValidDouble(index); + } + + // =================================================== + cpp_dec_float_100 DefaultIntegerFieldItem::getBigDecimal(int index) + { + if (!isValidBigDecimal(index)) + { + throw new PlcIncompatibleDatatypeException("cpp_dec_float_100", index); + } + + return (cpp_dec_float_100)getValue(index); + } + } + + } + } + } + } + } +} diff --git a/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultIntegerFieldItem.h b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultIntegerFieldItem.h new file mode 100644 index 00000000000..c3325e97947 --- /dev/null +++ b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultIntegerFieldItem.h @@ -0,0 +1,81 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +*/ + +#ifndef _DEFAULT_INTEGER_FIELD_ITEM +#define _DEFAULT_INTEGER_FIELD_ITEM + +#include +#include "BaseDefaultFieldItem.h" + +using namespace org::apache::plc4x::cpp::api::exceptions; +using namespace boost::multiprecision; + +namespace org +{ + namespace apache + { + namespace plc4x + { + namespace cpp + { + namespace base + { + namespace messages + { + namespace items + { + class DefaultIntegerFieldItem : public BaseDefaultFieldItem + { + + public: + template + DefaultIntegerFieldItem(std::vector values); + + template + inline T getObject(int index) { return BaseDefaultFieldItem::getValue(index); } + inline bool isValidBoolean(int index) { return true; } + bool getBoolean(int index); + bool isValidByte(int index); + char getByte(int index); + bool isValidShort(int index); + short getShort(int index); + bool isValidInteger(int index); + int getInteger(int index); + bool isValidLong(int index); + long getLong(int index); + bool isValidBigInteger(int index); + long long getBigInteger(int index); + bool isValidFloat(int index); + float getFloat(int index); + bool isValidDouble(int index); + double getDouble(int index); + bool isValidBigDecimal(int index); + cpp_dec_float_100 getBigDecimal(int index); + + private: + }; + } + } + } + } + } + } +} + +#endif \ No newline at end of file diff --git a/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultLocalDateFieldItem.cpp b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultLocalDateFieldItem.cpp new file mode 100644 index 00000000000..6d3e97d1496 --- /dev/null +++ b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultLocalDateFieldItem.cpp @@ -0,0 +1,196 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +*/ + +#include "DefaultLocalDateFieldItem.h" + +namespace org +{ + namespace apache + { + namespace plc4x + { + namespace cpp + { + namespace base + { + namespace messages + { + namespace items + { + // ================================================== + bool DefaultLocalDateFieldItem::getBoolean(int index) + { + if (!isValidBoolean(index)) + { + throw new PlcIncompatibleDatatypeException("bool", index); + } + + return getValue(index); + } + + // =================================================== + bool DefaultLocalDateFieldItem::isValidByte(int index) + { + data_type value = getValue(index); + return value <= -127 && value >= -128; + } + + // =================================================== + char DefaultLocalDateFieldItem::getByte(int index) + { + if (!isValidByte(index)) + { + throw new PlcIncompatibleDatatypeException("char", index); + } + return (char) getValue(index); + } + + // =================================================== + bool DefaultLocalDateFieldItem::isValidShort(int index) + { + data_type value = getValue(index); + return value >= -32768 && value <= 32767; + } + + // =================================================== + short DefaultLocalDateFieldItem::getShort(int index) + { + if (!isValidShort(index)) + { + throw new PlcIncompatibleDatatypeException("short", index); + } + + return (short)getValue(index); + } + + // =================================================== + bool DefaultLocalDateFieldItem::isValidInteger(int index) + { + data_type value = getValue(index); + return value >= 0 && value <= 2147483647; + } + + // =================================================== + int DefaultLocalDateFieldItem::getInteger(int index) + { + if (!isValidInteger(index)) + { + throw new PlcIncompatibleDatatypeException("int", index); + } + + return (int)getValue(index); + } + + // =================================================== + bool DefaultLocalDateFieldItem::isValidLong(int index) + { + data_type value = getValue(index); + return value >= -(2 ^ 63) && value <= (2 ^ 63) - 1; + } + + // =================================================== + long DefaultLocalDateFieldItem::getLong(int index) + { + if (!isValidLong(index)) + { + throw new PlcIncompatibleDatatypeException("long", index); + } + + return (long)getValue(index); + } + + // =================================================== + bool DefaultLocalDateFieldItem::isValidBigInteger(int index) + { + return true; + } + + // =================================================== + long long DefaultLocalDateFieldItem::getBigInteger(int index) + { + if (!isValidBigInteger(index)) + { + throw new PlcIncompatibleDatatypeException("long long", index); + } + + // Todo: add conversion from cpp_dec_float_100 TO long long + return (long)getValue(index); + } + + // =================================================== + bool DefaultLocalDateFieldItem::isValidFloat(int index) + { + data_type value = getValue(index); + return value >= -3.4e38 && value <= 3.4e38; + } + + // =================================================== + float DefaultLocalDateFieldItem::getFloat(int index) + { + if (!isValidFloat(index)) + { + throw new PlcIncompatibleDatatypeException("float", index); + } + + return (float)getValue(index); + } + + // =================================================== + bool DefaultLocalDateFieldItem::isValidDouble(int index) + { + data_type value = getValue(index); + return value >= -1.7e308 && value <= 1.7e308; + } + + // =================================================== + double DefaultLocalDateFieldItem::getDouble(int index) + { + if (!isValidDouble(index)) + { + throw new PlcIncompatibleDatatypeException("double", index); + } + + return (double)getValue(index); + } + + // =================================================== + bool DefaultLocalDateFieldItem::isValidBigDecimal(int index) + { + // same limits but higher precision + return isValidDouble(index); + } + + // =================================================== + cpp_dec_float_100 DefaultLocalDateFieldItem::getBigDecimal(int index) + { + if (!isValidBigDecimal(index)) + { + throw new PlcIncompatibleDatatypeException("cpp_dec_float_100", index); + } + + return (cpp_dec_float_100)getValue(index); + } + } + + } + } + } + } + } +} diff --git a/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultLocalDateFieldItem.h b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultLocalDateFieldItem.h new file mode 100644 index 00000000000..1811c21a2a1 --- /dev/null +++ b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultLocalDateFieldItem.h @@ -0,0 +1,81 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +*/ + +#ifndef _DEFAULT_LOCAL_DATE_FIELD_ITEM +#define _DEFAULT_LOCAL_DATE_FIELD_ITEM + +#include +#include "BaseDefaultFieldItem.h" + +using namespace org::apache::plc4x::cpp::api::exceptions; +using namespace boost::multiprecision; + +namespace org +{ + namespace apache + { + namespace plc4x + { + namespace cpp + { + namespace base + { + namespace messages + { + namespace items + { + class DefaultLocalDateFieldItem : public BaseDefaultFieldItem + { + typedef time_t data_type; + public: + template + DefaultLocalDateFieldItem(std::vector values); + + template + inline T getObject(int index) { return BaseDefaultFieldItem::getValue(index); } + inline bool isValidBoolean(int index) { return true; } + bool getBoolean(int index); + bool isValidByte(int index); + char getByte(int index); + bool isValidShort(int index); + short getShort(int index); + bool isValidInteger(int index); + int getInteger(int index); + bool isValidLong(int index); + long getLong(int index); + bool isValidBigInteger(int index); + long long getBigInteger(int index); + bool isValidFloat(int index); + float getFloat(int index); + bool isValidDouble(int index); + double getDouble(int index); + bool isValidBigDecimal(int index); + cpp_dec_float_100 getBigDecimal(int index); + + private: + }; + } + } + } + } + } + } +} + +#endif \ No newline at end of file diff --git a/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultLocalDateTimeFieldItem.h b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultLocalDateTimeFieldItem.h new file mode 100644 index 00000000000..efc0e7f7891 --- /dev/null +++ b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultLocalDateTimeFieldItem.h @@ -0,0 +1,71 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +*/ + +#ifndef _DEFAULT_LOCAL_DATE_TIME_FIELD_ITEM +#define _DEFAULT_LOCAL_DATE_TIME_FIELD_ITEM + +#include +#include +#include +#include "BaseDefaultFieldItem.h" + +using namespace org::apache::plc4x::cpp::api::exceptions; +using namespace boost::multiprecision; +using namespace boost::posix_time; + +namespace org +{ + namespace apache + { + namespace plc4x + { + namespace cpp + { + namespace base + { + namespace messages + { + namespace items + { + class DefaultLocalDateTimeFieldItem : public BaseDefaultFieldItem + { + typedef time_t data_type; + public: + template + DefaultLocalDateTimeFieldItem(std::vector values); + + template + inline T getObject(int index) { return BaseDefaultFieldItem::getValue(index); } + bool isValidTime(int index); + time_t getTime(int index); + bool isValidDate(int index); + tm getDate(int index); + bool isValidDateTime(int index); + time_t getDateTime(int index); + private: + }; + } + } + } + } + } + } +} + +#endif \ No newline at end of file diff --git a/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultLocalDateTimeFieldltem.cpp b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultLocalDateTimeFieldltem.cpp new file mode 100644 index 00000000000..a4ba5ee9c81 --- /dev/null +++ b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultLocalDateTimeFieldltem.cpp @@ -0,0 +1,95 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +*/ + +#include "DefaultLocalDateTimeFieldItem.h" + +namespace org +{ + namespace apache + { + namespace plc4x + { + namespace cpp + { + namespace base + { + namespace messages + { + namespace items + { + // ================================================== + bool DefaultLocalDateTimeFieldItem::isValidTime(int index) + { + return getValue(index) != NULL; ; + } + + // =================================================== + time_t DefaultLocalDateTimeFieldItem::getTime(int index) + { + return getValue(index); + } + + // =================================================== + bool DefaultLocalDateTimeFieldItem::isValidDateTime(int index) + { + return isValidTime(index); + } + + // =================================================== + time_t DefaultLocalDateTimeFieldItem::getDateTime(int index) + { + if (!isValidDateTime(index)) + { + throw new PlcIncompatibleDatatypeException("time_t", index); + } + + return getValue(index); + } + + // =================================================== + bool DefaultLocalDateTimeFieldItem::isValidDate(int index) + { + return getValue(index) != NULL; + } + + // =================================================== + tm DefaultLocalDateTimeFieldItem::getDate(int index) + { + if (!isValidDateTime(index)) + { + throw new PlcIncompatibleDatatypeException("time_t", index); + } + + time_t time = getValue(index); + + #pragma warning(suppress : 4996) + tm* date = gmtime(&time); + + return *date; + } + + + } + + } + } + } + } + } +} diff --git a/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultLocalTimeFieldItem.cpp b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultLocalTimeFieldItem.cpp new file mode 100644 index 00000000000..f1538ec9ea1 --- /dev/null +++ b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultLocalTimeFieldItem.cpp @@ -0,0 +1,95 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +*/ + +#include "DefaultLocalTimeFieldItem.h" + +namespace org +{ + namespace apache + { + namespace plc4x + { + namespace cpp + { + namespace base + { + namespace messages + { + namespace items + { + // ================================================== + bool DefaultLocalTimeFieldItem::isValidTime(int index) + { + return getValue(index) != NULL; ; + } + + // =================================================== + time_t DefaultLocalTimeFieldItem::getTime(int index) + { + return getValue(index); + } + + // =================================================== + bool DefaultLocalTimeFieldItem::isValidDateTime(int index) + { + return isValidTime(index); + } + + // =================================================== + time_t DefaultLocalTimeFieldItem::getDateTime(int index) + { + if (!isValidDateTime(index)) + { + throw new PlcIncompatibleDatatypeException("time_t", index); + } + + return getValue(index); + } + + // =================================================== + bool DefaultLocalTimeFieldItem::isValidDate(int index) + { + return getValue(index) != NULL; + } + + // =================================================== + tm DefaultLocalTimeFieldItem::getDate(int index) + { + if (!isValidDateTime(index)) + { + throw new PlcIncompatibleDatatypeException("time_t", index); + } + + time_t time = getValue(index); + + #pragma warning(suppress : 4996) + tm* date = gmtime(&time); + + return *date; + } + + + } + + } + } + } + } + } +} diff --git a/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultLocalTimeFieldItem.h b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultLocalTimeFieldItem.h new file mode 100644 index 00000000000..cd5eb3dadb6 --- /dev/null +++ b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultLocalTimeFieldItem.h @@ -0,0 +1,71 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +*/ + +#ifndef _DEFAULT_LOCAL_TIME_FIELD_ITEM +#define _DEFAULT_LOCAL_TIME_FIELD_ITEM + +#include +#include +#include +#include "BaseDefaultFieldItem.h" + +using namespace org::apache::plc4x::cpp::api::exceptions; +using namespace boost::multiprecision; +using namespace boost::posix_time; + +namespace org +{ + namespace apache + { + namespace plc4x + { + namespace cpp + { + namespace base + { + namespace messages + { + namespace items + { + class DefaultLocalTimeFieldItem : public BaseDefaultFieldItem + { + typedef time_t data_type; + public: + template + DefaultLocalTimeFieldItem(std::vector values); + + template + inline T getObject(int index) { return BaseDefaultFieldItem::getValue(index); } + bool isValidTime(int index); + time_t getTime(int index); + bool isValidDate(int index); + tm getDate(int index); + bool isValidDateTime(int index); + time_t getDateTime(int index); + private: + }; + } + } + } + } + } + } +} + +#endif \ No newline at end of file diff --git a/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultLongFieldItem.cpp b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultLongFieldItem.cpp new file mode 100644 index 00000000000..e66678b4e5a --- /dev/null +++ b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultLongFieldItem.cpp @@ -0,0 +1,196 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +*/ + +#include "DefaultLongFieldItem.h" + +namespace org +{ + namespace apache + { + namespace plc4x + { + namespace cpp + { + namespace base + { + namespace messages + { + namespace items + { + // ================================================== + bool DefaultLongFieldItem::getBoolean(int index) + { + if (!isValidBoolean(index)) + { + throw new PlcIncompatibleDatatypeException("bool", index); + } + + return getValue(index); + } + + // =================================================== + bool DefaultLongFieldItem::isValidByte(int index) + { + data_type value = getValue(index); + return value <= -127 && value >= -128; + } + + // =================================================== + char DefaultLongFieldItem::getByte(int index) + { + if (!isValidByte(index)) + { + throw new PlcIncompatibleDatatypeException("char", index); + } + return (char) getValue(index); + } + + // =================================================== + bool DefaultLongFieldItem::isValidShort(int index) + { + data_type value = getValue(index); + return value >= -32768 && value <= 32767; + } + + // =================================================== + short DefaultLongFieldItem::getShort(int index) + { + if (!isValidShort(index)) + { + throw new PlcIncompatibleDatatypeException("short", index); + } + + return (short)getValue(index); + } + + // =================================================== + bool DefaultLongFieldItem::isValidInteger(int index) + { + data_type value = getValue(index); + return value >= 0 && value <= 2147483647; + } + + // =================================================== + int DefaultLongFieldItem::getInteger(int index) + { + if (!isValidInteger(index)) + { + throw new PlcIncompatibleDatatypeException("int", index); + } + + return (int)getValue(index); + } + + // =================================================== + bool DefaultLongFieldItem::isValidLong(int index) + { + data_type value = getValue(index); + return value >= -(2 ^ 63) && value <= (2 ^ 63) - 1; + } + + // =================================================== + long DefaultLongFieldItem::getLong(int index) + { + if (!isValidLong(index)) + { + throw new PlcIncompatibleDatatypeException("long", index); + } + + return (long)getValue(index); + } + + // =================================================== + bool DefaultLongFieldItem::isValidBigInteger(int index) + { + return true; + } + + // =================================================== + long long DefaultLongFieldItem::getBigInteger(int index) + { + if (!isValidBigInteger(index)) + { + throw new PlcIncompatibleDatatypeException("long long", index); + } + + // Todo: add conversion from cpp_dec_float_100 TO long long + return (long)getValue(index); + } + + // =================================================== + bool DefaultLongFieldItem::isValidFloat(int index) + { + data_type value = getValue(index); + return value >= -3.4e38 && value <= 3.4e38; + } + + // =================================================== + float DefaultLongFieldItem::getFloat(int index) + { + if (!isValidFloat(index)) + { + throw new PlcIncompatibleDatatypeException("float", index); + } + + return (float)getValue(index); + } + + // =================================================== + bool DefaultLongFieldItem::isValidDouble(int index) + { + data_type value = getValue(index); + return value >= -1.7e308 && value <= 1.7e308; + } + + // =================================================== + double DefaultLongFieldItem::getDouble(int index) + { + if (!isValidDouble(index)) + { + throw new PlcIncompatibleDatatypeException("double", index); + } + + return (double)getValue(index); + } + + // =================================================== + bool DefaultLongFieldItem::isValidBigDecimal(int index) + { + // same limits but higher precision + return isValidDouble(index); + } + + // =================================================== + cpp_dec_float_100 DefaultLongFieldItem::getBigDecimal(int index) + { + if (!isValidBigDecimal(index)) + { + throw new PlcIncompatibleDatatypeException("cpp_dec_float_100", index); + } + + return (cpp_dec_float_100)getValue(index); + } + } + + } + } + } + } + } +} diff --git a/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultLongFieldItem.h b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultLongFieldItem.h new file mode 100644 index 00000000000..e6d31fc7636 --- /dev/null +++ b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultLongFieldItem.h @@ -0,0 +1,82 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +*/ + +#ifndef _DEFAULT_LONG_FIELD_ITEM +#define _DEFAULT_LONG_FIELD_ITEM + +#include +#include "BaseDefaultFieldItem.h" + +using namespace org::apache::plc4x::cpp::api::exceptions; +using namespace boost::multiprecision; + +namespace org +{ + namespace apache + { + namespace plc4x + { + namespace cpp + { + namespace base + { + namespace messages + { + namespace items + { + class DefaultLongFieldItem : public BaseDefaultFieldItem + { + + public: + template + DefaultLongFieldItem(std::vector values); + + template + inline T getObject(int index) { return BaseDefaultFieldItem::getValue(index); } + inline bool isValidBoolean(int index) { return true; } + bool getBoolean(int index); + bool isValidByte(int index); + char getByte(int index); + bool isValidShort(int index); + short getShort(int index); + bool isValidInteger(int index); + int getInteger(int index); + bool isValidLong(int index); + long getLong(int index); + bool isValidBigInteger(int index); + long long getBigInteger(int index); + bool isValidFloat(int index); + float getFloat(int index); + bool isValidDouble(int index); + double getDouble(int index); + bool isValidBigDecimal(int index); + cpp_dec_float_100 getBigDecimal(int index); + + private: + typedef long data_type; + }; + } + } + } + } + } + } +} + +#endif \ No newline at end of file diff --git a/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultShortFieldItem.cpp b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultShortFieldItem.cpp new file mode 100644 index 00000000000..6a8950aa61e --- /dev/null +++ b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultShortFieldItem.cpp @@ -0,0 +1,196 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +*/ + +#include "DefaultShortFieldItem.h" + +namespace org +{ + namespace apache + { + namespace plc4x + { + namespace cpp + { + namespace base + { + namespace messages + { + namespace items + { + // ================================================== + bool DefaultShortFieldItem::getBoolean(int index) + { + if (!isValidBoolean(index)) + { + throw new PlcIncompatibleDatatypeException("bool", index); + } + + return getValue(index); + } + + // =================================================== + bool DefaultShortFieldItem::isValidByte(int index) + { + data_type value = getValue(index); + return value <= -127 && value >= -128; + } + + // =================================================== + char DefaultShortFieldItem::getByte(int index) + { + if (!isValidByte(index)) + { + throw new PlcIncompatibleDatatypeException("char", index); + } + return (char) getValue(index); + } + + // =================================================== + bool DefaultShortFieldItem::isValidShort(int index) + { + data_type value = getValue(index); + return value >= -32768 && value <= 32767; + } + + // =================================================== + short DefaultShortFieldItem::getShort(int index) + { + if (!isValidShort(index)) + { + throw new PlcIncompatibleDatatypeException("short", index); + } + + return (short)getValue(index); + } + + // =================================================== + bool DefaultShortFieldItem::isValidInteger(int index) + { + data_type value = getValue(index); + return value >= 0 && value <= 2147483647; + } + + // =================================================== + int DefaultShortFieldItem::getInteger(int index) + { + if (!isValidInteger(index)) + { + throw new PlcIncompatibleDatatypeException("int", index); + } + + return (int)getValue(index); + } + + // =================================================== + bool DefaultShortFieldItem::isValidLong(int index) + { + data_type value = getValue(index); + return value >= -(2 ^ 63) && value <= (2 ^ 63) - 1; + } + + // =================================================== + long DefaultShortFieldItem::getLong(int index) + { + if (!isValidLong(index)) + { + throw new PlcIncompatibleDatatypeException("long", index); + } + + return (long)getValue(index); + } + + // =================================================== + bool DefaultShortFieldItem::isValidBigInteger(int index) + { + return true; + } + + // =================================================== + long long DefaultShortFieldItem::getBigInteger(int index) + { + if (!isValidBigInteger(index)) + { + throw new PlcIncompatibleDatatypeException("long long", index); + } + + // Todo: add conversion from cpp_dec_float_100 TO long long + return (long)getValue(index); + } + + // =================================================== + bool DefaultShortFieldItem::isValidFloat(int index) + { + data_type value = getValue(index); + return value >= -3.4e38 && value <= 3.4e38; + } + + // =================================================== + float DefaultShortFieldItem::getFloat(int index) + { + if (!isValidFloat(index)) + { + throw new PlcIncompatibleDatatypeException("float", index); + } + + return (float)getValue(index); + } + + // =================================================== + bool DefaultShortFieldItem::isValidDouble(int index) + { + data_type value = getValue(index); + return value >= -1.7e308 && value <= 1.7e308; + } + + // =================================================== + double DefaultShortFieldItem::getDouble(int index) + { + if (!isValidDouble(index)) + { + throw new PlcIncompatibleDatatypeException("double", index); + } + + return (double)getValue(index); + } + + // =================================================== + bool DefaultShortFieldItem::isValidBigDecimal(int index) + { + // same limits but higher precision + return isValidDouble(index); + } + + // =================================================== + cpp_dec_float_100 DefaultShortFieldItem::getBigDecimal(int index) + { + if (!isValidBigDecimal(index)) + { + throw new PlcIncompatibleDatatypeException("cpp_dec_float_100", index); + } + + return (cpp_dec_float_100)getValue(index); + } + } + + } + } + } + } + } +} diff --git a/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultShortFieldItem.h b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultShortFieldItem.h new file mode 100644 index 00000000000..9a8ac2bada9 --- /dev/null +++ b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultShortFieldItem.h @@ -0,0 +1,82 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +*/ + +#ifndef _DEFAULT_SHORT_FIELD_ITEM +#define _DEFAULT_SHORT_FIELD_ITEM + +#include +#include "BaseDefaultFieldItem.h" + +using namespace org::apache::plc4x::cpp::api::exceptions; +using namespace boost::multiprecision; + +namespace org +{ + namespace apache + { + namespace plc4x + { + namespace cpp + { + namespace base + { + namespace messages + { + namespace items + { + class DefaultShortFieldItem : public BaseDefaultFieldItem + { + + public: + template + DefaultShortFieldItem(std::vector values); + + template + inline T getObject(int index) { return BaseDefaultFieldItem::getValue(index); } + inline bool isValidBoolean(int index) { return true; } + bool getBoolean(int index); + bool isValidByte(int index); + char getByte(int index); + bool isValidShort(int index); + short getShort(int index); + bool isValidInteger(int index); + int getInteger(int index); + bool isValidLong(int index); + long getLong(int index); + bool isValidBigInteger(int index); + long long getBigInteger(int index); + bool isValidFloat(int index); + float getFloat(int index); + bool isValidDouble(int index); + double getDouble(int index); + bool isValidBigDecimal(int index); + cpp_dec_float_100 getBigDecimal(int index); + + private: + typedef short data_type; + }; + } + } + } + } + } + } +} + +#endif \ No newline at end of file diff --git a/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultStringFieldItem.cpp b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultStringFieldItem.cpp new file mode 100644 index 00000000000..cc66fd0b5ea --- /dev/null +++ b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultStringFieldItem.cpp @@ -0,0 +1,59 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +*/ + +#include "DefaultStringFieldItem.h" + +namespace org +{ + namespace apache + { + namespace plc4x + { + namespace cpp + { + namespace base + { + namespace messages + { + namespace items + { + // ================================================== + std::string DefaultStringFieldItem::getString(int index) + { + if (!isValidString(index)) + { + throw new PlcIncompatibleDatatypeException("std::string", index); + } + + return getValue(index); + } + + // =================================================== + bool DefaultStringFieldItem::isValidString(int index) + { + return true; + } + } + + } + } + } + } + } +} diff --git a/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultStringFieldItem.h b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultStringFieldItem.h new file mode 100644 index 00000000000..4e97cdd811e --- /dev/null +++ b/plc4cpp/protocols/driver-bases/base/src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultStringFieldItem.h @@ -0,0 +1,66 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +*/ + +#ifndef _DEFAULT_STRING_FIELD_ITEM +#define _DEFAULT_STRING_FIELD_ITEM + +#include +#include "BaseDefaultFieldItem.h" + +using namespace org::apache::plc4x::cpp::api::exceptions; +using namespace boost::multiprecision; + +namespace org +{ + namespace apache + { + namespace plc4x + { + namespace cpp + { + namespace base + { + namespace messages + { + namespace items + { + class DefaultStringFieldItem : public BaseDefaultFieldItem + { + + public: + template + DefaultStringFieldItem(std::vector values); + + template + inline T getObject(int index) { return BaseDefaultFieldItem::getValue(index); } + inline bool isValidString(int index); + std::string getString(int index); + + private: + typedef std::string data_type; + }; + } + } + } + } + } + } +} + +#endif \ No newline at end of file From 1c8ca9eb015bdaee40ff5d31e1c176c785259df3 Mon Sep 17 00:00:00 2001 From: Christofer Dutz Date: Mon, 25 Mar 2019 13:47:14 +0100 Subject: [PATCH 2/2] Added a first draft of maven support for Cpp driver base --- plc4cpp/protocols/driver-bases/base/pom.xml | 47 +++++++++++++++ .../base/src/main/cmake/CMakeLists.txt | 58 +++++++++++++++++++ plc4cpp/protocols/driver-bases/pom.xml | 40 +++++++++++++ plc4cpp/protocols/pom.xml | 40 +++++++++++++ 4 files changed, 185 insertions(+) create mode 100644 plc4cpp/protocols/driver-bases/base/pom.xml create mode 100644 plc4cpp/protocols/driver-bases/base/src/main/cmake/CMakeLists.txt create mode 100644 plc4cpp/protocols/driver-bases/pom.xml create mode 100644 plc4cpp/protocols/pom.xml diff --git a/plc4cpp/protocols/driver-bases/base/pom.xml b/plc4cpp/protocols/driver-bases/base/pom.xml new file mode 100644 index 00000000000..b1190e02b9f --- /dev/null +++ b/plc4cpp/protocols/driver-bases/base/pom.xml @@ -0,0 +1,47 @@ + + + + + 4.0.0 + + + org.apache.plc4x + plc4cpp-protocols-driver-bases + 0.4.0-SNAPSHOT + + + plc4cpp-protocol-driver-base + PLC4Cpp: Protocol: Driver-Base: Base + Base classes needed to implement all of the other driver bases. + + + + src/main/cpp + + + + + org.apache.plc4x + plc4cpp-api + 0.4.0-SNAPSHOT + + + + \ No newline at end of file diff --git a/plc4cpp/protocols/driver-bases/base/src/main/cmake/CMakeLists.txt b/plc4cpp/protocols/driver-bases/base/src/main/cmake/CMakeLists.txt new file mode 100644 index 00000000000..071be41557a --- /dev/null +++ b/plc4cpp/protocols/driver-bases/base/src/main/cmake/CMakeLists.txt @@ -0,0 +1,58 @@ +#[[ + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. +]] + +cmake_minimum_required(VERSION 3.7) +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_CXX_EXTENSIONS OFF) + +add_library(api ../../src/main/cpp/org/apache/plc4x/cpp/base/connection/AbstractPlcConnection.cpp + ../../src/main/cpp/org/apache/plc4x/cpp/base/connection/ChannelFactory.cpp + ../../src/main/cpp/org/apache/plc4x/cpp/base/connection/DefaultPlcFieldHandler.cpp + ../../src/main/cpp/org/apache/plc4x/cpp/base/connection/PlcFieldHandler.cpp + ../../src/main/cpp/org/apache/plc4x/cpp/base/events/ConnectedEvent.cpp + ../../src/main/cpp/org/apache/plc4x/cpp/base/events/ConnectEvent.cpp + ../../src/main/cpp/org/apache/plc4x/cpp/base/messages/items/BaseDefaultFieldItem.cpp + ../../src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultBigDecimalFieldItem.cpp + ../../src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultBigIntegerFieldItem.cpp + ../../src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultBooleanFieldItem.cpp + ../../src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultByteArrayFieldItem.cpp + ../../src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultByteFieldItem.cpp + ../../src/main/cpp/org/apache/plc4x/cpp/base/messages/items/DefaultDoubleFieldItem.cpp + ../../src/main/cpp/org/apache/plc4x/cpp/base/messages/DefaultPlcReadRequest.cpp + ../../src/main/cpp/org/apache/plc4x/cpp/base/messages/DefaultPlcWriteRequest.cpp + ../../src/main/cpp/org/apache/plc4x/cpp/base/messages/InternalPlcFieldRequest.cpp + ../../src/main/cpp/org/apache/plc4x/cpp/base/messages/InternalPlcFieldResponse.cpp + ../../src/main/cpp/org/apache/plc4x/cpp/base/messages/InternalPlcProprietaryRequest.cpp + ../../src/main/cpp/org/apache/plc4x/cpp/base/messages/InternalPlcProprietaryResponse.cpp + ../../src/main/cpp/org/apache/plc4x/cpp/base/messages/InternalPlcReadRequest.cpp + ../../src/main/cpp/org/apache/plc4x/cpp/base/messages/InternalPlcRequest.cpp + ../../src/main/cpp/org/apache/plc4x/cpp/base/messages/InternalPlcResponse.cpp + ../../src/main/cpp/org/apache/plc4x/cpp/base/messages/InternalPlcWriteRequest.cpp + ../../src/main/cpp/org/apache/plc4x/cpp/base/messages/PlcProprietaryRequest.cpp + ../../src/main/cpp/org/apache/plc4x/cpp/base/messages/PlcProprietaryResponse.cpp + ../../src/main/cpp/org/apache/plc4x/cpp/base/messages/PlcReader.cpp + ../../src/main/cpp/org/apache/plc4x/cpp/base/messages/PlcWriter.cpp + ) + +#[[ + Import the boost headers +]] +target_include_directories (api PUBLIC ../../../../../${boost.include-directory}) + diff --git a/plc4cpp/protocols/driver-bases/pom.xml b/plc4cpp/protocols/driver-bases/pom.xml new file mode 100644 index 00000000000..e172ea89cbc --- /dev/null +++ b/plc4cpp/protocols/driver-bases/pom.xml @@ -0,0 +1,40 @@ + + + + + 4.0.0 + + + org.apache.plc4x + plc4cpp-protocols + 0.4.0-SNAPSHOT + + + plc4cpp-protocols-driver-bases + pom + + PLC4Cpp: Protocols: Driver-Bases + Collection of base-types for implementing different types of drivers. + + + base + + + \ No newline at end of file diff --git a/plc4cpp/protocols/pom.xml b/plc4cpp/protocols/pom.xml new file mode 100644 index 00000000000..090eaf0ad2e --- /dev/null +++ b/plc4cpp/protocols/pom.xml @@ -0,0 +1,40 @@ + + + + + 4.0.0 + + + org.apache.plc4x + plc4cpp + 0.4.0-SNAPSHOT + + + plc4cpp-protocols + pom + + PLC4Cpp: Protocols + Wrapper project for all PLC4Cpp protocol implementations. + + + driver-bases + + +