Пример #1
0
        void WriteItems(OPCGroup ObjOPCGroup)
        {
            try
            {
                while (!stopThreads)
                {
                    if (Workflow.plcInputs != null && Workflow.plcInputs.Count > 0)
                    {
                        CurrentPLCInput = Workflow.plcInputs.First();
                        if (previousPLCInput == null || !previousPLCInput.Equals(CurrentPLCInput))
                        {
                            int index = Globals.INPUT_TAGS.FirstOrDefault(x => x.Name == "iPLC_STATUS").Index;
                            ItemServerWriteValues.SetValue(CurrentPLCInput.iPlc_Status, index);
                            // ItemServerWriteValues.SetValue(CurrentTestInput.input_bool, 1);
                            // ItemServerWriteValues.SetValue(CurrentTestInput.input_int, 2);
                            try
                            {
                                ObjOPCGroup.SyncWrite(tagIndexWriter - 1, ref writerItemServerHandles, ref ItemServerWriteValues, out writerItemServerErrors);
                            }
                            catch (Exception ex)
                            {
                                Console.WriteLine(ex.Message);
                                throw;
                            }
                            previousPLCInput = CurrentPLCInput;
                        }
                    }

                    //ItemServerWriteValues.SetValue(1.1, Array.IndexOf(OPCItemIDs,(object)("Bucket Brigade.Real1")));
                    System.Threading.Thread.Sleep(1000);
                }
            }
            catch (Exception ex)
            {
                Console.Write(ex.Message);
                throw;
            }
        }