Monthly Archives: March 2015

Dong Shin 03.31.2015

  • found that POC could not be added to the list
    • put old code back in place that refreshes the data on save
    • had to explicitly set the self.gridOptions.data = self.pointOfContacts when the data returns
  • changed so that server returns empty list instead of error when nothing found
  • modified funding_request_pocs table to cascade changes to point_of_contacts table

Phil 3.31.15

8:00 – 4:30 SR

  • Working on debugging POC name issue. Fixed? Had to roll back some things to make the data binding work?
  • Migrating NovettaUtils to the lib directory, then using that for inheriting in the charts module. Which was going to be migrated before discovering the fat arrow inherit feature (FAIF). So yeah. migrate that too.
  • Nope, realized that there was no way to maintain state using the approach that I tried. Looking into using the actual prototype chaining pattern instead.
  • Ok, kinda hit a wall here. Note that the breakpoint and the console.log disagree:

wtf

Phil 3.30.15

8:00 – 3:00 SR

  • Mark, who is standing in for Lenny, found this and I verified. Entering a POC in a new FR doesn’t show up in the list.
  • Testing the new callback scheme in typescript testbed.
  • Tried it, and was quite hopeful, but the scheme failed with the timeoutService callback. Bad, because that’s a basic Angular component and messing with that just isn’t in the cards. But the fatPrototype/fatSuper scheme works. Now I just need to be able to make prototype chaining work right. Done! Here’s the entire class:
    export class FatSuperBase {
       public functionMap:any[];
       constructor() {
          this.functionMap = [];
       }
       public setFatPrototype(fn:Function, n:string){
          // TODO: look for earlier prototypes that we might need to call
          if(!this.functionMap.hasOwnProperty(n)){
             this.functionMap[n] = [];
          }
          this.functionMap[n].push(fn);
       }
       public fatSuper(fnName:string, childArgs:IArguments){
          // TODO: look for earlier prototypes that we might need to call
          var fn:Function;
          var farray:Function[];
          if(this.functionMap.hasOwnProperty(fnName)){
             farray = this.functionMap[fnName];
             fn = farray[farray.length-1];
             fn.apply(fn, childArgs);
          }else{
             console.log("fatSuper(): function '"+fnName+"'does not exist on the prototype chain");
          }
       }
    }

Dong Shin 03.30.2015

  • working on Stored Query Service – runs stored queries and publishes as json
    • creating database table, model, controller, service……
  • created separate Java Lib for logging – LoggingUtils
    • moved Spring Service libraries to User Library – SpringLibs
  • POC problem on-site… need to look at the debug information tomorrow.

Phil 3.27.17

7:00 – 3:30 SR

  • Timesheets
  • Wow – upgraded to Windows 7! Of course, that means that I don’t have PuTTY and can’t get to the servers. Put in a ticket…
  • Need to see how super() works in JavaScript. I’m thinking it should be possible to write a Utils.FatSuper(this.myFnPtr) static method that will do the same.
  • TypeScript parent class (Parts stripped out for clarity):
    export class TestController implements ITestController {
       // standard TypeScript constructor
       constructor() {
       }
    
       public extendableFunction():void{
          alert("It's extendableFunction()");
       }
    
       public fatArrowFunction = ():void => {
          alert("It's fatArrowFunction()");
       }
    }
  • Compiled JavaScript of above:
    var TestController = (function () {
        // standard TypeScript constructor
        function TestController() {
            var _this = this;
            
            this.fatArrowFunction = function () {
                alert("It's fatArrowFunction()");
            };
        }
        TestController.prototype.extendableFunction = function () {
            alert("It's extendableFunction()");
        };
        return TestController;
    })();
    InheritApp.TestController = TestController;
  • TypeScript child class:
    export class TestController2 extends TestController implements ITestController2 {
       myInheritedString:string;
    
       // standard inheriting constructor pattern. Note that 'super' must be on the first line and
       // that the arguments from angular get passed through
       constructor(){
          super();
       }
    
       public extendableFunction():void{
          super.extendableFunction();
       }
    }
  • Compiled JavaScript of above:
    var TestController2 = (function (_super) {
        __extends(TestController2, _super);
        
        function TestController2() {
            _super.call(this);
        }
        TestController2.prototype.extendableFunction = function () {
            _super.prototype.extendableFunction.call(this);
        };
        return TestController2;
    })(TestController);
    InheritApp.TestController2 = TestController2;
  • JavaScript of above with all the contents commented out:
    var TestController2 = (function (_super) {
        __extends(TestController2, _super);
        function TestController2() {
            _super.apply(this, arguments);
        }
        return TestController2;
    })(TestController);
    InheritApp.TestController2 = TestController2;
  • As an aside, __extends is just parasitic inheritance:
    var __extends = this.__extends || function (d, b) {
        for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
        function __() { this.constructor = d; }
        __.prototype = b.prototype;
        d.prototype = new __();
    };
  • So we know a few things now:
    • extending in TypeScript means that the child class is called with the parent class passed in as an argument called ‘_super’
    • Fat arrow functions are defined in the constructor as variables pointing to functions and are attached to ‘this’, not ‘_this’
  • I tried looking for the properties in the debugger, but couldn’t really see what was going on in the JavaScript. So I added a loop over the properties in the TestController2 constructor. FatArrowFunction is listed and extendableFunction is not. To me this makes sense, as extendableFunction is on the prototype:
    this[fatArrowFunction] = function () {
            alert("It's fatArrowFunction()");
        }
  • Building on the above, we can make what boils down to our own prototype for fat functions. The other option is to turn everything into fat functions as per this nifty piece of work, discussed on this page. I have a concern about adding all this wrapping to functions, so until I run some tests and see what’s faster, here’s a way of doing it semi-manually. Here’s the parent code:
    export class TestController implements ITestController {
       public functionMap:Function[];
    
       // standard TypeScript constructor
       constructor() {
          this.functionMap = [];
          this.setFatPrototype(this.fatArrowFunction, "fatArrowFunction");
       }
    
       public fatArrowFunction = (arg:string):void => {
          alert("It's fatArrowFunction("+arg+")");
       };
    
       public extendableFunction():void{
          alert("It's extendableFunction()");
       }
       public setFatPrototype(fn:Function, n:string){
          // TODO: look for earlier prototypes that we might need to call
          fn["name"] = n;
          this.functionMap[n] = fn;
       }
       public fatSuper(fnName:string, childArgs:IArguments){
          // TODO: look for earlier prototypes that we might need to call
          var fn;Function;
          if(this.functionMap.hasOwnProperty(fnName)){
             fn = this.functionMap[fnName];
             fn.apply(fn, childArgs);
          }else{
             console.log("fatSuper(): function '"+fnName+"'does not exist on the prototype chain");
          }
       }
    }
  • And here’s the child class:
    export class TestController2 extends TestController implements ITestController2 {
    
       public extendableFunction():void{
          super.extendableFunction();
       }
    
       public fatArrowFunction = (arg:string):void => {
          this.fatSuper("fatArrowFunction", arguments);
          alert("It's fatArrowFunction2("+arg+")");
       };
    }
  • As the comments say, I do not recurse up the ‘prototyp’ tree yet, though that wouldn’t be hard. Before I do that, I need to implement both versions and see if the version that converts all functions to function pointers works with Angular and if it does, to run some tests to see which is faster. Stuff for Monday.

Phil 3.26.15

8:00 – 4:00 SR

  • Tested threejs on target browsers. The hardware acceleration is iffy, but the software renderer and the raytracer work fine
  • Deployed Dong’s FR fixes
  • Working on splitting the chart elements into their own module.
  • Argh! Fat arrow functions can’t inherit in TypeScript! Thinking about making a mapping table? Something like
    • fooPtr = (var:number):void =>{…};
    • fooFn(var:number):void{fooPtr(var);}
    • ????
  • Set up and implemented an interface for calculating behaviors, which works nicely:
  • public behavior = (dClock:number, elapsed:number):void => {
       var rb = this.wglCanvas;
       var ci:IChartElement;
       var i:number = 0;
       if (rb) {
          rb.dprint("Hello controller - sin(elapsed) = " + Math.sin(elapsed).toFixed(2));
          for (i = 0; i < this.chartElements.length; i++) {
             ci = this.chartElements[i];
             ci.setZOffset(Math.sin(elapsed + i));
             ci.behavior(dClock, elapsed);
          }
       }
    };

Dong Shin 03.25.2015

  • modified POC processing so that it cannot be edited/deleted if used in others.
  • tried to update Angular to latest (1.3.15 or 1.4), didn’t work with min attribute in Obligations/Outlays…..
  • fixed incorrect Funding Amount (Number.MAX_VALUE) showing in Obligations/Outlays
  • working on setting central login page….

Phil 3.25.15

8:00 – 5:00 SR

  • Set up Mark’s accounts
  • Set up an admin account for our tester. Not sure if that’s actually needed?
  • Brought over the latest and greatest for Bill to scan. Should be ready for testing tomorrow.
  • Finish integrating Chartinfo class into testbed. Done, but more of an adventure than I was expecting. First, my development box began acting weird (fan noises, flickering graphics, slow performance). Then it BSOD’d. When I finally got it back up, the debugger kept on getting confused about comments. Once that was sorted, I couldn’t get picking to work on area charts, even though it worked fine for everything else. That traced back to a null value for the component name, which is an explicit test I run to manage tooltips. So once the name from the ChartInfo item was loaded into the glComponent, everything began working correctly. Sheesh.
  • Tried to get my laptop again and also a replacement workstation, since this one is now suspect.
  • Running CC

Dong Shin 03.24.2015

  • reworking on POC processing
    • server returns list of POCs on add
    • fixed Error not showing on Save/Edit/Delete
    • added instruction
    • set all the modals (pop-ups) to use backdrop: ‘static’ so background is grayed out and must click Ok/Cancel to dismiss

Phil 3.24.15

8:00 – 4:30 SR

  • Lenny’s out for the week. Going to coordinate with Don and Mike(?) for the time being.
  • Need to set up cluster and stacked barcharts. I think it’s mostly a size and offset issue, so there need to be multiple arrays. Since area charts and bar charts pretty much use the same raw data, I think I’ll make a data object that contains the needed data. That can be set by a server call and passed in regardless of the chart type. Cluster bar charts are just offset by the index times the width. The width in turn is the spacing divided by the number of columns and clusters.
  • It strikes me that if we have enough problems having hardware rendering, that we can use raytracing. Either in the server (povray), or using the threejs raytracer. There is no THREE.RaytracingRenderer in definitelyTyped though.
  • Found a bug while making sure that the software rendering looks ok (it does). Fixed. The OrbitControls were resetting the camera origin. I just needed to not set OrbitControls if the scene is not dynamic.
  • Added ChartInfo class that stores all the numbers for a bar chart or area chart. Compiles, will test tomorrow.
  • Burned a disk containing the newest threejs for Bill.

Phil 3.23.15

8:00 – 10:00, 12:00- 5:00 SR

  • Snow flurries are predicted for tomorrow. Some start to spring, huh?
  • Deployed new FR. All seems to be working.
  • Pinged our potential new servers. They respond in half the time and are farther away. I mean like Georgia, I think.
  • Adding bar charts. Once that works, I’ll try to figure out where all the code should go. I also need to talk to Dong about hooking up to a data source.
  • Bar charts are in and working. Need to set them up for ortho2 rendering.

Dong Shin 03.20.2015

  • continue working on FR
    • added calculate functions to the download template
    • download works on Chrome, partially on Firefox
    • only a page is downloaded
    • tried various data attribute….. found this is the way!
    • pom.setAttribute('href', 'data:text/attachment,' + encodeURIComponent(content.innerHTML));

Phil 3.20.15

7:00 – 4:00 SR

  • Still working on the lab problem. I’m using the roll of a six-sided dice to represent labs. Here’s the issue.
    • For an even distribution over a set of options, the probability of an event converges nicely: EvenDistribution
    • A random distribution converges, but not so nicely: RandomDistribution
    • Loaded dice also converge, but in a different way: LoadedDice
    • The question is, how do I tell that the difference between 1 and 2 is acceptable, but that the difference between 2 and 3 isn’t? Also very important is how many “rolls” do you need before you can say that the dice is loaded one way or another? I was looking at Chi Squares, but that doesn’t seem to be right. Currently looking at Binomial Distributions.
    • Ok, it looks like Binomial Distributions are what we want. Here’s what it looks like:BinomialTail
    • In the chart, probabilities accumulate for the first 100 rolls, and then a cumulative binomial distribution is calculated where at least one success happens in the next ten trials. The excel function that does this is:
      • =1-BINOM.DIST(<successes-1>,<trial number starting at 2>, <calculated probability>, TRUE)
    • Note that the probability of a future even sums to more than 100%. This is because the probability of one face coming up at least once in the next ten trials is pretty independent of the other faces, so they get added together. That being said, the differences between the likelihoods remains consistent until they go asymptotic at 100%. This is a pretty good indicator of how far out in the future a prediction can be made. In this case, it looks like 5-15 trials in the future before the high values converge. Note though that the very low values (F5 and F6,which were near zero) still do not have a significant impact on the outcome in this time horizon. So the ability to project into the future is strongly dependent on how spread out the initial probabilities are when the binomial calculations are invoked.