Exemplo n.º 1
0
        private void OkBTN_Click(object sender, EventArgs e)
        {
            try
            {
                #region Task #B4 - Call a Method
                List <object> inputArguments = new List <object>();

                TutorialModel.CalibrationDataType d = new TutorialModel.CalibrationDataType();
                d.Period = 10;
                d.Offset = 20;
                inputArguments.Add(new Variant(new ExtensionObject(d)));

                /*
                 * byte[] buffer1 = BitConverter.GetBytes((double)1);
                 * byte[] buffer2 = BitConverter.GetBytes((double)2);
                 *
                 * ExtensionObject ex = new ExtensionObject();
                 * ex.TypeId = new ExpandedNodeId(238, "http://somecompany.com/TutorialModel");
                 * ex.Body = Utils.Append(buffer1, buffer2);
                 *
                 * inputArguments.Add(new Variant(ex));
                 *
                 * for (int ii = 0; ii < m_firstOutputArgument; ii++)
                 * {
                 * Variant value = (Variant)ArgumentsLV.Items[ii].Tag;
                 * inputArguments.Add(value.Value);
                 * }
                 */

                IList <object> outputArguments = m_session.Call(m_objectId, m_methodId, inputArguments.ToArray());

                for (int ii = m_firstOutputArgument; ii - m_firstOutputArgument < outputArguments.Count && ii < ArgumentsLV.Items.Count; ii++)
                {
                    Variant value = new Variant(outputArguments[ii - m_firstOutputArgument]);
                    ArgumentsLV.Items[ii].SubItems[2].Text = value.ToString();
                }

                MessageBox.Show("Call succeeded.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                #endregion
            }
            catch (Exception exception)
            {
                ClientUtils.HandleException(this.Text, exception);
            }
        }
Exemplo n.º 2
0
        private void OkBTN_Click(object sender, EventArgs e)
        {
            try
            {
                #region Task #B4 - Call a Method
                List<object> inputArguments = new List<object>();

                TutorialModel.CalibrationDataType d = new TutorialModel.CalibrationDataType();
                d.Period = 10;
                d.Offset = 20;
                inputArguments.Add(new Variant(new ExtensionObject(d)));
             
                /*
             byte[] buffer1 = BitConverter.GetBytes((double)1);
             byte[] buffer2 = BitConverter.GetBytes((double)2);

             ExtensionObject ex = new ExtensionObject();
             ex.TypeId = new ExpandedNodeId(238, "http://somecompany.com/TutorialModel");
             ex.Body = Utils.Append(buffer1, buffer2);

             inputArguments.Add(new Variant(ex));
             
             for (int ii = 0; ii < m_firstOutputArgument; ii++)
             {
                 Variant value = (Variant)ArgumentsLV.Items[ii].Tag;
                 inputArguments.Add(value.Value);
             }
             */

                IList<object> outputArguments = m_session.Call(m_objectId, m_methodId, inputArguments.ToArray());

                for (int ii = m_firstOutputArgument; ii-m_firstOutputArgument < outputArguments.Count && ii < ArgumentsLV.Items.Count; ii++)
                {
                    Variant value = new Variant(outputArguments[ii-m_firstOutputArgument]);
                    ArgumentsLV.Items[ii].SubItems[2].Text = value.ToString();
                }

                MessageBox.Show("Call succeeded.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
                #endregion
            }
            catch (Exception exception)
            {
                ClientUtils.HandleException(this.Text, exception);
            }
        }