Пример #1
0
        public void ExecuteDeviceCommand(object param)
        {
            DeviceControlCommands command = (DeviceControlCommands)param;
            OperationTask         task    = new OperationTask
            {
                OperationToExecute = WorkerTasks.ExecutingCommand,
                OperationArgument  = command
            };

            ChannelReady = false;
            _worker.RunWorkerAsync(task);
        }
Пример #2
0
 public string ExecuteDeviceCommand(DeviceControlCommands command)
 {
     if (_modbusSerial == null)
     {
         return("Нет подключения");
     }
     try
     {
         _modbusSerial.WriteMultipleRegisters(SlaveAddress, RegisterMappingOffsets.ControlRegisterOffset, new [] { (ushort)command });
     }
     catch (Exception exception)
     {
         return(exception.Message);
     }
     return("OK");
 }
Пример #3
0
        ///// <summary>首次连接数据库时初始化数据,仅用于实体类重载,用户不应该调用该方法</summary>
        //[EditorBrowsable(EditorBrowsableState.Never)]
        //protected override void InitData()
        //{
        //    base.InitData();

        //    // InitData一般用于当数据表没有数据时添加一些默认数据,该实体类的任何第一次数据库操作都会触发该方法,默认异步调用
        //    // Meta.Count是快速取得表记录数
        //    if (Meta.Count > 0) return;

        //    // 需要注意的是,如果该方法调用了其它实体类的首次数据库操作,目标实体类的数据初始化将会在同一个线程完成
        //    if (XTrace.Debug) XTrace.WriteLine("开始初始化{0}[{1}]数据……", typeof(Device).Name, Meta.Table.DataTable.DisplayName);

        //    var entity = new Device();
        //    entity.Serialnum = "abc";
        //    entity.CreateTime = DateTime.Now;
        //    entity.CreateSysUserSerialnum = "abc";
        //    entity.UpdateTime = DateTime.Now;
        //    entity.UpdateSysUserSerialnum = "abc";
        //    entity.Name = "abc";
        //    entity.FacilitySerialnum = "abc";
        //    entity.DeviceTypeSerialnum = "abc";
        //    entity.PhotoUrl = "abc";
        //    entity.OnlineStatus = true;
        //    entity.IsException = true;
        //    entity.ProcessedValue = 0;
        //    entity.ShowValue = "abc";
        //    entity.Unit = "abc";
        //    entity.Location = "abc";
        //    entity.Status = 0;
        //    entity.Sort = 0;
        //    entity.Remark = "abc";
        //    entity.Insert();

        //    if (XTrace.Debug) XTrace.WriteLine("完成初始化{0}[{1}]数据!", typeof(Device).Name, Meta.Table.DataTable.DisplayName);
        //}

        /// <summary>已重载。删除关联数据</summary>
        /// <returns></returns>
        protected override int OnDelete()
        {
            if (DeviceControlCommands != null)
            {
                DeviceControlCommands.Delete();
            }
            if (DeviceControlLogs != null)
            {
                DeviceControlLogs.Delete();
            }
            if (DeviceDataExceptionLogs != null)
            {
                DeviceDataExceptionLogs.Delete();
            }
            if (DeviceDataInfos != null)
            {
                DeviceDataInfos.Delete();
            }
            if (DeviceExceptionSets != null)
            {
                DeviceExceptionSets.Delete();
            }
            if (DeviceRunLogs != null)
            {
                DeviceRunLogs.Delete();
            }
            if (DeviceRunningStatisticss != null)
            {
                DeviceRunningStatisticss.Delete();
            }
            if (DeviceTimeSharingStatisticss != null)
            {
                DeviceTimeSharingStatisticss.Delete();
            }
            if (ExceptionSmss != null)
            {
                ExceptionSmss.Delete();
            }

            return(base.OnDelete());
        }