コード例 #1
0
 private void Read(string address, OpResult result, IAddressableEncoder encoder, IDecoder decoder, Action <OpResult, IEncoder, IDecoder> dataGotAction)
 {
     if (result.CheckNotNullOrWhiteSpace(address, SR.ArgumentIsNullOrEmpty))
     {
         FinsFrame frame = NewFrame();
         frame.MRC = 01;
         frame.SRC = 01;
         if (result.CheckTrue(encoder.FillAddress(address), SR.WrongAddressFormat))
         {
             frame.Content = encoder.Encode();
             var buffer = frame.Encode();
             try
             {
                 int count = _client.Send(buffer, buffer.Length);
                 buffer = _client.Receive(ref _remoteEndpoint);
                 var decodeFrame = new FinsFrame();
                 if (result.CheckTrue(decodeFrame.Decode(buffer), SR.DecodeError))
                 {
                     if (result.CheckTrue(decoder.Decode(decodeFrame.Content), SR.DecodeError))
                     {
                         dataGotAction?.Invoke(result, encoder, decoder);
                     }
                 }
             }
             catch (Exception ex)
             {
                 result.SetException(ex, SR.CallServiceException);
             }
         }
     }
 }
コード例 #2
0
        protected FinsFrame NewFrame()
        {
            var frame = new FinsFrame();

            Options.CopyTo(frame);
            return(frame);
        }