/// <summary> /// 消息传输I格式, 消息处理完成后处理 /// </summary> /// <param name="n"></param> private void MeeageProcessCompleted(TypeIdentification id) { // BeginInvokeUpdateHistory(id.ToString() + "应答完成"); switch (id) { //主站召唤 case TypeIdentification.C_IC_NA_1: { break; } case TypeIdentification.C_CS_NA_1: //时钟同步 { break; } case TypeIdentification.C_RP_NA_1: //复位经进程命令 { break; } case TypeIdentification.M_EI_NA_1: //初始化结束命令 { break; } default: { break; } } }
public void GetAll() { // Arrange var builder = new DbContextOptionsBuilder <CarvajalDbContext>(); var options = builder.UseInMemoryDatabase(Guid.NewGuid().ToString()).Options; using var context = new CarvajalDbContext(options); context.Database.EnsureDeleted(); var entity = new TypeIdentification { Description = "Cedula Ciudadania" }; context.TypeIdentifications.Add(entity); context.SaveChanges(); // Action var repository = new TypeIdentificationRepository(context); var entities = repository.GetAll(); // Assert Assert.True(entities != null); Assert.True(entities.Count() > 0); Assert.True(entities.LastOrDefault().Description == "Cedula Ciudadania"); }
/// <summary> /// 消息传输I格式, 消息处理未完成后处理 /// </summary> /// <param name="id"></param> private void MeeageProcessNoCompleted(TypeIdentification id) { Action <string> myDelegate = UpdateReciveTxt; Dispatcher.BeginInvoke(myDelegate, "应答失败\n"); switch (id) { //主站召唤 case TypeIdentification.C_IC_NA_1: { break; } case TypeIdentification.C_CS_NA_1: //时钟同步 { break; } case TypeIdentification.C_RP_NA_1: //复位经进程命令 { break; } case TypeIdentification.M_EI_NA_1: //初始化结束命令 { break; } default: { break; } } }
/// <summary> /// Insert typeidentificacion method repository /// </summary> /// <param name="typeIdentificacion">Tipo de identificacion model</param> /// <returns>Type Identificacion create</returns> public async Task <TypeIdentification> CreateTypeIdentification(TypeIdentification typeIdentificacion) { DynamicParameters parameters = new DynamicParameters(); parameters.Add(HelpersEnums.GetEnumDescription(EnumTypeIdentificationParameters.ID), Guid.NewGuid()); parameters.Add(HelpersEnums.GetEnumDescription(EnumTypeIdentificationParameters.Description), typeIdentificacion.Description); parameters.Add(HelpersEnums.GetEnumDescription(EnumTypeIdentificationParameters.CREATED_BY), typeIdentificacion.CreatedBy); parameters.Add(HelpersEnums.GetEnumDescription(EnumTypeIdentificationParameters.CREATED_ON), typeIdentificacion.CreatedOn); parameters.Add(HelpersEnums.GetEnumDescription(EnumTypeIdentificationParameters.STATE), typeIdentificacion.State); return(await GetAsyncFirst <TypeIdentification>(QueryTypeIdentification.InsertTypeIdentification, parameters, CommandType.Text)); }
/// <summary> /// 获取电能脉冲 /// </summary> /// <param name="id">类型ID</param> /// <param name="dataArray">原始字节数组</param> private void GetElectricEnergy(TypeIdentification id, byte[] dataArray) { try { var message = new APDU(dataArray); ElectricEnergyArrived(this, new TransmitEventArgs <TypeIdentification, APDU>(id, message)); } catch (Exception ex) { throw ex; } }
/// <summary> /// 获取遥控 /// </summary> /// <param name="id">类型ID</param> /// <param name="dataArray">原始字节数组</param> public void GetTelecotrolCommand(TypeIdentification id, byte[] dataArray) { try { var message = new APDU(dataArray); TelecontrolCommandArrived(this, new TransmitEventArgs <TypeIdentification, APDU>(id, message)); } catch (Exception ex) { throw ex; } }
/// <summary> /// MasterCommand 命令 不含信息体 /// </summary> /// <param name="typeID">类型ID</param> /// <param name="transmitSeqNum">发送序列号</param> /// <param name="ReceiveSeqNum">接收序列号</param> /// <param name="cot">传输原因</param> /// <param name="asduPublicAddress">ASDU公共地址</param> /// <param name="objectAddress">信息对象地址</param> public MasterCommand(UInt16 transmitSeqNum, UInt16 ReceiveSeqNum, TypeIdentification typeID, CauseOfTransmissionList cot, UInt16 asduPublicAddress) { ASDU = new ApplicationServiceDataUnit((byte)typeID, (byte)1, false, (byte)cot, asduPublicAddress); //信息对象地址为0 ASDU.InformationObject[0] = 0; ASDU.InformationObject[1] = 0; ASDU.InformationObject[2] = 0; var apduLen = 4 + ASDU.Length; //控制域长度4 + ASDU长度 APCI = new APCITypeI((byte)apduLen, transmitSeqNum, ReceiveSeqNum); TimeStamp = DateTime.Now; }
/// <summary> /// APDU初始化 /// </summary> /// <param name="transmitSeqNum">发送序列号</param> /// <param name="ReceiveSeqNum">接收序列号</param> /// <param name="typeID">类型ID</param> /// <param name="isquense">是否序列号 true-序列化 false-非序列化</param> /// <param name="objectCount">信息对象数目数目</param> /// <param name="cot">传输原因</param> /// <param name="ASDUPublicAddress">公共地址</param> public APDU(UInt16 transmitSeqNum, UInt16 ReceiveSeqNum, TypeIdentification typeID, bool isquense, byte objectCount, CauseOfTransmissionList cot, UInt16 ASDUPublicAddress, UInt32 objectAddress) { ASDU = new ApplicationServiceDataUnit((byte)typeID, objectCount, isquense, (byte)cot, ASDUPublicAddress); //信息对象地址为0 ASDU.InformationObject[0] = ElementTool.GetBit7_0(objectAddress); ASDU.InformationObject[1] = ElementTool.GetBit15_8(objectAddress); ASDU.InformationObject[2] = ElementTool.GetBit23_16(objectAddress); var apduLen = 4 + ASDU.Length; //控制域长度4 + ASDU长度 APCI = new APCITypeI((byte)apduLen, transmitSeqNum, ReceiveSeqNum); TimeStamp = DateTime.Now; }
/// <summary> /// 主站发送TypeI-测量值参数/参数激活 /// </summary> /// <param name="id"></param> /// <param name="apdu"></param> private void SendTypeIMessage(TypeIdentification id, APDU apdu) { try { eventTypeIDManager.AddEventProcess(new EventProperty(id)); var array = apdu.GetAPDUDataArray(); MainTypeIProcess(array, array.Length, appMessageManager.WaitTime, id); appMessageManager.UpdateTransmitSequenceNumber(); } catch (Exception ex) { MessageBox.Show(ex.Message, "SendTypeIMessage主站遥控命令"); } }
/// <summary> /// MasterCommand APDU初始化结束命令 /// </summary> /// <param name="typeID">类型ID</param> /// <param name="transmitSeqNum">发送序列号</param> /// <param name="ReceiveSeqNum">接收序列号</param> /// <param name="cot">传输原因</param> /// <param name="asduPublicAddress">ASDU公共地址</param> /// <param name="objectAddress">信息对象地址</param> /// <param name="coi">初始化原因coi</param> public MasterCommand(UInt16 transmitSeqNum, UInt16 ReceiveSeqNum, TypeIdentification typeID, CauseOfTransmissionList cot, UInt16 asduPublicAddress, UInt32 objectAddress, CauseOfInitialization coi) { ASDU = new ApplicationServiceDataUnit((byte)typeID, (byte)1, false, (byte)cot, asduPublicAddress); //信息对象地址为0 ASDU.InformationObject[0] = ElementTool.GetBit7_0(objectAddress); ASDU.InformationObject[1] = ElementTool.GetBit15_8(objectAddress); ASDU.InformationObject[2] = ElementTool.GetBit23_16(objectAddress); ASDU.InformationObject[3] = (byte)coi; var apduLen = 4 + ASDU.Length; //控制域长度4 + ASDU长度 APCI = new APCITypeI((byte)apduLen, transmitSeqNum, ReceiveSeqNum); TimeStamp = DateTime.Now; }
/// <summary> /// 消息传输I格式 处理流程 /// </summary> /// <param name="data">消息帧转化后,发送的字节数组</param> /// <param name="len">发送的数据长度</param> /// <param name="ms">超时时间,单位ms</param> /// <param name="id">类型</param> private bool MainTypeIProcess(byte[] data, int len, int ms, TypeIdentification id) { if (data.Length < len) { return(false); } var mStartEvent = eventTypeIDManager.GetEventProcess(id); var process = new ProcessControl <byte[], TypeIdentification, TypeIdentification>(data, id, id, StartMessageProcess, MeeageProcessCompleted, MeeageProcessNoCompleted, ms, mStartEvent.Event); process.StartProcessThread(); processList.Add(process); BeginInvokeUpdateHistory(data, len, "主站发送:I帧"); return(true); }
/// <summary> /// 获取文件服务信息 /// </summary> /// <param name="id">类型ID</param> /// <param name="dataArray">原始字节数组</param> private void GetFileServertMessage(TypeIdentification id, byte[] dataArray) { try { var message = new FilePacket(dataArray); switch (id) { case TypeIdentification.F_FR_NA_1_NR: { FileServerArrived(this, new TransmitEventArgs <TypeIdentification, FilePacket>(id, message)); break; } } } catch (Exception ex) { throw ex; } }
/// <summary> /// 获取保护定值设置信息 /// </summary> /// <param name="id">类型ID</param> /// <param name="dataArray">原始字节数组</param> private void GetProtectsetPointMessage(TypeIdentification id, byte[] dataArray) { try { var message = new APDU(dataArray); switch (id) { case TypeIdentification.C_SE_NC_1: // 保护定值 { ProtectSetMessageArrived(this, new TransmitEventArgs <TypeIdentification, APDU>(id, message)); break; } } } catch (Exception ex) { throw ex; } }
/// <summary> /// 获取校准信息 /// </summary> /// <param name="id">类型ID</param> /// <param name="dataArray">原始字节数组</param> private void GetCalibrationMessage(TypeIdentification id, byte[] dataArray) { try { var message = new APDU(dataArray); switch (id) { case TypeIdentification.P_AC_NA_1: // 参数激活 case TypeIdentification.P_ME_NC_1: // 测量值参数,短浮点数 { CalibrationMessageArrived(this, new TransmitEventArgs <TypeIdentification, APDU>(id, message)); break; } } } catch (Exception ex) { throw ex; } }
/// <summary> /// 获取主站系统命令信息 /// </summary> /// <param name="id">类型ID</param> /// <param name="dataArray">原始字节数组</param> public void GetMasterComand(TypeIdentification id, byte[] dataArray) { try { var cmd = new MasterCommand(dataArray); switch (id) { //主站系统命令 case TypeIdentification.C_IC_NA_1: //总召唤/组召唤 { MasterInterrogationArrived(this, new MasterCommmadEventArgs(cmd)); break; } case TypeIdentification.C_RP_NA_1: //复位进程命令 { MasterResetArrived(this, new MasterCommmadEventArgs(cmd)); break; } case TypeIdentification.M_EI_NA_1: //初始化结束 { MasterInitializeArrived(this, new MasterCommmadEventArgs(cmd)); break; } case TypeIdentification.C_CS_NA_1: //时钟同步 { MasterTimeArrived(this, new MasterCommmadEventArgs(cmd)); break; } } } catch (Exception ex) { throw ex; } }
/// <summary> /// 获取遥测信息 /// </summary> /// <param name="id">类型ID</param> /// <param name="dataArray">原始字节数组</param> public void GetTelemeteringMessage(TypeIdentification id, byte[] dataArray) { try { var message = new APDU(dataArray); switch (id) { //遥信信息 case TypeIdentification.M_ME_NA_1: //测量值,归一化值 case TypeIdentification.M_ME_NC_1: //测量值,短浮点数 case TypeIdentification.M_ME_TD_1: //带CP56Time2a时标的测量值,归一化值 case TypeIdentification.M_ME_TF_1: //带CP56Time2a时标的测量值,短浮点数 { TelemeteringMessageArrived(this, new TransmitEventArgs <TypeIdentification, APDU>(id, message)); break; } } } catch (Exception ex) { throw ex; } }
/// <summary> /// 获取遥信信息 /// </summary> /// <param name="id">类型ID</param> /// <param name="dataArray">原始字节数组</param> public void GetTelesignalisationMessage(TypeIdentification id, byte[] dataArray) { try { var message = new APDU(dataArray); switch (id) { //遥信信息 case TypeIdentification.M_SP_NA_1: //单点信息 case TypeIdentification.M_DP_NA_1: //双点信息 case TypeIdentification.M_SP_TB_1: //带CP56Time2a时标的单点信息 case TypeIdentification.M_DP_TB_1: //带CP56Time2a时标的双点信息 { TelesignalisationMessageArrived(this, new TransmitEventArgs <TypeIdentification, APDU>(id, message)); break; } } } catch (Exception ex) { throw ex; } }
public async Task <TypeIdentification> UpdateTypeIdentification(TypeIdentification TypeIdentification) { return(await this._TypeIdentificationService.Update(TypeIdentification)); }
public async Task <TypeIdentification> CreateTypeIdentification([FromBody] TypeIdentification TypeIdentification) { return(await this._TypeIdentificationService.Create(TypeIdentification)); }
protected virtual void Dispose(bool disposing) { if (!disposedValue) { if (disposing) { // TODO: eliminar el estado administrado (objetos administrados) if (Language != null) { Language.Dispose(); } if (Menu != null) { Menu.Dispose(); } if (Parameters != null) { Parameters.Dispose(); } if (Roles != null) { Roles.Dispose(); } if (RolMenu != null) { RolMenu.Dispose(); } if (Third != null) { Third.Dispose(); } if (ThirdType != null) { ThirdType.Dispose(); } if (TypeIdentification != null) { TypeIdentification.Dispose(); } if (UserInfoDetail != null) { UserInfoDetail.Dispose(); } if (User != null) { User.Dispose(); } if (UserRoles != null) { UserRoles.Dispose(); } if (UserStatus != null) { UserStatus.Dispose(); } } // TODO: liberar los recursos no administrados (objetos no administrados) y reemplazar el finalizador // TODO: establecer los campos grandes como NULL disposedValue = true; } }
/// <summary> /// 移除指定typeID的类型EventProperty /// </summary> /// <param name="typeID">类型ID</param> public void RemoveEventProcess(TypeIdentification typeID) { eventList.Remove(eventList.Find(x => x.TypeID == typeID)); }
public async Task <TypeIdentification> Update(TypeIdentification typeIdentification) { return(await this.asyncRepository.UpdateAsync(typeIdentification)); }
/// <summary> /// 查找是否包含指定typeID的类型EventProperty,若有则返回。 /// </summary> /// <param name="typeID">类型ID</param> /// <returns>EventProperty</returns> public EventProperty GetEventProcess(TypeIdentification typeID) { return(eventList.Find(x => x.TypeID == typeID)); }