当前位置: 首页>>代码示例>>C#>>正文


C# ReturnCode.ToString方法代码示例

本文整理汇总了C#中ReturnCode.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# ReturnCode.ToString方法的具体用法?C# ReturnCode.ToString怎么用?C# ReturnCode.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ReturnCode的用法示例。


在下文中一共展示了ReturnCode.ToString方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ReadInitDataSynch

        public void ReadInitDataSynch(int clientSubscriptionIndex)
        {
            //turn dynamic list into array used to subscribe to items
            itemIdentifiers = _itemIdentifiers.ToArray();

            //create return code for subscription result
            Kepware.ClientAce.OpcDaClient.ReturnCode returnCode;
            returnCode = new ReturnCode();

            // Transaction Handle Is the PLC's Index 1 Based So Must Decrement By 1
            int idx = clientSubscriptionIndex - 1;
            int index = 0;

            if (_itemIdentifiers.Count != 0)
            {
                try
                {
                    //temporarily use Synchronous Read.  Calls the normal Callback Handler
                    ItemValue[] itemValues;
                    returnCode = clientAce.DAServer.Read(0, ref itemIdentifiers, out itemValues);

                    //set initial value read to true for each plc and record
                    if (IDCService.IDCConfig.model.plcs[idx].initDataReceived != true)
                    {
                        IDCService.IDCConfig.model.plcs[idx].initDataReceived = true;
                        logger.Debug("Initial data received for PLC: {0}", IDCService.IDCConfig.model.plcs[idx].name);
                    }

                    if (returnCode.ToString() != "SUCCEEDED")
                    {
                        logger.Error("DAServer.Read error: ReturnCode: {0} for PLC: {1}", returnCode, IDCService.IDCConfig.model.plcs[idx].name);
                    }

                    if (itemValues != null)
                    {
                        foreach (ItemValue itemValue in itemValues)
                        {
                            //write values to items within plc.
                            //clientSubscriptionIndex - PLC index
                            //index - item index within PLC
                            if (itemValue.Value != null & itemValue.Quality != null & itemValue.TimeStamp != null)
                            {

                                IDCService.IDCConfig.model.plcs[idx].opcliitems[index].value = itemValue.Value;
                                IDCService.IDCConfig.model.plcs[idx].opcliitems[index].quality = itemValue.Quality.Quality;
                                IDCService.IDCConfig.model.plcs[idx].opcliitems[index].timestamp = itemValue.TimeStamp;
                            }
                            else
                            {
                                logger.Error("ItemVlaue Read returned null values for opccliitem: {0}", IDCService.IDCConfig.model.plcs[idx].opcliitems[index].name);
                            }
                            index++;
                        }
                    }
                }
                catch (Exception ex)
                {
                    logger.Error("ReadInitDataSynch exception. Reason: {0}, PLC: {1}", ex.Message, IDCService.IDCConfig.model.plcs[idx].name);
                }
            }
            else
            {
                logger.Info("There were no items to be initially read.");
            }
        }
开发者ID:bsrpn6,项目名称:IDCServer,代码行数:65,代码来源:IDCModelExtension.cs


注:本文中的ReturnCode.ToString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。