/// <summary> /// Construtor que recebe os atributos do Objeto Project a ser criados /// </summary> /// <param name="name">Nome do Projeto</param> /// <param name="licenseId">License ID da licença que pertence ao Projeto</param> /// <param name="permissionId">Permission ID da base que pertence ao Projeto</param> /// <param name="description">Descrição do projeto</param> /// <param name="fileType">Tipo de Arquivo que será usado na integração</param> /// <param name="divisorChar">Caracter divisor do arquivo</param> /// <param name="fileName">Nome do arquivo que será importado</param> /// <param name="errorEmail">E-mail em caso de erros na integração do projeto</param> /// <param name="sendType">Tipo de Envio</param> /// <param name="ignoreFirstLine">Boolean para Ignorar ou não o cabeçalho</param> public CreateProjectCommand(string name, Guid licenseId, Guid permissionId, string description, EFileType fileType, char divisorChar, string fileName, string errorEmail, ESendType sendType, bool ignoreFirstLine) { Name = name; LicenseId = licenseId; PermissionId = permissionId; Description = description; FileType = fileType; DivisorChar = divisorChar; FileName = fileName; ErrorEmail = errorEmail; SendType = sendType; IgnoreFirstLine = ignoreFirstLine; ProjectStatus = EProjectStatus.Active; }
/// <summary> /// 发送数据 /// </summary> /// <param name="canBusId"></param> /// <param name="canIndex"></param> /// <param name="wData"></param> /// <param name="rData"></param> /// <param name="er"></param> /// <param name="wTimeOut"></param> /// <param name="remoteFlag"></param> /// <param name="externFlag"></param> /// <param name="sendType"></param> /// <param name="recvFlag"></param> /// <returns></returns> public bool SendCmd(UInt32 canBusId, string canIndex, string wData, out string rData, out string er, int wTimeOut = 100, ERemoteFlag remoteFlag = ERemoteFlag.数据帧, EExternFlag externFlag = EExternFlag.标准帧, ESendType sendType = ESendType.正常发送, bool recvFlag = true) { rData = string.Empty; er = string.Empty; try { if (!_devOpen) { er = "CanBus总线未打开"; return(false); } if (VCI_ClearBuffer(_devType, _canBusId, canBusId) != STATUS_OK) { er = "清除缓存失败"; return(false); } VCI_CAN_OBJ sendobj = new VCI_CAN_OBJ(); sendobj.Init(); sendobj.SendType = (byte)sendType; sendobj.RemoteFlag = (byte)remoteFlag; sendobj.ExternFlag = (byte)externFlag; sendobj.ID = System.Convert.ToUInt32(canIndex, 16); int len = wData.Length / 2; sendobj.DataLen = System.Convert.ToByte(len); for (int i = 0; i < len; i++) { sendobj.Data[i] = System.Convert.ToByte(wData.Substring(i * 2, 2), 16); } if (VCI_Transmit(_devType, _canBusId, canBusId, ref sendobj, 1) != STATUS_OK) { er = "发送数据失败"; return(false); } //不接收数据 if (!recvFlag) { return(true); } //接收数据 UInt32 getRecNum = 0; int waitTimes = System.Environment.TickCount; while (System.Environment.TickCount - waitTimes < wTimeOut) { UInt32 res = new UInt32(); res = VCI_GetReceiveNum(_devType, _canBusId, canBusId); if (res == 0) { continue; } getRecNum = res; break; } if (getRecNum == 0) { er = "接收数据超时"; return(false); } UInt32 con_maxlen = 50; IntPtr pt = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(VCI_CAN_OBJ)) * (Int32)con_maxlen); UInt32 resLen = VCI_Receive(_devType, _canBusId, canBusId, pt, con_maxlen, wTimeOut); rData = string.Empty; for (UInt32 i = 0; i < resLen; i++) { VCI_CAN_OBJ obj = (VCI_CAN_OBJ)Marshal.PtrToStructure((IntPtr)((UInt32)pt + i * Marshal.SizeOf(typeof(VCI_CAN_OBJ))), typeof(VCI_CAN_OBJ)); if (obj.RemoteFlag == 0) //数据帧 { byte rLen = (byte)(obj.DataLen % 9); for (byte j = 0; j < rLen; j++) { rData += obj.Data[j].ToString("X2"); } } } Marshal.FreeHGlobal(pt); return(true); } catch (Exception ex) { er = ex.ToString(); return(false); } }
public void ChangeSendType(Project project, ESendType newType) { project.ChangeSendType(newType); _repository.Update(project); }
/// <summary> /// Método para alterar o tipo de envio do Projeto /// </summary> /// <param name="newType">Novo tipo de envio</param> public void ChangeSendType(ESendType newType) { this.SendType = newType; }