Skip to content

Commit

Permalink
read ports map changed
Browse files Browse the repository at this point in the history
  • Loading branch information
joggyGeorge committed Mar 21, 2021
1 parent e2e905d commit 7a45db1
Show file tree
Hide file tree
Showing 3 changed files with 129 additions and 125 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ export default class ProjectManager {
body: JSON.stringify(transmit, null, 4)
});
const data = await response.json();
console.log(data);
if (data.status === true) {
new Notification('馄饨FPGA', {
body: '已保存'
Expand All @@ -234,8 +235,11 @@ export default class ProjectManager {

ShowWaveform = async () => {
//console.log(JSON.stringify(this.projectInfo["projectPortsMap"]));
const response = await fetch('/api/fpga/waveform?portsMap=' + JSON.stringify(this.projectInfo["projectPortsMap"]));
const data = await response.json();
console.log(JSON.stringify(this.projectInfo["projectPortsMap"]));
const response = await fetch('/api/fpga/waveform?portsmap=' + JSON.stringify(this.projectInfo["projectPortsMap"]));
//await console.log("text: " + response.text());
const data = await response.text();
console.log(data);

if (!data.status)
return false;
Expand Down
132 changes: 123 additions & 9 deletions Wonton.CrossUI.Web/Controllers/FPGAController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,127 @@ public class FPGAController : ControllerBase
{
private readonly ILogger<FPGAController> _logger;
private readonly FPGAManager _manager;
private Dictionary<string, ushort> inputDict;
private Dictionary<string, ushort> outputDict;
private Dictionary<string, int> inputDict;
private Dictionary<string, int> outputDict;

public FPGAController(ILogger<FPGAController> logger, FPGAManager manager)
{
_logger = logger;
_manager = manager;
//ReadPortsMap();
inputDict = new Dictionary<string, int>()
{
{"P151", 0},
{"P148", 1},
{"P150", 2},
{"P152", 3},
{"P160", 4},
{"P161", 5},
{"P162", 6},
{"P163", 7},
{"P164", 8},
{"P165", 9},
{"P166", 10},
{"P169", 11},
{"P173", 12},
{"P174", 13},
{"P175", 14},
{"P191", 15},
{"P120", 16},
{"P116", 17},
{"P115", 18},
{"P114", 19},
{"P113", 20},
{"P112", 21},
{"P111", 22},
{"P108", 23},
{"P102", 24},
{"P101", 25},
{"P100", 26},
{"P97", 27},
{"P96", 28},
{"P95", 29},
{"P89", 30},
{"P88", 31},
{"P87", 32},
{"P86", 33},
{"P81", 34},
{"P75", 35},
{"P74", 36},
{"P70", 37},
{"P69", 38},
{"P68", 39},
{"P64", 40},
{"P62", 41},
{"P61", 42},
{"P58", 43},
{"P57", 44},
{"P49", 45},
{"P47", 46},
{"P48", 47},
{"P192", 48},
{"P193", 49},
{"P199", 50},
{"P200", 51},
{"P201", 52},
{"P202", 53}
};
outputDict = new Dictionary<string, int>()
{
{"P7", 0},
{"P6", 1},
{"P5", 2},
{"P4", 3},
{"P9", 4},
{"P8", 5},
{"P16", 6},
{"P15", 7},
{"P11", 8},
{"P10", 9},
{"P20", 10},
{"P18", 11},
{"P17", 12},
{"P22", 13},
{"P21", 14},
{"P23", 15},
{"P44", 16},
{"P45", 17},
{"P46", 18},
{"P43", 19},
{"P40", 20},
{"P41", 21},
{"P42", 22},
{"P33", 23},
{"P34", 24},
{"P35", 25},
{"P36", 26},
{"P30", 27},
{"P31", 28},
{"P24", 29},
{"P27", 30},
{"P29", 31},
{"P110", 32},
{"P109", 33},
{"P99", 34},
{"P98", 35},
{"P94", 36},
{"P93", 37},
{"P84", 38},
{"P83", 39},
{"P82", 40},
{"P73", 41},
{"P71", 42},
{"P63", 43},
{"P60", 44},
{"P59", 45},
{"P56", 46},
{"P55", 47},
{"P167", 48},
{"P168", 49},
{"P176", 50},
{"P187", 51},
{"P189", 52},
{"P194", 53}
};
}

[HttpGet("initio")]
Expand Down Expand Up @@ -345,11 +458,11 @@ public async Task<FPGAResponse> NewProject(string projectdir, string projectname
}

[HttpGet("waveform")]
public async Task<FPGAResponse> Waveform(string portsMap)
public async Task<FPGAResponse> Waveform(string portsmap)
{
ReadPortsMap(); //因为每一次io传输都会新建一个fpgaController对象,所以要即建即用
//ReadPortsMap(); //因为每一次io传输都会新建一个fpgaController对象,所以要即建即用

Dictionary<string, string> ports = JsonConvert.DeserializeObject<Dictionary<string, string>>(portsMap);
Dictionary<string, string> ports = JsonConvert.DeserializeObject<Dictionary<string, string>>(portsmap);
var inputPortsIndexDict = new Dictionary<int, string>();
var outputPortsIndexDict = new Dictionary<int, string>();
foreach (KeyValuePair<string, string> i in ports)
Expand Down Expand Up @@ -501,6 +614,7 @@ internal string PrintVcd(Dictionary<int, string> dict, Dictionary<int, int> data
ans += t;
}
}
return ans;
/*
int cycle = dict.Count() / 16; //默认向下取整
//Console.WriteLine("Cycle = " + cycle);
Expand All @@ -522,9 +636,8 @@ internal string PrintVcd(Dictionary<int, string> dict, Dictionary<int, int> data
}
}
*/
return ans;
}

/*
//读取引脚名和引脚序号的映射
internal void ReadPortsMap()
{
Expand All @@ -544,7 +657,7 @@ internal void ReadPortsMap()
outputDict.Add(i[0].ToString(), i[1].ToObject<ushort>());
sr.Close();
fs.Close();
}
}*/
}

class RunExeByProcess
Expand Down Expand Up @@ -580,6 +693,7 @@ public string Execute()
return Result;
}
}

class VCDException : Exception
{
public VCDException(string message) : base(message) { }
Expand Down
114 changes: 0 additions & 114 deletions Wonton.CrossUI.Web/Services/FPGAPortsMap.js

This file was deleted.

0 comments on commit 7a45db1

Please sign in to comment.