Removed debug. Final testing
This commit is contained in:
parent
39f3383709
commit
db662a7662
@ -288,7 +288,6 @@ class Lorenz extends Operation {
|
|||||||
if (lugx4.length != 26 || !re.test(lugx4) ) throw new OperationError("Χ4 custom lugs must be 26 long and can only include . or x");
|
if (lugx4.length != 26 || !re.test(lugx4) ) throw new OperationError("Χ4 custom lugs must be 26 long and can only include . or x");
|
||||||
if (lugx5.length != 23 || !re.test(lugx5) ) throw new OperationError("Χ5 custom lugs must be 23 long and can only include . or x");
|
if (lugx5.length != 23 || !re.test(lugx5) ) throw new OperationError("Χ5 custom lugs must be 23 long and can only include . or x");
|
||||||
var chosenSetting = INIT_PATTERNS["No Pattern"];
|
var chosenSetting = INIT_PATTERNS["No Pattern"];
|
||||||
console.log(chosenSetting);
|
|
||||||
chosenSetting["S"][1] = this.readLugs(lugs1);
|
chosenSetting["S"][1] = this.readLugs(lugs1);
|
||||||
chosenSetting["S"][2] = this.readLugs(lugs2);
|
chosenSetting["S"][2] = this.readLugs(lugs2);
|
||||||
chosenSetting["S"][3] = this.readLugs(lugs3);
|
chosenSetting["S"][3] = this.readLugs(lugs3);
|
||||||
@ -301,7 +300,6 @@ class Lorenz extends Operation {
|
|||||||
chosenSetting["X"][3] = this.readLugs(lugx3);
|
chosenSetting["X"][3] = this.readLugs(lugx3);
|
||||||
chosenSetting["X"][4] = this.readLugs(lugx4);
|
chosenSetting["X"][4] = this.readLugs(lugx4);
|
||||||
chosenSetting["X"][5] = this.readLugs(lugx5);
|
chosenSetting["X"][5] = this.readLugs(lugx5);
|
||||||
console.log(chosenSetting);
|
|
||||||
} else {
|
} else {
|
||||||
var chosenSetting = INIT_PATTERNS[pattern];
|
var chosenSetting = INIT_PATTERNS[pattern];
|
||||||
}
|
}
|
||||||
@ -317,7 +315,7 @@ class Lorenz extends Operation {
|
|||||||
var letter = character.toUpperCase();
|
var letter = character.toUpperCase();
|
||||||
|
|
||||||
if(intype == "Plaintext") {
|
if(intype == "Plaintext") {
|
||||||
if (validChars.indexOf(letter) === -1) throw new OperationError("Invalid Plaintext character");
|
if (validChars.indexOf(letter) === -1) throw new OperationError("Invalid Plaintext character : "+letter);
|
||||||
|
|
||||||
if( !figShifted && figShiftedChars.indexOf(letter) !== -1 ) {
|
if( !figShifted && figShiftedChars.indexOf(letter) !== -1 ) {
|
||||||
// in letters mode and next char needs to be figure shifted
|
// in letters mode and next char needs to be figure shifted
|
||||||
@ -342,8 +340,12 @@ class Lorenz extends Operation {
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
if (validITA2.indexOf(letter) === -1) throw new OperationError("Invalid ITA2 character");
|
if (validITA2.indexOf(letter) === -1) {
|
||||||
|
var errltr = letter;
|
||||||
|
if(errltr=="\n") errltr = "Carriage Return";
|
||||||
|
if(errltr==" ") errltr = "Space";
|
||||||
|
throw new OperationError("Invalid ITA2 character : "+errltr);
|
||||||
|
}
|
||||||
return letter;
|
return letter;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -355,28 +357,30 @@ class Lorenz extends Operation {
|
|||||||
// Receive input should always be ITA2
|
// Receive input should always be ITA2
|
||||||
ita2 = Array.prototype.map.call(input, function(character) {
|
ita2 = Array.prototype.map.call(input, function(character) {
|
||||||
var letter = character.toUpperCase();
|
var letter = character.toUpperCase();
|
||||||
if (validITA2.indexOf(letter) === -1) throw new OperationError("Invalid ITA2 character");
|
if (validITA2.indexOf(letter) === -1) {
|
||||||
|
var errltr = letter;
|
||||||
|
if(errltr=="\n") errltr = "Carriage Return";
|
||||||
|
if(errltr==" ") errltr = "Space";
|
||||||
|
throw new OperationError("Invalid ITA2 character : "+errltr);
|
||||||
|
}
|
||||||
return letter;
|
return letter;
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const ita2Input = ita2.join("");
|
const ita2Input = ita2.join("");
|
||||||
console.log(ita2Input);
|
|
||||||
|
|
||||||
var thisPsi = [];
|
var thisPsi = [];
|
||||||
var thisChi = [];
|
var thisChi = [];
|
||||||
var thisMu = [];
|
var thisMu = [];
|
||||||
var m61lug = muSettings[1][m61-1];
|
var m61lug = muSettings[1][m61-1];
|
||||||
var m37lug = 0;
|
var m37lug = muSettings[2][m37-1];
|
||||||
var p5 = [0,0,0];
|
var p5 = [0,0,0];
|
||||||
|
|
||||||
const self = this;
|
const self = this;
|
||||||
const letters = Array.prototype.map.call(ita2Input, function(character) {
|
const letters = Array.prototype.map.call(ita2Input, function(character) {
|
||||||
const letter = character.toUpperCase();
|
const letter = character.toUpperCase();
|
||||||
|
|
||||||
//console.log(s1+' '+s2+' '+s3+' '+s4+' '+s5+' : '+m37+' '+m61+' : '+x1+' '+x2+' '+x3+' '+x4+' '+x5);
|
|
||||||
|
|
||||||
var x2bptr = x2+1;
|
var x2bptr = x2+1;
|
||||||
if(x2bptr==32) x2bptr=1;
|
if(x2bptr==32) x2bptr=1;
|
||||||
var s1bptr = s1+1;
|
var s1bptr = s1+1;
|
||||||
@ -403,8 +407,6 @@ class Lorenz extends Operation {
|
|||||||
muSettings[2][m37-1]
|
muSettings[2][m37-1]
|
||||||
];
|
];
|
||||||
|
|
||||||
console.log(letter + ' + ' + self.REVERSE_ITA2_TABLE[thisPsi.join("")] + ' + ' + self.REVERSE_ITA2_TABLE[thisChi.join("")]);
|
|
||||||
|
|
||||||
if (typeof ITA2_TABLE[letter] == "undefined") {
|
if (typeof ITA2_TABLE[letter] == "undefined") {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
@ -436,15 +438,17 @@ class Lorenz extends Operation {
|
|||||||
|
|
||||||
p5[2] = p5[1];
|
p5[2] = p5[1];
|
||||||
p5[1] = p5[0];
|
p5[1] = p5[0];
|
||||||
p5[0] = ITA2_TABLE[letter][4];
|
if(mode=="Send") {
|
||||||
console.log('p5='+ITA2_TABLE[letter]+' ('+letter+') = '+p5[0]);
|
p5[0] = ITA2_TABLE[letter][4];
|
||||||
|
} else {
|
||||||
|
p5[0] = xorSum[4];
|
||||||
|
}
|
||||||
|
|
||||||
// Limitations here
|
// Limitations here
|
||||||
if(model=='SZ42a') {
|
if(model=='SZ42a') {
|
||||||
// Chi 2 one back lim - The active character of chi 2 (2nd Chi wheel) in the previous position
|
// Chi 2 one back lim - The active character of chi 2 (2nd Chi wheel) in the previous position
|
||||||
lim = chiSettings[2][x2bptr-1];
|
lim = chiSettings[2][x2bptr-1];
|
||||||
if(kt) {
|
if(kt) {
|
||||||
console.log('lim='+lim+', p5-2='+p5[2]);
|
|
||||||
if(lim==p5[2]) { lim = 0; } else { lim=1; } //p5 back 2
|
if(lim==p5[2]) { lim = 0; } else { lim=1; } //p5 back 2
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -454,7 +458,6 @@ class Lorenz extends Operation {
|
|||||||
} else {
|
} else {
|
||||||
totalmotor = 1;
|
totalmotor = 1;
|
||||||
}
|
}
|
||||||
console.log('BM='+basicmotor+', LM='+lim+', TM='+totalmotor);
|
|
||||||
|
|
||||||
} else if(model=='SZ42b') {
|
} else if(model=='SZ42b') {
|
||||||
// Chi 2 one back + Psi 1 one back.
|
// Chi 2 one back + Psi 1 one back.
|
||||||
@ -465,7 +468,6 @@ class Lorenz extends Operation {
|
|||||||
if(kt) {
|
if(kt) {
|
||||||
if(lim==p5[2]) { lim=0; } else { lim=1; } //p5 back 2
|
if(lim==p5[2]) { lim=0; } else { lim=1; } //p5 back 2
|
||||||
}
|
}
|
||||||
console.log('BM='+basicmotor+', LM='+lim);
|
|
||||||
// If basic motor = 0 and limitation = 1, Total motor = 0 [no move], otherwise, total motor = 1 [move]
|
// If basic motor = 0 and limitation = 1, Total motor = 0 [no move], otherwise, total motor = 1 [move]
|
||||||
if(basicmotor==0 && lim==1) {
|
if(basicmotor==0 && lim==1) {
|
||||||
totalmotor = 0;
|
totalmotor = 0;
|
||||||
@ -476,7 +478,6 @@ class Lorenz extends Operation {
|
|||||||
} else if(model=="SZ40") {
|
} else if(model=="SZ40") {
|
||||||
// SZ40
|
// SZ40
|
||||||
totalmotor = basicmotor;
|
totalmotor = basicmotor;
|
||||||
console.log('TM='+basicmotor);
|
|
||||||
} else {
|
} else {
|
||||||
throw new OperationError("Lorenz model type not recognised");
|
throw new OperationError("Lorenz model type not recognised");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user