public override void EvaluateArgumentsOfInstruction() { IDataType d = (GetArgument(CommonSCKeys.Conditional) as ConditionalInstruction)?.RunInstruction().GetReturnDataVal(); if (d != null) { conditionIsTrue = (bool)d.GetValue(); } }
//dat파일 파싱 private void ParsingDataFileToJson(out List <string> scichartKeyList, string filePath) { jArrayResult = new JArray(); scichartKeyList = new List <string>(); JArray jsonFormatArray = formatJson.Value <JArray>(JSON); IEnumerator enumerator = jsonFormatArray.GetEnumerator(); scichartKeyList.Clear(); while (enumerator.MoveNext()) { JObject fieldFormatJson = enumerator.Current as JObject; string fieldName = fieldFormatJson.Value <string>(NAME); scichartKeyList.Add(fieldName); } enumerator.Reset(); //전체 바이트 길이 중 1번에 해당하는 offset int obj_byte_length = 100; try { using (BinaryReader binaryReader = new BinaryReader(File.Open(filePath, FileMode.Open))) { long lCurOffset = 0L; while (true) { byte[] bytes = binaryReader.ReadBytes(obj_byte_length); sbyte[] sBytes = Array.ConvertAll(bytes, b => unchecked ((sbyte)b)); JObject rawDataModel; Dictionary <string, object> nameAndTypeAndValueDictionary = new Dictionary <string, object>(); if (sBytes.Length <= 0) { break; } int startPoint = 0; rawDataModel = new JObject(); while (enumerator.MoveNext()) { JObject fieldFormatJson = enumerator.Current as JObject; string fieldName = fieldFormatJson.Value <string>(NAME); int fieldSize = fieldFormatJson.Value <int>(SIZE); string fieldType = fieldFormatJson.Value <string>(TYPE); sbyte[] byteForParsing = new sbyte[fieldSize]; Array.Copy(sBytes, startPoint, byteForParsing, 0, byteForParsing.Length); if (!creationFunctions.ContainsKey(fieldType.ToLower())) { MessageBox.Show("formatJson 파일에 Sbyte, Short, Integer, Long, Float, Double, String이 아닌 type이 있습니다."); break; } if (fieldType.ToLower().Equals(STRING) || !(fieldName.Equals(UUUUUUUUUUU) || fieldName.Equals(VVVVVVVVVVV) || fieldName.Equals(X) || fieldName.Equals(Y) || fieldName.Equals(Z) || fieldName.Equals(A) || fieldName.Equals(B) || fieldName.Equals(C) || fieldName.Equals(AAAAAAAAAAA) || fieldName.Equals(BBBBBBBBBBB) || fieldName.Equals(CCCCCCCCCCC) || fieldName.Equals(DDDDDDDDDDD) || fieldName.Equals(EEEEEEEEEEE) || fieldName.Equals(FFFFFFFFFFF) || fieldName.Equals(GGGGGGGGGGG) || fieldName.Equals(HHHHHHHHHHH) || fieldName.Equals(IIIIIIIIIII) || fieldName.Equals(JJJJJJJJJJJ) || fieldName.Equals(KKKKKKKKKKK) || fieldName.Equals(LLLLLLLLLLL) || fieldName.Equals(MMMMMMMMMMM) || fieldName.Equals(NNNNNNNNNNN) || fieldName.Equals(OOOOOOOOOOO) || fieldName.Equals(PPPPPPPPPPP) || fieldName.Equals(QQQQQQQQQQQ) || fieldName.Equals(RRRRRRRRRRR) || fieldName.Equals(SSSSSSSSSSS) || fieldName.Equals(TTTTTTTTTTT))) { //타입이 string -> scichart에 보내지 않음 if (scichartKeyList.Contains(fieldName)) { scichartKeyList.Remove(fieldName); } } else if (fieldType.ToLower().Equals(SBYTE) || fieldType.ToLower().Equals(SHORT) || fieldType.ToLower().Equals(INTEGER) || fieldType.ToLower().Equals(INT) || fieldType.ToLower().Equals(LONG) || fieldType.ToLower().Equals(FLOAT) || fieldType.ToLower().Equals(DOUBLE)) { int typeByteSize = 0; //바이트 사이즈에 대한 유효성 검사 switch (fieldType.ToString().ToLower()) { case INTEGER: typeByteSize = sizeof(int); break; case INT: typeByteSize = sizeof(int); break; case SHORT: typeByteSize = sizeof(short); break; case FLOAT: typeByteSize = sizeof(float); break; case LONG: typeByteSize = sizeof(long); break; case DOUBLE: typeByteSize = sizeof(double); break; case SBYTE: typeByteSize = sizeof(sbyte); break; default: MessageBox.Show("formatJson파일에서 해당 항목의 Type 확인 요망 : " + fieldType); break; } if (Convert.ToInt32(fieldSize) != typeByteSize) { MessageBox.Show("입력된 size와 해당 데이터타입의 size가 일치하지 않습니다."); break; } } IDataType field = creationFunctions[fieldType.ToLower()].Invoke(fieldName.ToLower(), byteForParsing); startPoint += byteForParsing.Length; Dictionary <string, object> fieldTypeAndValueDictionary = new Dictionary <string, object>(); fieldTypeAndValueDictionary.Add(fieldType, field.GetValue()); nameAndTypeAndValueDictionary.Add(fieldName, fieldTypeAndValueDictionary); } rawDataModel = JObject.FromObject(nameAndTypeAndValueDictionary); jArrayResult.Add(rawDataModel); enumerator.Reset(); lCurOffset += obj_byte_length; } } } catch (Exception e) { MessageBox.Show(e.Message); return; } }