• 0
bixie

Export issues

Question

Posted (edited)

 

i want to export my file with respect to the date and time it was created. Can anyone help. So the date and time should be as a folder 

Impedance1.Export("~/Desktop/SeeIfIWork/"#ddmmyy"/Messung"+Index+".png")

Edited by rohanchakraborty
unnecessary part edited

Share this post


Link to post
Share on other sites

10 answers to this question

Recommended Posts

  • 0

Hi @rohanchakraborty

 

function date() {
    var now = new Date(),
        year = '' + (now.getFullYear()%2000),
        month = '' + (now.getMonth() + 1),
        day = '' + now.getDate();

    if (year.length < 2) year = '0' + year;
    if (month.length < 2) month = '0' + month;
    if (day.length < 2) day = '0' + day;

    return [year, month, day].join('_'); // '' no separator
}

....
var filename = "~/Desktop/SeeIfIWork/"+date()+"/Messung"+Index+".png"
Impedance.single()
Impedance.wait()
Impedance.Export(filename)

 

Share this post


Link to post
Share on other sites
  • 0

Hi @attila 

Thanks a lot! I'm also a bit confused about this part, please help

I want also a folder which has time specified in side the date folder, only showing what hour it is of that day 24 h format

and if there's already an existing folder with that hour eg 12, then it should have something like "12 1"

Share this post


Link to post
Share on other sites
  • 0

Hi @bixie

Where do you want the hour to be ? Where do you want the '1,2,3' suffix to be ? In the directory or in the file name ?

On 8/22/2019 at 1:14 PM, bixie said:

Impedance1.Export("~/Desktop/SeeIfIWork/"#ddmmyy"/Messung"+Index+".png")

 

Share this post


Link to post
Share on other sites
  • 0

Hi @bixie

image.thumb.png.52eb0e8e48f61634eb7a8ce26b642fbd.png

const Index = 1

function dir(){
     var now = new Date(),
        year = '' + (now.getFullYear()%2000),
        month = '' + (now.getMonth() + 1),
        day = '' + now.getDate(),
        hour = '' + now.getHours();

    if (year.length < 2) year = '0' + year;
    if (month.length < 2) month = '0' + month;
    if (day.length < 2) day = '0' + day;
    if (hour.length < 2) hour = '0' + hour;

    var dirbase = "~/Desktop/SeeIfIWork/#"+day+month+year+"/#"+hour
    for(var i = 0; i < 1000; i++){
        var dirname = dirbase;
        if(i!=0) dirname += " "+i;
        var test = File(dirname)
        var exists = test.exists();
        delete test;
        if(!exists) return dirname;
    }
    return "";
}

Impedance.single();
Impedance.wait();

var filename = dir()+"/Messung"+Index+".png";
print(filename);
Impedance.Export(filename);

 

Share this post


Link to post
Share on other sites
  • 0

Hi @attila

I’m facing an export problem on Probe 2, here,

 

if(!('Impedance1' in this)) throw "Please open the Impedance1 instrument";

if(!('Supplies' in this)) throw "Please open the Supplies instrument";

if(!('StaticIO' in this)) throw "Please open the StaticIO instrument";

 

//Impedance Settings

Impedance1.Frequency.Samples.value=51

Impedance1.Frequency.Start.value=1

Impedance1.Frequency.Stop.value=100000

Impedance1.Wavegen.Amplitude.value=0.2

Impedance1.Resistor.resistor=100

 

//Supplier Settings

Supplies.Output.PositiveSupply.Voltage.value=5

Supplies.Output.NegativeSupply.Voltage.value=-5

Supplies.Output.PositiveSupply.Enable.value=1

Supplies.Output.NegativeSupply.Enable.value=1

Supplies.run()

 

for(var c = 0; c < 8; c++){

StaticIO.Channel0.DIO[c].Mode.text = "Switch";

//dd=Date()

//folder=print(dd)

Index=1

 

//My Addition dt 23.08.19 ---ST--

//const Index = 1

 

function dir(){

var now = new Date(),

year = '' + (now.getFullYear()),

month = '' + (now.getMonth() + 1),

day = '' + now.getDate(),

hour = '' + now.getHours();

 

if (year.length < 2) year = '0' + year;

if (month.length < 2) month = '0' + month;

if (day.length < 2) day = '0' + day;

if (hour.length < 2) hour = '0' + hour;

 

var dirbase = "~/Desktop/TEERvalues/"+year+" "+month+" "+day+"/"+hour

for(var i = 0; i < 1000; i++){

var dirname = dirbase;

if(i!=0) dirname += " "+i;

var test = File(dirname)

var exists = test.exists();

delete test;

if(!exists) return dirname;

}

return "";

}

var filename = dir()+"/Messung"+Index+".png";

var filenametxt = dir()+"/Messung"+Index+".txt";

//My Addition dt 23.08.19 --END--

 

StaticIO.run()

 

// 1.Probe

print("Running pin 1, channel 1")

StaticIO.Channel0.DIO[3].text = "0";

StaticIO.Channel0.DIO[4].text = "1";

StaticIO.Channel0.DIO[5].text = "1";

StaticIO.Channel0.DIO[0].text = "0";

StaticIO.Channel0.DIO[1].text = "0";

StaticIO.Channel0.DIO[2].text = "0";

Impedance1.single()

wait(120)

 

Impedance1.Export("~/Desktop/SeeIfIWork/und/Messung"+Index+".png")

 

 

 

Impedance1.Export(filename)

Impedance1.Export(filenametxt)

 

// Impedance1.Export("~/Desktop/Bachelor Arbeit/Bilder/Messung"+Index+".png")

 

 

Index++

 

// 2.Probe

print("Running pin 2, channel 2")

StaticIO.Channel0.DIO[3].text = "0";

StaticIO.Channel0.DIO[4].text = "1";

StaticIO.Channel0.DIO[5].text = "1";

StaticIO.Channel0.DIO[0].text = "1";

StaticIO.Channel0.DIO[1].text = "0";

StaticIO.Channel0.DIO[2].text = "0";

Impedance1.single()

wait(120)

//Impedance1.Export("~/Desktop/SeeIfIWork/"dd+MM+yy"/Messung"+Index+".png")

 

Impedance1.Export(filename)

Impedance1.Export(filenametxt)

Index++

______
Here^^

please help me correct my mistake 

Share this post


Link to post
Share on other sites
  • 0

@attila it isn't exporting the files after the first time. Here:

 

/ 2.Probe

print("Running pin 2, channel 2")

StaticIO.Channel0.DIO[3].text = "0";

StaticIO.Channel0.DIO[4].text = "1";

StaticIO.Channel0.DIO[5].text = "1";

StaticIO.Channel0.DIO[0].text = "1";

StaticIO.Channel0.DIO[1].text = "0";

StaticIO.Channel0.DIO[2].text = "0";

Impedance1.single()

wait(120)

//Impedance1.Export("~/Desktop/SeeIfIWork/"dd+MM+yy"/Messung"+Index+".png")

 

Impedance1.Export(filename)

Impedance1.Export(filenametxt)

Index++

Share this post


Link to post
Share on other sites
  • 0

Hi @bixie

1. In the forum you can use the <> to insert code.
2. In the script you are using the same filename in exports in "Probe 1 and 2".
3. With the StaticIO you are probably controlling some external components, so a few milliseconds of wait could be indicated to take effect.
4. You can use Impedance.wait() to wait for analysis to finish.
5. Calling dir function twice could give different results (in filename and filenametxt) since time elapses from one call to another.
6. The ImpedanceAnalyzer takes control over the Supplies and StaticIO when used with the IA Adapter.

Index=1
// 1.Probe
print("Running pin 1, channel 1")
StaticIO.Channel0.DIO[3].text = "0";
StaticIO.Channel0.DIO[4].text = "1";
StaticIO.Channel0.DIO[5].text = "1";
StaticIO.Channel0.DIO[0].text = "0";
StaticIO.Channel0.DIO[1].text = "0";
StaticIO.Channel0.DIO[2].text = "0";
StaticIO.config() // force immediate configuration

wait(1) // wait on external device/circuit
Impedance1.single()
Impedance1.wait()

dirname = dir() 
Impedance1.Export(dirname+"/Messung"+Index+".png")
Impedance1.Export(dirname+"/Messung"+Index+".txt")
 
Index++
// 2.Probe
print("Running pin 2, channel 2")
StaticIO.Channel0.DIO[3].text = "0";
StaticIO.Channel0.DIO[4].text = "1";
StaticIO.Channel0.DIO[5].text = "1";
StaticIO.Channel0.DIO[0].text = "1";
StaticIO.Channel0.DIO[1].text = "0";
StaticIO.Channel0.DIO[2].text = "0";
StaticIO.config()

wait(1)
Impedance1.single()
Impedance1.wait()
 
dirname = dir() 
Impedance1.Export(dirname+"/Messung"+Index+".png")
Impedance1.Export(dirname+"/Messung"+Index+".txt")

 

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now