s7_comm/builder/
job_setup.rs1use crate::packet::{Frame, Header, Job, SetupCommunication};
2
3#[derive(Default)]
4pub struct FrameJobSetupBuilder {
5 pdu_ref: u16,
6 max_amq_calling: u16,
7 max_amq_called: u16,
8 pdu_length: u16,
9}
10
11impl FrameJobSetupBuilder {
12 pub fn pdu_ref(mut self, pdu_ref: u16) -> Self {
13 self.pdu_ref = pdu_ref;
14 self
15 }
16 pub fn max_amq_calling(mut self, max_amq_calling: u16) -> Self {
17 self.max_amq_calling = max_amq_calling;
18 self
19 }
20 pub fn max_amq_called(mut self, max_amq_called: u16) -> Self {
21 self.max_amq_called = max_amq_called;
22 self
23 }
24 pub fn pdu_length(mut self, pdu_length: u16) -> Self {
25 self.pdu_length = pdu_length;
26 self
27 }
28 pub fn build(self) -> Frame {
29 let Self {
30 pdu_ref,
31 max_amq_calling,
32 max_amq_called,
33 pdu_length,
34 } = self;
35 let header = Header::init(pdu_ref, 8, 0);
36 let setup = SetupCommunication::init(max_amq_calling, max_amq_called, pdu_length);
37 let job = Job::SetupCommunication(setup);
38 Frame::Job { header, job }
39 }
40}