//public void TOFDemodulateBlocks(string[] blockFiles, string savePath, string[] detectorNames) //{ // // first of all test that the save location exists to avoid later disappointment. // if (!Directory.Exists(Path.GetDirectoryName(savePath))) // { // log("Save path does not exist!!"); // return; // } // // initialise the TOF accumulator dictionary // tcsaDictionary = new Dictionary<string, TOFChannelSetAccumulator>(); // foreach (string detectorName in detectorNames) // { // tcsaDictionary.Add(detectorName, new TOFChannelSetAccumulator()); // } // // queue the blocks - the last block analysed will take care of saving the results. // foreach (string blockFile in blockFiles) // { // TofDemodulateParams tdp = new TofDemodulateParams(); // tdp.blockPath = blockFile; // tdp.savePath = savePath; // tdp.detectorNames = detectorNames; // threadManager.AddToQueue(TOFDemodulateThreadWrapper, tdp); // } //} //private void TOFDemodulateBlock(string blockPath, string savePath, string[] detectorNames) //{ // BlockSerializer bs = new BlockSerializer(); // string[] splitPath = blockPath.Split('\\'); // log("Loading block " + splitPath[splitPath.Length - 1]); // Block b = bs.DeserializeBlockFromZippedXML(blockPath, "block.xml"); // TOFBlockDemodulator bd = new TOFBlockDemodulator(); // log("TOF Demodulating block " + b.Config.Settings["cluster"] + " - " + b.Config.Settings["clusterIndex"]); // foreach (string detectorName in detectorNames) // { // TOFDemodulatedBlock tdb = bd.TOFDemodulateBlock(b); // string savePathTDB = savePath + detectorName + b.Config.Settings["cluster"] + "-" + b.Config.Settings["clusterIndex"] + ".bin"; // log("Saving TOF Channel Set for " + detectorName + " - " + b.Config.Settings["cluster"] + " - " + b.Config.Settings["clusterIndex"]); // Stream fs = new FileStream(savePathTDB, FileMode.Create); // (new BinaryFormatter()).Serialize(fs, tdb); // fs.Close(); // } //} //private void TOFDemodulateThreadWrapper(object parametersIn) //{ // threadManager.QueueItemWrapper(delegate(object parms) // { // TofDemodulateParams parameters = (TofDemodulateParams)parms; // TOFDemodulateBlock(parameters.blockPath, parameters.savePath, parameters.detectorNames); // }, // parametersIn // ); //} //private struct TofDemodulateParams //{ // public string blockPath; // public string savePath; // public string[] detectorNames; // // this struct has a ToString method defined for error reporting porpoises. // public override string ToString() // { // return blockPath; // } //} #endregion #region Testing // Somewhere for SirCachealot to store test results that's accessible by Mathematica. // Makes debugging easier and is needed as a workaround for the constant Mathematica // NET/Link errors. // public TOFChannelSetGroup ChanSetGroup; // workarounds for NET/Link bugs //public TOFChannelSet GetAveragedChannelSet(bool eSign, bool bSign, bool rfSign) //{ // return ChanSetGroup.AverageChannelSetSignedByMachineState(eSign, bSign, rfSign); //} //public void LoadChannelSetGroup(string path) //{ // BinaryFormatter bf = new BinaryFormatter(); // FileStream fs = new FileStream(path, FileMode.Open); // ChanSetGroup = (TOFChannelSetGroup)bf.Deserialize(fs); // fs.Close(); //} public void Test1() { GatedDemodulationConfig standardConfig = GatedDemodulationConfig.MakeStandardWideGateConfig(); //gateSet = new GatedDemodulationConfigSet(); //gateSet.GatedDemodulationConfigs.Add(standardConfig); //SaveGateSet(); //SelectDB("dbTest1"); //DemodulatedBlock dBlock = blockStore.GetDBlock(1); //GateTOFDemodulatedBlock(dBlock, GatedDemodulationConfig.MakeStandardWideGateConfig()); }
public void NewGateConfig() { GatedDemodulationConfig newGateConfig = GatedDemodulationConfig.MakeStandardWideGateConfig(); newGateConfig.Name = "Untitled"; try { currentGateSetDictionary.Add(newGateConfig.Name, newGateConfig); } catch (ArgumentException) { errorLog("A gate config with the same name already exists!"); } RefreshGateConfigList(); mainWindow.SelectGateConfig(newGateConfig.Name); }
public void UpdateGateListInUI(string gateConfigName) { GatedDemodulationConfig gateConfig = currentGateSetDictionary[gateConfigName]; List <string[]> gateConfigData = new List <string[]>(); mainWindow.ClearGateList(); for (int i = 0; i < gateConfig.Gates.Count; i++) { mainWindow.AddGateListEntry( gateConfig.GatedDetectors[i], gateConfig.Gates[i].GateLow, gateConfig.Gates[i].GateHigh, gateConfig.Gates[i].Integrate ); } }
public void SaveCurrentGateConfig() { var gateConfig = new GatedDemodulationConfig(); List <object[]> gateConfigData = mainWindow.GetGateConfigFromDataView(); gateConfig.Name = mainWindow.GetGateConfigNameTextBox(); foreach (object[] gateData in gateConfigData) { if (!gateConfig.GatedDetectors.Contains((string)gateData[0])) { gateConfig.AddGate( (string)gateData[0], new Gate() { GateLow = (int)gateData[1], GateHigh = (int)gateData[2], Integrate = (bool)gateData[3] } ); } else { MessageBox.Show("Two gates have the same detector!"); return; } } currentGateSetDictionary.Remove(mainWindow.GetGateConfigName()); try { currentGateSetDictionary.Add(gateConfig.Name, gateConfig); } catch (ArgumentException) { errorLog("A gate config with the same name already exists!"); } RefreshGateConfigList(); mainWindow.SelectGateConfig(gateConfig.Name); }