/// <summary> /// This method is used to send a data request to the embedded PTU target using the type of /// device specified in the argument. The difference between this method and the method of the same name /// is that this method is used when there is NO payload with the data request. /// </summary> /// <param name="commDevice">The comm device used to communicate with target</param> /// <param name="packetRequestType">The command sent to the target</param> /// <param name="rxMessage">Used to store the response from the embedded target</param> /// <returns>0 (0) if all is well; otherwise another enumeration which is less than 0</returns> public Int32 SendDataRequestToEmbedded(ICommDevice commDevice, ProtocolPTU.PacketType packetRequestType, Byte[] rxMessage) { // Send the SOM and receive it Int32 commError = (Int32)commDevice.SendReceiveSOM(); // Verify the sending and receiving of SOM is /RX OK if (commError != 0) { return(commError); } // Create the message header for a command and command type; "null" as 1st argument indicates no payload ProtocolPTU.DataPacketProlog dpp = new ProtocolPTU.DataPacketProlog(); Byte[] txMessage = dpp.GetByteArray(null, packetRequestType, ProtocolPTU.ResponseType.DATARESPONSE, commDevice.IsTargetBigEndian()); // Send the command to the target Int32 errorCode = commDevice.SendMessageToTarget(txMessage); if (errorCode < 0) { return(-1); } // Verify the target responds with data errorCode = commDevice.ReceiveTargetDataPacket(rxMessage); if (errorCode < 0) { return(-1); } return(0); }
/// <summary> /// This method is used to send a command to the embedded PTU target using the type of /// device specified in the argument. The difference between this method and the 2 parameter /// method of the same name is that this method is used when there is a payload with the command. /// </summary> /// <param name="commDevice">The comm device used to communicate with target</param> /// <param name="requestObj">This object is a request that already has the all of the necessary payload /// parameters ready to be formed into a message to be sent to embedded target</param> /// <returns>0 (0) if all is well; otherwise another enumeration which is less than 0</returns> public Int32 SendCommandToEmbedded(ICommDevice commDevice, ICommRequest requestObj) { // Send the SOM and receive it Int32 commError = (Int32)commDevice.SendReceiveSOM(); // Verify the sending and receiving of SOM is /RX OK if (commError != 0) { return(commError); } // Create the message header and payload for a command and command type Byte[] txMessage = requestObj.GetByteArray(commDevice.IsTargetBigEndian()); // Send the command and payload to the target Int32 errorCode = commDevice.SendMessageToTarget(txMessage); // Verify the command was sent without errors if (errorCode < 0) { return(errorCode); } // Since no return data is expected, verify the embedded target responds with an Acknowledge (implicit // acknowledge with TCP, but 232 has no such entity errorCode = commDevice.ReceiveTargetAcknowledge(); if (errorCode < 0) { return(errorCode); } return(0); }
/// <summary> /// This method is used to send a command to the embedded PTU target using the type of /// device specified in the argument. The difference between this method and the 3 parameter /// method of the same name is that this method is used when there is no payload with the command. /// </summary> /// <param name="commDevice">The comm device used to communicate with target</param> /// <param name="packetRequestType">The command sent to the target</param> /// <returns>0 (0) if all is well; otherwise another enumeration which is less than 0</returns> public Int32 SendCommandToEmbedded(ICommDevice commDevice, ProtocolPTU.PacketType packetRequestType) { // Send the SOM and receive it Int32 commError = (Int32)commDevice.SendReceiveSOM(); // Verify the sending and receiving of SOM is /RX OK if (commError != 0) { return(commError); } // Create the message header for a command and command type; "null" as 1st argument indicates no payload ProtocolPTU.DataPacketProlog dpp = new ProtocolPTU.DataPacketProlog(); Byte[] txMessage = dpp.GetByteArray(null, packetRequestType, ProtocolPTU.ResponseType.COMMANDRESPONSE, commDevice.IsTargetBigEndian()); // Send the command to the target Int32 errorCode = commDevice.SendMessageToTarget(txMessage); // Verify the command was sent without errors if (errorCode < 0) { return(errorCode); } // Since no return data is expected, verify the embedded target responds with an Acknowledge (implicit // acknowledge with TCP, but 232 has no such entity errorCode = commDevice.ReceiveTargetAcknowledge(); if (errorCode < 0) { return(errorCode); } return(0); }
/// <summary> /// This method is used to send a command to the embedded PTU target using the type of /// device specified in the argument. The difference between this method and the 3 parameter /// method of the same name is that this method is used when there is no payload with the command. /// </summary> /// <param name="commDevice">The comm device used to communicate with target</param> /// <param name="packetRequestType">The command sent to the target</param> /// <returns>CommunicationError.Success (0) if all is well; otherwise another enumeration which is less than 0</returns> public CommunicationError SendCommandToEmbedded(ICommDevice commDevice, ProtocolPTU.PacketType packetRequestType) { // Send the SOM and receive it CommunicationError commError = (CommunicationError)commDevice.SendReceiveSOM(); // Verify the sending and receiving of SOM is /RX OK if (commError != CommunicationError.Success) { return commError; } // Create the message header for a command and command type; "null" as 1st argument indicates no payload ProtocolPTU.DataPacketProlog dpp = new ProtocolPTU.DataPacketProlog(); Byte[] txMessage = dpp.GetByteArray(null, packetRequestType, ProtocolPTU.ResponseType.COMMANDRESPONSE, commDevice.IsTargetBigEndian()); // Send the command to the target Int32 errorCode = commDevice.SendMessageToTarget(txMessage); // Verify the command was sent without errors if (errorCode < 0) { return CommunicationError.BadRequest; } // Since no return data is expected, verify the embedded target responds with an Acknowledge (implicit // acknowledge with TCP, but 232 has no such entity errorCode = commDevice.ReceiveTargetAcknowledge(); if (errorCode < 0) { return CommunicationError.BadResponse; } return CommunicationError.Success; }
/// <summary> /// This method is used to send a data request to the embedded PTU target using the type of /// device specified in the argument. The difference between this method and the method of the same name /// is that this method is used when there is a payload with the data request. /// </summary> /// <param name="commDevice">The comm device used to communicate with target</param> /// <param name="requestObj">This object is a request that already has the all of the necessary payload /// parameters ready to be formed into a message to be sent to embedded target</param> /// <param name="rxMessage">Used to store the response from the embedded target</param> /// <returns>0 (0) if all is well; otherwise another enumeration which is less than 0</returns> public Int32 SendDataRequestToEmbedded(ICommDevice commDevice, ICommRequest requestObj, Byte[] rxMessage) { // Send the SOM and receive it Int32 commError = (Int32)commDevice.SendReceiveSOM(); // Verify the sending and receiving of SOM is /RX OK if (commError != 0) { return(commError); } // Create the message header and payload for a command and command type Byte[] txMessage = requestObj.GetByteArray(commDevice.IsTargetBigEndian()); // Send the command and payload to the target Int32 errorCode = commDevice.SendMessageToTarget(txMessage); if (errorCode < 0) { return(-1); } // Verify the target responds with data errorCode = commDevice.ReceiveTargetDataPacket(rxMessage); if (errorCode < 0) { return(-1); } return(0); }
/// <summary> /// Initialize the communication port. /// </summary> /// <param name="communicationsSetting">The communication settings.</param> /// <exception cref="CommunicationException">Thrown if the error code returned from the call to the PTUDLL32.InitCommunication() method is /// not CommunicationError.Success.</exception> public virtual void InitCommunication(CommunicationSetting_t communicationsSetting) { Int32 error = -1; CommunicationError errorCode = CommunicationError.UnknownError; try { String args = ""; if (communicationsSetting.Protocol == Protocol.RS232) { m_CommDevice = new Serial(); args = "COM" + communicationsSetting.PortIdentifier + "," + ((Int32)communicationsSetting.SerialCommunicationParameters.BaudRate).ToString() + "," + communicationsSetting.SerialCommunicationParameters.Parity.ToString() + "," + ((Int32)communicationsSetting.SerialCommunicationParameters.BitsPerCharacter).ToString() + "," + ((Int32)communicationsSetting.SerialCommunicationParameters.StopBits).ToString(); } else if (communicationsSetting.Protocol == Protocol.TCPIP) { m_CommDevice = new TCP(); args = communicationsSetting.PortIdentifier; } if (m_CommDevice != null) { error = m_CommDevice.Open(args); } } catch (Exception) { errorCode = CommunicationError.SystemException; throw new CommunicationException(Resources.EMPortInitializationFailed, errorCode); } if (DebugMode.Enabled == true) { DebugMode.InitCommunication_t initCommunication = new DebugMode.InitCommunication_t(communicationsSetting.Protocol, communicationsSetting.PortIdentifier, communicationsSetting.SerialCommunicationParameters.BaudRate, communicationsSetting.SerialCommunicationParameters.BitsPerCharacter, communicationsSetting.SerialCommunicationParameters.Parity, communicationsSetting.SerialCommunicationParameters.StopBits, errorCode); DebugMode.Write(initCommunication.ToXML()); } if (error >= 0) { errorCode = CommunicationError.Success; m_WatchClockMarshal = new WatchClockMarshal(m_CommDevice); } if (errorCode != CommunicationError.Success) { throw new CommunicationException(Resources.EMPortInitializationFailed, errorCode); } }
/// <summary> /// Initialize a new instance of the class and set the function delegates, properties and member variables. /// </summary> /// <param name="communicationInterface">Reference to the communication interface containing the properties and member variables that are to /// be used to initialize the class.</param> public CommunicationParent(ICommunicationParent communicationInterface) : this() { m_CommunicationSetting = communicationInterface.CommunicationSetting; m_CommDevice = communicationInterface.CommDevice; m_WatchClockMarshal = communicationInterface.WatchClockMarshall; }
/// <summary> /// Constructor that must be used to create an object of this class. /// </summary> /// <param name="device">the type of communication device (RS-232, TCP, etc.)</param> public SelfTestMarshal(ICommDevice device) { m_CommDevice = device; }
public Event(ICommDevice device) { m_CommDevice = device; }
/// <summary> /// Constructor that initializes a new instance of the CommGen class /// </summary> /// <param name="device">The communication vehicle used to access the PTU target (VCU)</param> public WatchClockMarshal(ICommDevice device) { m_CommDevice = device; m_PtuTargetCommunication = new PtuTargetCommunication(); }
/// <summary> /// /// </summary> /// <param name="device"></param> public Comm(ICommDevice device) { m_CommDevice = device; }
/// <summary> /// This method is used to send a command to the embedded PTU target using the type of /// device specified in the argument. The difference between this method and the 2 parameter /// method of the same name is that this method is used when there is a payload with the command. /// </summary> /// <param name="commDevice">The comm device used to communicate with target</param> /// <param name="requestObj">This object is a request that already has the all of the necessary payload /// parameters ready to be formed into a message to be sent to embedded target</param> /// <returns>CommunicationError.Success (0) if all is well; otherwise another enumeration which is less than 0</returns> public CommunicationError SendCommandToEmbedded(ICommDevice commDevice, ICommRequest requestObj) { // Send the SOM and receive it CommunicationError commError = (CommunicationError)commDevice.SendReceiveSOM(); // Verify the sending and receiving of SOM is /RX OK if (commError != CommunicationError.Success) { return commError; } // Create the message header and payload for a command and command type Byte[] txMessage = requestObj.GetByteArray(commDevice.IsTargetBigEndian()); // Send the command and payload to the target Int32 errorCode = commDevice.SendMessageToTarget(txMessage); // Verify the command was sent without errors if (errorCode < 0) { return CommunicationError.BadRequest; } // Since no return data is expected, verify the embedded target responds with an Acknowledge (implicit // acknowledge with TCP, but 232 has no such entity errorCode = commDevice.ReceiveTargetAcknowledge(); if (errorCode < 0) { return CommunicationError.BadResponse; } return CommunicationError.Success; }
/// <summary> /// This method is used to send a data request to the embedded PTU target using the type of /// device specified in the argument. The difference between this method and the method of the same name /// is that this method is used when there is NO payload with the data request. /// </summary> /// <param name="commDevice">The comm device used to communicate with target</param> /// <param name="packetRequestType">The command sent to the target</param> /// <param name="rxMessage">Used to store the response from the embedded target</param> /// <returns>CommunicationError.Success (0) if all is well; otherwise another enumeration which is less than 0</returns> public CommunicationError SendDataRequestToEmbedded(ICommDevice commDevice, ProtocolPTU.PacketType packetRequestType, Byte[] rxMessage) { // Send the SOM and receive it CommunicationError commError = (CommunicationError)commDevice.SendReceiveSOM(); // Verify the sending and receiving of SOM is /RX OK if (commError != CommunicationError.Success) { return commError; } // Create the message header for a command and command type; "null" as 1st argument indicates no payload ProtocolPTU.DataPacketProlog dpp = new ProtocolPTU.DataPacketProlog(); Byte[] txMessage = dpp.GetByteArray(null, packetRequestType, ProtocolPTU.ResponseType.DATARESPONSE, commDevice.IsTargetBigEndian()); // Send the command to the target Int32 errorCode = commDevice.SendMessageToTarget(txMessage); if (errorCode < 0) { return CommunicationError.BadRequest; } // Verify the target responds with data errorCode = commDevice.ReceiveTargetDataPacket(rxMessage); if (errorCode < 0) { return CommunicationError.BadResponse; } return CommunicationError.Success; }
/// <summary> /// This method is used to send a data request to the embedded PTU target using the type of /// device specified in the argument. The difference between this method and the method of the same name /// is that this method is used when there is a payload with the data request. /// </summary> /// <param name="commDevice">The comm device used to communicate with target</param> /// <param name="requestObj">This object is a request that already has the all of the necessary payload /// parameters ready to be formed into a message to be sent to embedded target</param> /// <param name="rxMessage">Used to store the response from the embedded target</param> /// <returns>CommunicationError.Success (0) if all is well; otherwise another enumeration which is less than 0</returns> public CommunicationError SendDataRequestToEmbedded(ICommDevice commDevice, ICommRequest requestObj, Byte[] rxMessage) { // Send the SOM and receive it CommunicationError commError = (CommunicationError)commDevice.SendReceiveSOM(); // Verify the sending and receiving of SOM is /RX OK if (commError != CommunicationError.Success) { return commError; } // Create the message header and payload for a command and command type Byte[] txMessage = requestObj.GetByteArray(commDevice.IsTargetBigEndian()); // Send the command and payload to the target Int32 errorCode = commDevice.SendMessageToTarget(txMessage); if (errorCode < 0) { return CommunicationError.BadRequest; } // Verify the target responds with data errorCode = commDevice.ReceiveTargetDataPacket(rxMessage); if (errorCode < 0) { return CommunicationError.BadResponse; } return CommunicationError.Success; }
/// <summary> /// Constructor that must be used to create an object of this class. /// </summary> /// <param name="device">the type of communication device (RS-232, TCP, etc.)</param> public EventStreamMarshal(ICommDevice device) { m_CommDevice = device; }
protected void InitilizeComponent(ICommDevice device) { System.Threading.Interlocked.Increment(ref _instanceCount); _device = device; _ringBuffer = new RingBuffer(MaxBufferSize); }
public TcpClient(ICommDevice recloser, string serverAddress, int serverPort) : base(recloser) { this.ServerAddress = serverAddress; this.ServerPort = serverPort; }
public TcpServer(ICommDevice recloser) : base(recloser) { }
public TcpBase(ICommDevice device) { InitilizeComponent(device); }