| /* |
| * 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. |
| */ |
| // package org.apache.plc4x.rust.s7.readwrite; |
| |
| // Code generated by code-generation. DO NOT EDIT. |
| use std::io::{Error, ErrorKind, Read, Write}; |
| use plc4rust::{Message, NoOption}; |
| use plc4rust::read_buffer::ReadBuffer; |
| use plc4rust::write_buffer::WriteBuffer; |
| |
| use crate::AlarmStateType::AlarmStateType; |
| |
| #[derive(PartialEq, Debug, Clone)] |
| pub struct S7PayloadUserDataItemCpuFunctionMsgSubscriptionOptions { |
| pub cpuFunctionType: u8, |
| pub cpuSubfunction: u8 |
| } |
| |
| #[derive(PartialEq, Debug, Clone)] |
| pub struct S7PayloadUserDataItemCpuFunctionMsgSubscription { |
| pub Subscription: u8, |
| // -> DefaultReservedField{referenceValue=0x00} DefaultTypedField{type=AbstractSimpleTypeReference{baseType=UINT, sizeInBits=8}} DefaultField{attributes={}} |
| pub magicKey: String, |
| // -> DefaultOptionalField{conditionExpression=DefaultBinaryTerm{a=DefaultVariableLiteral{name='Subscription', typeReference='null', args=null, index=null, child=null}, b=DefaultNumericLiteral{number=128}, operation='>='}} DefaultTypedNamedField{name='Alarmtype'} DefaultTypedField{type=DefaultEnumTypeReference{name='AlarmStateType', params=null}} DefaultField{attributes={}} |
| // -> DefaultOptionalField{conditionExpression=DefaultBinaryTerm{a=DefaultVariableLiteral{name='Subscription', typeReference='null', args=null, index=null, child=null}, b=DefaultNumericLiteral{number=128}, operation='>='}} DefaultTypedNamedField{name='Reserve'} DefaultTypedField{type=AbstractSimpleTypeReference{baseType=UINT, sizeInBits=8}} DefaultField{attributes={}} |
| } |
| |
| impl S7PayloadUserDataItemCpuFunctionMsgSubscription { |
| } |
| |
| impl Message for S7PayloadUserDataItemCpuFunctionMsgSubscription { |
| type M = S7PayloadUserDataItemCpuFunctionMsgSubscription; |
| type P = S7PayloadUserDataItemCpuFunctionMsgSubscriptionOptions; |
| |
| fn get_length_in_bits(&self) -> u32 { |
| todo!() |
| } |
| |
| fn serialize<T: Write>(&self, writer: &mut WriteBuffer<T>) -> Result<usize, Error> { |
| writer.write_u8(self.Subscription)?; |
| ---> DefaultReservedField{referenceValue=0x00} DefaultTypedField{type=AbstractSimpleTypeReference{baseType=UINT, sizeInBits=8}} DefaultField{attributes={}} |
| writer.write_bytes(self.magicKey.as_str())?; |
| self.Alarmtype.serialize(writer)?; |
| writer.write_u8(self.Reserve)?; |
| Ok(0) |
| } |
| |
| fn parse<T: Read>(reader: &mut ReadBuffer<T>, parameter: Option<Self::P>) -> Result<Self::M, Error> { |
| // (Re-)define the options |
| let parameter = parameter.unwrap(); |
| let cpuFunctionType = parameter.cpuFunctionType; |
| let cpuSubfunction = parameter.cpuSubfunction; |
| let Subscription = reader.read_u8()?; |
| // Reserved field |
| let _ = reader.read_u8()?; |
| let magicKey = reader.read_bytes(8 as usize)?;; |
| let Alarmtype = AlarmStateType::parse(reader, None)?; |
| let Reserve = reader.read_u8()?; |
| Ok(Self::M { |
| Subscription, |
| magicKey, |
| Alarmtype, |
| Reserve |
| }) |
| } |
| } |
| |
| |