Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
DNI-Meta-Model
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Descartes Research
DNI-Meta-Model
Commits
352fb7bd
Commit
352fb7bd
authored
9 years ago
by
Piotr
Browse files
Options
Downloads
Patches
Plain Diff
propagate to DNI3: change applyPrefix and getDependecyValue 1000 vs 1024
parent
b04ca90d
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
DNI3/genDNI/eol/dependency.eol
+32
-13
32 additions, 13 deletions
DNI3/genDNI/eol/dependency.eol
with
32 additions
and
13 deletions
DNI3/genDNI/eol/dependency.eol
+
32
−
13
View file @
352fb7bd
...
...
@@ -75,6 +75,12 @@ operation Any toString() : String {
////////////////////////////////////////////////////////////////////////////////////////
operation DNI!Dependency getDependencyValue() : Real {
//self.value - Real / Long
//self.unit - DNIUnit (abstract): TimeUnit, DataUnit, SpeedUnit
//self.unit.unit = Time, Speed
//self.unit.prefix = UnitPrefix
var value = 0.0;
if(self.hasProperty("value")){
...
...
@@ -96,31 +102,44 @@ operation DNI!Dependency getDependencyValue() : Real {
value = value/1000.0/1000.0;
}
}
else if(self.unit.isTypeOf(DNI!DataUnit)){ //////////// this is data unit
//nothing. prefix is applied later
else if(self.unit.isTypeOf(DNI!DataUnit)){ //////////// this is data unit - 1 KB = 1024B
if(self.unit.hasProperty("prefix")){
if(self.unit.prefix.isTypeOf(DNI!EEnumLiteral)){
value = self.unit.prefix.applyPrefix(value, 1024);
}
}
}
else if(self.unit.isTypeOf(DNI!SpeedUnit)){ //////////// this is througput unit
if(self.unit.unit==DNI!Speed#bitsPerSec){
value /= 8d;
//value /= 8d; //whoy do you want to convert it into bytes??
if(self.unit.hasProperty("prefix")){
if(self.unit.prefix.isTypeOf(DNI!EEnumLiteral)){
value = self.unit.prefix.applyPrefix(value, 1000);
}
}
}
else if(self.unit==DNI!Speed#packetsPerSec){
throw ("Cannot convert DNI!SpeedUnit packets per second to Bytes per second!");
if(self.unit.hasProperty("prefix")){
if(self.unit.prefix.isTypeOf(DNI!EEnumLiteral)){
value = self.unit.prefix.applyPrefix(value, 1000);
}
}
throw ("WARNING! WE return packets per second! Make sure that this is what you want");
}
else{
else if(self.unit==DNI!Speed#bytesPerSec){
if(self.unit.hasProperty("prefix")){
if(self.unit.prefix.isTypeOf(DNI!EEnumLiteral)){
value = self.unit.prefix.applyPrefix(value, 1024);
}
}
}
}
if(self.unit.hasProperty("prefix")){
if(self.unit.prefix.isTypeOf(DNI!EEnumLiteral)){
value = self.unit.prefix.applyPrefix(value, 1000); ///this should not be always 1000!!! 1 Kbps = 1000 bps, but 1KBps = 1024 Bps!!
}
}
}
return value;
}
////////////////////////////////////////////////////////////////////////////////////////
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment