public void StartTracker() { // reset reference in case if test starts again if (_csuData != null) { _csuData = null; } _currentStep = Step.BodyPartSelection; // show needed content ShowContent(); // create new data, because now we don't need to modify existing data until it's been submitted by user in a last step _csuData = new CSUData(DateTime.Today); _csuData.ResetQuestionIndex(); // enable screen ScreenManager.Instance.Set(23); // reset other components _bodyPartsController.ResetView(); _toggleGroup.SetAllTogglesOff(); }
public void CompleteTracker() { // save progress CSUData originalData = TrackerManager.GetData(DateTime.Today, TrackerManager.TrackerType.CSU) as CSUData; originalData.ChangeBodyPart(_selectedBodyPart); originalData.SetAnswers(_csuData.GetAnswers()); // save all photos List <int> texturesIndexes = _photosScrollController.GetSelectedPhotosIndexes(); if (texturesIndexes != null && texturesIndexes.Count > 0) { List <string> paths = CameraManager.GetTexturesPaths(texturesIndexes, true); originalData.SavePhotos(paths); } TrackerManager.UpdateEntry(DateTime.Today, originalData); // open CSU tracker menu dialog asking for another body part data fillup ScreenManager.Instance.Set(24); Dispose(); }
public void UpdateData(CSUData data) { if (data == null) { // show empty fields for (int i = 0; i < _hivesStats.Length; i++) { _hivesStats[i].text = _itchesStats[i].text = string.Empty; } _canavsGroup.alpha = 0.5f; } else { for (int i = 0; i < data.questionDataList.Count; i++) { var bodyParts = EnumUtil.GetValues <BodyPart>(); int counter = 0; foreach (BodyPart bodyPart in bodyParts) { // Debug.Log("BodyPart: "+bodyPart); _stats[i][counter].text = data.GetAnswerDescription(i, bodyPart); counter++; } } _canavsGroup.alpha = 1f; } }
public static void UpdateEntry(DateTime day, CSUData data) { if (_calendarDictionary.ContainsKey(day)) { Debug.LogWarning($"Same date {day.ToLongDateString()} log data already exist. Updating it."); _calendarDictionary[day].UpdateData(data); } else { _calendarDictionary.Add(day, new LogData { csuData = data }); } }
public void ShowPhotosPopup() { // update photo hint if needed if (_trackerType == TrackerManager.TrackerType.CSU) { CSUData csuData = TrackerManager.GetData(_data[_lastActiveCellIndex].date, TrackerManager.TrackerType.CSU) as CSUData; // if data exists if (csuData != null) { string[] texturesPaths = csuData.GetAllPhotosPaths(); photosScreen.Show(texturesPaths, csuData.GetDate()); } } }
private void Dispose() { _csuData = null; _photosScrollController.Dispose(); // remove textures for (int i = 0; i < _photos.Count; i++) { if (_photos[i] != null) { Destroy(_photos[i]); } } _photos.Clear(); }
public static void UpdateEntry(DateTime day, CSUData data) { DateTime dateTime = day.Date + DateTime.Now.TimeOfDay; // if it's a new entry if (!_csuJsonObjectList.Contains(data)) { _csuJsonObjectList.Add(data); OnFirstDataAdded?.Invoke(dateTime, data); } else { // update reminder OnDataUpdated?.Invoke(dateTime, data); } if (_trackerDictionary.ContainsKey(day)) { // Debug.LogWarning($"Same date {day.ToLongDateString()} log data already exist. Updating it."); _trackerDictionary[day].UpdateData(data); } else { _trackerDictionary.Add(day, new LogData { csuData = data }); } // update log file JSONObject o = new JSONObject(); for (int i = 0; i < _csuJsonObjectList.Count; i++) { o.Add(_csuJsonObjectList[i].FormatToJson()); } WriteToFile(GetPath(TrackerType.CSU), o.Print(true)); }
/// <summary> /// Test method to generate random data for particular day. /// </summary> /// <param name="date"></param> /// <returns></returns> public static LogData GenerateRandomData(DateTime date) { // load random textures form resources Texture2D[] textures = Resources.LoadAll <Texture2D>("RandomTextures"); date = date.Date; LogData logData = new LogData(); // symptom tracker SymptomData symptomData = new SymptomData(date); for (int j = 0; j < symptomData.questionDataList.Count; j++) { QuestionBasedTrackerData.QuestionData qData = symptomData.GetQuestion(); symptomData.SetAnswer(qData, UnityEngine.Random.Range(1, qData.answersOption.Length)); } logData.symptomData = symptomData; // asthma test AsthmaData asthmaData = new AsthmaData(date); for (int j = 0; j < asthmaData.questionDataList.Count; j++) { QuestionBasedTrackerData.QuestionData qData = asthmaData.GetQuestion(); asthmaData.SetAnswer(qData, UnityEngine.Random.Range(1, qData.answersOption.Length)); } logData.asthmaData = asthmaData; // CSU test CSUData csuData = new CSUData(date); for (int j = 0; j < csuData.questionDataList.Count * 3; j++) { if (j == 0) { csuData.ChangeBodyPart(BodyPart.Head); } else if (j == 2) { csuData.ChangeBodyPart(BodyPart.Chest); } else if (j == 4) { csuData.ChangeBodyPart(BodyPart.Legs); } QuestionBasedTrackerData.QuestionData qData = csuData.GetQuestion(); csuData.SetAnswer(qData, UnityEngine.Random.Range(1, qData.answersOption.Length)); if (Random.value > 0.5f) { // add some random textures int count = Random.Range(0, textures.Length); // shuffle textures System.Random rnd = new System.Random(); Texture2D[] shuffled = textures.OrderBy(x => rnd.Next()).ToArray(); // and cut out the array Array.Resize(ref shuffled, count); csuData.SavePhotos(shuffled); } } logData.csuData = csuData; // UAS test UASData uasData = new UASData(date); for (int j = 0; j < uasData.questionDataList.Count; j++) { QuestionBasedTrackerData.QuestionData qData = uasData.GetQuestion(); uasData.SetAnswer(qData, UnityEngine.Random.Range(1, qData.answersOption.Length)); } logData.uasData = uasData; return(logData); }
public static void FillTestData() { // Debug.Log("call"); // load random textures form resources Texture2D[] textures = Resources.LoadAll <Texture2D>("RandomTextures"); int days = Random.Range(65, 120); // int days = 1; // stay today date empty to use DateTime date = DateTime.Now.AddDays(-days).Date; Debug.Log("Fixed start date: " + date.ToString("dd/MM/yyyy")); JSONObject symptomJsonObject = new JSONObject(); JSONObject asthmaJsonObject = new JSONObject(); JSONObject csuJsonObject = new JSONObject(); JSONObject uasJsonObject = new JSONObject(); for (int i = 0; i < days; i++) { if (i % 7 == 0) { // symptom tracker SymptomData symptomData = new SymptomData(date); for (int j = 0; j < symptomData.questionDataList.Count; j++) { QuestionBasedTrackerData.QuestionData qData = symptomData.GetQuestion(); symptomData.SetAnswer(qData, Random.Range(1, qData.answersOption.Length)); } symptomJsonObject.Add(symptomData.FormatToJson()); } if (i % 14 == 0) { // asthma test AsthmaData asthmaData = new AsthmaData(date); for (int j = 0; j < asthmaData.questionDataList.Count; j++) { QuestionBasedTrackerData.QuestionData qData = asthmaData.GetQuestion(); asthmaData.SetAnswer(qData, Random.Range(1, qData.answersOption.Length)); } asthmaJsonObject.Add(asthmaData.FormatToJson()); } if (Random.Range(0f, 1f) > 0.5f) { // CSU test CSUData csuData = new CSUData(date); for (int j = 0; j < csuData.questionDataList.Count * 3; j++) { if (j == 0) { csuData.ChangeBodyPart(BodyPart.Head); } else if (j == 2) { csuData.ChangeBodyPart(BodyPart.Chest); } else if (j == 4) { csuData.ChangeBodyPart(BodyPart.Legs); } QuestionBasedTrackerData.QuestionData qData = csuData.GetQuestion(); csuData.SetAnswer(qData, Random.Range(1, qData.answersOption.Length)); if (Random.value > 0.5f) { // add some random textures int count = Random.Range(0, textures.Length); // shuffle textures System.Random rnd = new System.Random(); Texture2D[] shuffled = textures.OrderBy(x => rnd.Next()).ToArray(); // and cut out the array Array.Resize(ref shuffled, count); csuData.SavePhotos(shuffled); } } csuJsonObject.Add(csuData.FormatToJson()); } if (Random.Range(0f, 1f) > 0.5f) { // UAS test UASData uasData = new UASData(date); for (int j = 0; j < uasData.questionDataList.Count; j++) { QuestionBasedTrackerData.QuestionData qData = uasData.GetQuestion(); uasData.SetAnswer(qData, Random.Range(1, qData.answersOption.Length)); } uasJsonObject.Add(uasData.FormatToJson()); } // add a single day date = date.AddDays(1); } WriteToFile(Path.Combine(Helper.GetDataPath(), LOGS_FOLDER, CSU_LOG), csuJsonObject.Print(true)); WriteToFile(Path.Combine(Helper.GetDataPath(), LOGS_FOLDER, UAS_LOG), uasJsonObject.Print(true)); WriteToFile(Path.Combine(Helper.GetDataPath(), LOGS_FOLDER, SYMPTOM_LOG), symptomJsonObject.Print(true)); WriteToFile(Path.Combine(Helper.GetDataPath(), LOGS_FOLDER, ASTHMA_TEST_LOG), asthmaJsonObject.Print(true)); NotesManager.FillTestData(days); Debug.LogWarning($"Random log data generated for {days} days"); }
private void Awake() { DateTime today = DateTime.Now.Date; // parse log files on start if exists // symptom tracker string path = Path.Combine(Helper.GetDataPath(), LOGS_FOLDER, SYMPTOM_LOG); List <JSONObject> jsonList = GetJsonList(path); for (int i = 0; i < jsonList.Count; i++) { JSONObject jsonObj = jsonList[i]; SymptomData data = new SymptomData(jsonObj.ToString()); // don't manage outdated logs if ((today - data.GetDate()).Days > LOG_LIFE_TIME) { continue; } _symptomJsonObjectList.Add(data); // check if this date already exists if (_trackerDictionary.ContainsKey(data.GetDate())) { // modify existing entry UpdateEntry(data.GetDate(), data); } else { // add new entry UpdateEntry(data.GetDate(), new LogData { symptomData = data }); } } // asthma test path = Path.Combine(Helper.GetDataPath(), LOGS_FOLDER, ASTHMA_TEST_LOG); jsonList = GetJsonList(path); for (int i = 0; i < jsonList.Count; i++) { JSONObject jsonObj = jsonList[i]; AsthmaData data = new AsthmaData(jsonObj.ToString()); // don't manage outdated logs if ((today - data.GetDate()).Days > LOG_LIFE_TIME) { continue; } _asthmaJsonObjectList.Add(data); // check if this date already exists if (_trackerDictionary.ContainsKey(data.GetDate())) { // modify existing entry UpdateEntry(data.GetDate(), data); } else { // add new entry UpdateEntry(data.GetDate(), new LogData { asthmaData = data }); } } // CSU test path = Path.Combine(Helper.GetDataPath(), LOGS_FOLDER, CSU_LOG); jsonList = GetJsonList(path); for (int i = 0; i < jsonList.Count; i++) { JSONObject jsonObj = jsonList[i]; CSUData data = new CSUData(jsonObj.ToString()); // don't manage outdated logs if ((today - data.GetDate()).Days > LOG_LIFE_TIME) { continue; } _csuJsonObjectList.Add(data); // check if this date already exists if (_trackerDictionary.ContainsKey(data.GetDate())) { // modify existing entry UpdateEntry(data.GetDate(), data); } else { // add new entry UpdateEntry(data.GetDate(), new LogData { csuData = data }); } } // UAS test path = Path.Combine(Helper.GetDataPath(), LOGS_FOLDER, UAS_LOG); jsonList = GetJsonList(path); for (int i = 0; i < jsonList.Count; i++) { JSONObject jsonObj = jsonList[i]; UASData data = new UASData(jsonObj.ToString()); // don't manage outdated logs if ((today - data.GetDate()).Days > LOG_LIFE_TIME) { continue; } _uasJsonObjectList.Add(data); // check if this date already exists if (_trackerDictionary.ContainsKey(data.GetDate())) { // modify existing entry UpdateEntry(data.GetDate(), data); } else { // add new entry UpdateEntry(data.GetDate(), new LogData { uasData = data }); } } _logDataList = _logDataList.OrderBy(x => x.date).ToList(); }
public void UpdateData(CSUData data) { csuData = data; OnUpdate?.Invoke(); }
private void Start() { // parse log files on start if exists // symptom tracker file string path = Path.Combine(Helper.StreamingAssetPath(), SYMPTOM_LOG); List <JSONObject> jsonList = GetJsonList(path); for (int i = 0; i < jsonList.Count; i++) { JSONObject jsonObj = jsonList[i]; SymptomData data = JsonUtility.FromJson <SymptomData>(jsonObj.str); // check if this date already exists if (_calendarDictionary.ContainsKey(data.GetDate())) { // modify existing entry _calendarDictionary[data.GetDate()].symptomData = data; } else { // add new entry _calendarDictionary.Add(data.GetDate(), new LogData { symptomData = data }); } } // asthma test path = Path.Combine(Helper.StreamingAssetPath(), ASTHMA_TEST_LOG); jsonList = GetJsonList(path); for (int i = 0; i < jsonList.Count; i++) { JSONObject jsonObj = jsonList[i]; AsthmaData data = JsonUtility.FromJson <AsthmaData>(jsonObj.str); // check if this date already exists if (_calendarDictionary.ContainsKey(data.GetDate())) { // modify existing entry _calendarDictionary[data.GetDate()].asthmaData = data; } else { // add new entry _calendarDictionary.Add(data.GetDate(), new LogData { asthmaData = data }); } } // CSU test path = Path.Combine(Helper.StreamingAssetPath(), CSU_LOG); jsonList = GetJsonList(path); for (int i = 0; i < jsonList.Count; i++) { JSONObject jsonObj = jsonList[i]; CSUData data = JsonUtility.FromJson <CSUData>(jsonObj.str); // check if this date already exists if (_calendarDictionary.ContainsKey(data.GetDate())) { // modify existing entry _calendarDictionary[data.GetDate()].csuData = data; } else { // add new entry _calendarDictionary.Add(data.GetDate(), new LogData { csuData = data }); } } // UAS test path = Path.Combine(Helper.StreamingAssetPath(), UAS_LOG); jsonList = GetJsonList(path); for (int i = 0; i < jsonList.Count; i++) { JSONObject jsonObj = jsonList[i]; UASData data = JsonUtility.FromJson <UASData>(jsonObj.str); // check if this date already exists if (_calendarDictionary.ContainsKey(data.GetDate())) { // modify existing entry _calendarDictionary[data.GetDate()].uasData = data; } else { // add new entry _calendarDictionary.Add(data.GetDate(), new LogData { uasData = data }); } } }