public static void AddParameterToGlobal(string key, string value) { SetCustomFile(); ServiceDataType type = Helper.ServiceData.SupposeDataType(value); var booleanVerbs = Helper.ServiceData.SupposeBooleanVerbs(value); var line = new LineModel() { FilePath = $"{DIR}/{antdSyslogngFile}", Key = key, Value = value, Type = type, BooleanVerbs = booleanVerbs }; var shares = MapFile.Get().Share; var data = MapFile.Get().Data; data.Add(line); var syslogng = new SyslogngModel() { _Id = serviceGuid, Guid = serviceGuid, Timestamp = Timestamp.Now, Share = shares, Data = data }; DeNSo.Session.New.Set(syslogng); }
//-------------- сравнение служебной информации пакета с текущими настройками ------------------------ private bool CheckCorrectionMess(byte[] data) { ServiceDataType NewData = new ServiceDataType(); if (ComPort.ReceiveBuffCount < 7) return false; try { NewData.serialNumber = (UInt32)(data[0] * 0x1000000 + data[1] * 0x10000 + data[2] * 0x100 + data[3]); if (NewData.serialNumber == 0xF00F0FF0) return true; if (ComPort.ReceiveBuffCount != data[5]) return false; NewData.functionCode = data[4]; NewData.length = data[5]; NewData.ID = BitConverter.ToUInt16(data, NewData.length - 4); NewData.CRC16 = BitConverter.ToUInt16(data, NewData.length - 2); } catch (Exception) { return false; } // проверяем if (NewData.CRC16 != getCRC(data, NewData.length)) return false; if (NewData.serialNumber != ServiceData.serialNumber) return false; if (NewData.functionCode != ServiceData.functionCode) return false; if (NewData.ID != ServiceData.ID) return false; return true; }
/// <summary> /// /// </summary> /// <param name="pos">Position of return value (starts at 1)</param> /// <param name="name">Name of return value</param> /// <param name="dataType">Datatype of return value</param> /// <param name="value">Value of return value</param> public ServiceReturn(int pos, string name, ServiceDataType dataType, string value = "") { this.Position = pos; this.Name = name; this.DataType = dataType; this.value = value; }
/// <summary> /// /// </summary> /// <param name="position">Position of arguments (starts at 1)</param> /// <param name="name">Name of argument</param> /// <param name="dataType">Datatype of argument</param> /// <param name="mandatory">Whether the argument is mandatory or not</param> /// <param name="value">Value of argument</param> public ServiceArgument(int position, string name, ServiceDataType dataType, bool mandatory = false, string value = "") { this.Position = position; this.Name = name; this.DataType = dataType; this.Mandatory = mandatory; this.Value = value; }
private static LineModel ConvertData(ServiceSyslogng parameter) { ServiceDataType type = Helper.ServiceData.SupposeDataType(parameter.DataValue); var booleanVerbs = Helper.ServiceData.SupposeBooleanVerbs(parameter.DataValue); var data = new LineModel() { FilePath = parameter.DataFilePath, Key = parameter.DataKey, Value = parameter.DataValue, Type = type, BooleanVerbs = booleanVerbs }; return(data); }
//-------------- сравнение служебной информации пакета с текущими настройками ------------------------ private bool CheckCorrectionMess(byte[] data) { ServiceDataType NewData = new ServiceDataType(); NewData.serialNumber = (UInt32)(data[0] * 0x1000000 + data[1] * 0x10000 + data[2] * 0x100 + data[3]); NewData.functionCode = data[4]; NewData.length = data[5]; NewData.ID = BitConverter.ToUInt16(data, NewData.length - 4); NewData.CRC16 = BitConverter.ToUInt16(data, NewData.length - 2); // проверяем if (NewData.CRC16 != getCRC(data, NewData.length)) return false; if (NewData.serialNumber != ServiceData.serialNumber) return false; if (NewData.functionCode != ServiceData.functionCode) return false; if (NewData.ID != ServiceData.ID) return false; return true; }
/// <summary> /// Return the datatype as a string /// </summary> /// <param name="dataType">datatype</param> /// <returns> /// int /// char /// string /// double /// float /// short /// long /// </returns> public static string TypeToString(ServiceDataType dataType) { return(dataType.ToString().Substring(1)); }
public ServiceData(ServiceDataType type, bool isArray = false) { DataType = type; IsArray = isArray; }